ragha108's picture
Update app.py
ad4a7ba
raw
history blame
752 Bytes
from gtts import gTTS
import gradio as gr
import os
from coqui_tts import Synthesizer
def text_to_audio(text):
# Load a pre-trained model
model = Synthesizer.from_pretrained("tts_models/coqui_tts/cleanup")
# Generate audio from text using gTTS
audio = model.synthesize(text)
# Save audio to file
with open("output.wav", "wb") as f:
f.write(audio)
# def text_to_audio(text):
# # Generate audio from text using gTTS
# tts = gTTS(text=text, lang='en', slow=False)
# tts.save("test.wav")
# return 'test.wav'
iface = gr.Interface(fn = text_to_audio,
inputs = 'text',
outputs = 'audio',
verbose = True,
)
iface.launch()