Spaces:
Running
Running
import gradio as gr | |
def text_to_speech(text, voice): | |
import subprocess | |
import audiosegment | |
from IPython.display import Audio, display | |
command = ['edge-tts', '--voice', voice, '--text', text, | |
'--write-media', 'edge.mp3', '--write-subtitles', 'edge.vtt'] | |
result = subprocess.run(command, stdout=subprocess.PIPE, text=True) | |
print(result.stdout) | |
try: | |
display(Audio("edge.mp3", autoplay=True)) | |
except Exception as e: | |
print("Error:", str(e)) | |
voice = ["en-US-JennyNeural", "en-US-GuyNeural"] | |
gr.Interface(fn=text_to_speech, inputs=["text", gr.Dropdown(voice)], outputs="audio").launch() |