File size: 499 Bytes
b23d86c
 
 
 
 
 
 
 
 
 
 
 
f6a5f10
 
 
d9c9ec8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr

def text_to_speech(text, voice):
    import subprocess
    import audiosegment

    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)


voice_options = ["en-US-JennyNeural", "en-US-GuyNeural"]

gr.Interface(fn=text_to_speech, inputs=["text", gr.Dropdown(voice_options)], outputs="audio").launch()