Spaces:
No application file
No application file
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import soundfile as sf
|
| 3 |
+
from tango import Tango
|
| 4 |
+
import IPython.display as ipd
|
| 5 |
+
|
| 6 |
+
# Initialize the Tango model
|
| 7 |
+
tango = Tango("declare-lab/tango-full-ft-audiocaps")
|
| 8 |
+
|
| 9 |
+
# Function to generate audio from text prompt
|
| 10 |
+
def generate_audio(prompt):
|
| 11 |
+
# Generate audio from the prompt
|
| 12 |
+
audio = tango.generate(prompt)
|
| 13 |
+
# Save the audio to a file
|
| 14 |
+
file_path = f"{prompt}.wav"
|
| 15 |
+
sf.write(file_path, audio, samplerate=16000)
|
| 16 |
+
return file_path
|
| 17 |
+
|
| 18 |
+
# Gradio interface
|
| 19 |
+
interface = gr.Interface(
|
| 20 |
+
fn=generate_audio,
|
| 21 |
+
inputs="text",
|
| 22 |
+
outputs="audio",
|
| 23 |
+
title="Audio Generation with Tango",
|
| 24 |
+
description="Enter a prompt to generate an audio description using the Tango model."
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Launch the app
|
| 28 |
+
interface.launch()
|