TextToSpeech / app.py
RIZAEFE's picture
Upload app.py
54a1a72 verified
raw
history blame
795 Bytes
from gtts import gTTS
import gradio as gr
def textToSpeech(text,lang,file):
if file is not None:
with open(file.name, "r", encoding="utf-8") as f:
text = f.read()
record=gTTS(text=text,lang=lang,slow=False)
record.save("output.mp3")
return "output.mp3"
interface=gr.Interface(
fn=textToSpeech,
inputs=[gr.Textbox(label='Text to be spoken'),
gr.Dropdown(
["tr", "en", "fr", "de"],
label="Language Selection",
value="tr"),
gr.File(label="Upload Text File(Optional)",type="filepath")
],
outputs=gr.Audio(label="Voice"),
title="Text To Speech",
description="Enter the text you want to voice into the box"
)
interface.launch()