ljdfghjo / app.py
HabibiBear's picture
Create app.py
b9b74eb verified
raw
history blame contribute delete
738 Bytes
import gradio as gr
import soundfile as sf
from tango import Tango
import IPython.display as ipd
# Initialize the Tango model
tango = Tango("declare-lab/tango-full-ft-audiocaps")
# Function to generate audio from text prompt
def generate_audio(prompt):
# Generate audio from the prompt
audio = tango.generate(prompt)
# Save the audio to a file
file_path = f"{prompt}.wav"
sf.write(file_path, audio, samplerate=16000)
return file_path
# Gradio interface
interface = gr.Interface(
fn=generate_audio,
inputs="text",
outputs="audio",
title="Audio Generation with Tango",
description="Enter a prompt to generate an audio description using the Tango model."
)
# Launch the app
interface.launch()