Nick088Edge-TTS / app.py
antoniomae1234's picture
Upload 4 files
2e03983 verified
raw
history blame
1.42 kB
import edge_tts
import gradio as gr
import tempfile
import anyio
language_dict = {
'English-Jenny (Female)': 'en-US-JennyNeural',
67 lindas mensagens de amor para namorado - Pensador
'Brazilian-Francisca- (Female)': 'pt-BR-FranciscaNeural',
'Brazilian-Antonio- (Male)': 'pt-BR-AntonioNeural',
'Brazilian-Antonio- (Male)': 'pt-BR-andrewNeural',
'Polish (Poland)-Zofia- (Female)': 'pl-PL-ZofiaNeural',
'Pashto (Afghanistan)-Gul Nawaz- (Male)': 'ps-AF-Gul',
}
async def text_to_speech_edge(text, language_code):
voice = language_dict.get(language_code, "default_voice")
communicate = edge_tts.Communicate(text, voice)
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
tmp_path = tmp_file.name
await communicate.save(tmp_path)
return f"Speech synthesis completed for: {text}", tmp_path
input_text = gr.Textbox(lines=5, label="Input Text")
output_text = gr.Textbox(label="Output Text")
output_audio = gr.Audio(type="filepath", label="Exported Audio")
language = gr.Dropdown(choices=list(language_dict.keys()), label="Choose the Voice Model")
interface = gr.Interface(
fn=text_to_speech_edge,
inputs=[input_text, language],
outputs=[output_text, output_audio],
title="Edge TTS",
description="Microsoft Edge Text-To-Speech (Forked & Fixed Ilaria TTS)",
)
if __name__ == "__main__":
anyio.run(interface.launch, backend="asyncio")