Spaces:
Sleeping
Sleeping
File size: 1,415 Bytes
2e03983 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
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") |