Spaces:
Running
Running
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[20]: | |
from gtts import gTTS | |
import gradio as gr | |
import warnings | |
warnings.filterwarnings('ignore') | |
# In[22]: | |
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" | |
# In[25]: | |
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() | |
# In[ ]: | |