Spaces:
Running
Running
faelfernandes
commited on
Commit
•
eab81ba
1
Parent(s):
a020e84
Update app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,10 @@ VOICES = {
|
|
10 |
"Brian (Multilingual)": "en-US-BrianMultilingualNeural",
|
11 |
"Francisca": "pt-BR-FranciscaNeural",
|
12 |
"Thalita": "pt-BR-ThalitaNeural",
|
13 |
-
"Ava (
|
14 |
-
"Emma (
|
15 |
-
|
16 |
}
|
17 |
|
18 |
-
# Função para gerar o áudio
|
19 |
async def text_to_speech(text, voice):
|
20 |
voice_key = VOICES[voice]
|
21 |
output_file = f"output_{hash(text)}.mp3"
|
@@ -23,22 +21,67 @@ async def text_to_speech(text, voice):
|
|
23 |
await communicate.save(output_file)
|
24 |
return output_file
|
25 |
|
26 |
-
# Função para processar a entrada e chamar o TTS
|
27 |
async def process_tts(text, voice):
|
28 |
return await text_to_speech(text, voice)
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
convert_button.click(process_tts, inputs=[text_input, voice], outputs=[audio_output])
|
42 |
|
43 |
-
|
44 |
-
iface.launch()
|
|
|
10 |
"Brian (Multilingual)": "en-US-BrianMultilingualNeural",
|
11 |
"Francisca": "pt-BR-FranciscaNeural",
|
12 |
"Thalita": "pt-BR-ThalitaNeural",
|
13 |
+
"Ava (Multilingual)": "en-US-AvaMultilingualNeural",
|
14 |
+
"Emma (Multilingual)": "en-US-EmmaMultilingualNeural"
|
|
|
15 |
}
|
16 |
|
|
|
17 |
async def text_to_speech(text, voice):
|
18 |
voice_key = VOICES[voice]
|
19 |
output_file = f"output_{hash(text)}.mp3"
|
|
|
21 |
await communicate.save(output_file)
|
22 |
return output_file
|
23 |
|
|
|
24 |
async def process_tts(text, voice):
|
25 |
return await text_to_speech(text, voice)
|
26 |
|
27 |
+
css = """
|
28 |
+
body {
|
29 |
+
background-color: #f0f0f0;
|
30 |
+
font-family: 'Arial', sans-serif;
|
31 |
+
}
|
32 |
+
.container {
|
33 |
+
max-width: 800px;
|
34 |
+
margin: 0 auto;
|
35 |
+
padding: 20px;
|
36 |
+
background-color: white;
|
37 |
+
border-radius: 10px;
|
38 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
39 |
+
}
|
40 |
+
h1 {
|
41 |
+
color: #2c3e50;
|
42 |
+
text-align: center;
|
43 |
+
margin-bottom: 30px;
|
44 |
+
}
|
45 |
+
.footer {
|
46 |
+
text-align: center;
|
47 |
+
margin-top: 50px;
|
48 |
+
color: #7f8c8d;
|
49 |
+
font-size: 0.9em;
|
50 |
+
}
|
51 |
+
"""
|
52 |
+
|
53 |
+
with gr.Blocks(css=css) as iface:
|
54 |
+
with gr.Column(elem_classes="container"):
|
55 |
+
gr.Markdown("# TSM - Texto em Voz")
|
56 |
+
gr.Markdown("Converta texto em fala usando vozes em português e multilíngues.")
|
57 |
+
|
58 |
+
with gr.Row():
|
59 |
+
with gr.Column(scale=2):
|
60 |
+
text_input = gr.Textbox(
|
61 |
+
label="Digite o texto para converter em fala",
|
62 |
+
placeholder="Escreva seu texto aqui...",
|
63 |
+
lines=5
|
64 |
+
)
|
65 |
+
with gr.Column(scale=1):
|
66 |
+
voice = gr.Radio(
|
67 |
+
choices=list(VOICES.keys()),
|
68 |
+
label="Escolha a voz",
|
69 |
+
value="Francisca"
|
70 |
+
)
|
71 |
+
|
72 |
+
convert_button = gr.Button("Converter para Áudio", variant="primary")
|
73 |
+
audio_output = gr.Audio(label="Áudio Gerado")
|
74 |
+
|
75 |
+
gr.Markdown(
|
76 |
+
"""
|
77 |
+
<div class="footer">
|
78 |
+
<p>Desenvolvido por [Seu Nome/Empresa] © 2023</p>
|
79 |
+
<p>Powered by Azure Text-to-Speech</p>
|
80 |
+
</div>
|
81 |
+
""",
|
82 |
+
elem_classes="footer"
|
83 |
+
)
|
84 |
|
85 |
convert_button.click(process_tts, inputs=[text_input, voice], outputs=[audio_output])
|
86 |
|
87 |
+
iface.launch(show_api=False)
|
|