Spaces:
Running
Running
File size: 632 Bytes
b23d86c 207d168 b23d86c 207d168 f6a5f10 207d168 f6a5f10 207d168 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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() |