Spaces:
Running
Running
Commit
·
669226b
1
Parent(s):
58a2f85
Added sentences to test the voice easier
Browse files- app.py +13 -3
- assets/sentences_es.txt +26 -0
app.py
CHANGED
@@ -6,11 +6,13 @@ from huggingface_hub import hf_hub_download
|
|
6 |
from piper import PiperVoice
|
7 |
from transformers import pipeline
|
8 |
import typing
|
|
|
9 |
|
10 |
model_path = hf_hub_download(repo_id="larcanio/piper-voices", filename="es_AR-daniela-high.onnx")
|
11 |
config_path = hf_hub_download(repo_id="larcanio/piper-voices", filename="es_AR-daniela-high.json")
|
12 |
voice = PiperVoice.load(model_path, config_path)
|
13 |
-
|
|
|
14 |
|
15 |
def synthesize_speech(text):
|
16 |
# Create an in-memory buffer for the WAV file
|
@@ -30,6 +32,9 @@ def synthesize_speech(text):
|
|
30 |
|
31 |
return audio_data.tobytes(), None
|
32 |
|
|
|
|
|
|
|
33 |
BANNER_TEXT = """
|
34 |
# Demo en español argentino con Piper
|
35 |
|
@@ -52,12 +57,17 @@ on [piper's shoulders](https://huggingface.co/rhasspy/piper-voices) by [rhasspy]
|
|
52 |
with gr.Blocks(theme=gr.themes.Base()) as demo:
|
53 |
gr.Markdown(BANNER_TEXT)
|
54 |
input_text = gr.Textbox(label=" ", placeholder="Introduce el texto a leer aquí")
|
55 |
-
|
|
|
|
|
|
|
56 |
output_text = gr.Textbox(label="Tokens generados", visible=False)
|
57 |
-
|
58 |
gr.Markdown(FOOTER_TEXT)
|
59 |
|
60 |
submit_button.click(synthesize_speech, inputs=input_text, outputs=[output_audio, output_text])
|
|
|
|
|
61 |
|
62 |
if __name__ == '__main__':
|
63 |
demo.launch()
|
|
|
6 |
from piper import PiperVoice
|
7 |
from transformers import pipeline
|
8 |
import typing
|
9 |
+
import random
|
10 |
|
11 |
model_path = hf_hub_download(repo_id="larcanio/piper-voices", filename="es_AR-daniela-high.onnx")
|
12 |
config_path = hf_hub_download(repo_id="larcanio/piper-voices", filename="es_AR-daniela-high.json")
|
13 |
voice = PiperVoice.load(model_path, config_path)
|
14 |
+
with open('assets/sentences_es.txt', 'r') as r:
|
15 |
+
random_quotes = [line.strip() for line in r]
|
16 |
|
17 |
def synthesize_speech(text):
|
18 |
# Create an in-memory buffer for the WAV file
|
|
|
32 |
|
33 |
return audio_data.tobytes(), None
|
34 |
|
35 |
+
def get_random_quote():
|
36 |
+
return random.choice(random_quotes)
|
37 |
+
|
38 |
BANNER_TEXT = """
|
39 |
# Demo en español argentino con Piper
|
40 |
|
|
|
57 |
with gr.Blocks(theme=gr.themes.Base()) as demo:
|
58 |
gr.Markdown(BANNER_TEXT)
|
59 |
input_text = gr.Textbox(label=" ", placeholder="Introduce el texto a leer aquí")
|
60 |
+
with gr.Row():
|
61 |
+
submit_button = gr.Button("Genera audio")
|
62 |
+
random_btn = gr.Button('🎲 Cita aleatoria 💬', variant='secondary')
|
63 |
+
output_audio = gr.Audio(label="Audio generado", type="numpy", interactive=False, streaming=False, autoplay=True)
|
64 |
output_text = gr.Textbox(label="Tokens generados", visible=False)
|
65 |
+
|
66 |
gr.Markdown(FOOTER_TEXT)
|
67 |
|
68 |
submit_button.click(synthesize_speech, inputs=input_text, outputs=[output_audio, output_text])
|
69 |
+
random_btn.click(fn=get_random_quote, inputs=[], outputs=[input_text])
|
70 |
+
|
71 |
|
72 |
if __name__ == '__main__':
|
73 |
demo.launch()
|
assets/sentences_es.txt
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
No, no vamos a generar algo.
|
2 |
+
¿Te quieres casar conmigo? Me preguntó el muy valiente.
|
3 |
+
¡Sí! esa fue la respuesta que dio y que marcó su destino.
|
4 |
+
Enumeremos los resultados: uno, dos, tres, cuatro y cinco.
|
5 |
+
Puedes decir el número 27?
|
6 |
+
Vamos a ver qué tiene. cuáles son las mejores? Esas son las que quiero.
|
7 |
+
No, no, no; es la forma que parece más sencilla de evadir algo.
|
8 |
+
¡ay! otra vez con la misma situación!
|
9 |
+
mirá, tiene el copete rosado.
|
10 |
+
Se le saltó la térmica
|
11 |
+
Tres tristes tigres tragan trigo
|
12 |
+
Que me la rompes. El morral se me ha llenado.
|
13 |
+
Erre con erre cigarro, erre con erre barril, rápido ruedan los carros cargados de azúcar del ferrocarril.
|
14 |
+
Zaragoza es una ciudad importante de España
|
15 |
+
Un viaje se mide mejor en amigos que en millas.
|
16 |
+
El gran placer de la vida es hacer lo que la gente dice que no puedes.
|
17 |
+
El éxito es caer siete veces y levantarte ocho.
|
18 |
+
Un viajero sin capacidad de observación es como un pájaro sin alas.
|
19 |
+
De ningún laberinto propio se sale con llave ajena.
|
20 |
+
Me he dado cuenta que no hay forma más segura de saber si amas u odias a la gente que viajando con ellas.
|
21 |
+
Nunca sabes lo fuerte que eres, hasta que ser fuerte es la única opción que te queda.
|
22 |
+
Hemos sido puestos aquí para aprender lecciones que nos convertirán en almas más completas.
|
23 |
+
Si piensas que la aventura es peligrosa, prueba la rutina. Es mortal.
|
24 |
+
No esperes. El momento perfecto nunca llegará.
|
25 |
+
El mundo es un libro, y aquellos que no viajan leen solo una página.
|
26 |
+
La gente que está lo suficientemente loca para pensar que pueden cambiar el mundo, son aquellas que lo consiguen.
|