Spaces:
Sleeping
Sleeping
jhonparra18
commited on
Commit
•
53b42ec
1
Parent(s):
a88820e
app definition
Browse files- app.py +19 -0
- inference.py +36 -0
- requirements.txt +7 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from inference import text_to_speech
|
4 |
+
|
5 |
+
|
6 |
+
def greet(text=""):
|
7 |
+
return "this is a f test"
|
8 |
+
|
9 |
+
with gr.Blocks() as demo:
|
10 |
+
gr.Markdown("Text-to-Speech Gustavo Petro")
|
11 |
+
|
12 |
+
with gr.Row():
|
13 |
+
text_input = gr.Textbox(lines=2, placeholder="Hola soy Gustavo Petro y esta es mi voz de prueba")
|
14 |
+
|
15 |
+
text_button = gr.Button("Generate")
|
16 |
+
|
17 |
+
text_button.click(text_to_speech, inputs=text_input, outputs=gr.Audio(label="Model Response"))
|
18 |
+
|
19 |
+
demo.launch()
|
inference.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from TTS.api import TTS
|
2 |
+
from scipy.io import wavfile
|
3 |
+
import noisereduce as nr
|
4 |
+
import gdown
|
5 |
+
import os
|
6 |
+
|
7 |
+
cur_path=os.getcwd()
|
8 |
+
|
9 |
+
## download weights and config file
|
10 |
+
file_id = '1-uVNiBjN9d6GBZy3jubvgq7slyEgObyr'
|
11 |
+
url = f'https://drive.google.com/uc?id='
|
12 |
+
output = f'{cur_path}/best_model.pth'
|
13 |
+
gdown.download(f"{url}{file_id}", output, quiet=False)
|
14 |
+
|
15 |
+
file_id = '1-Jot_x7bkWUE5SyAcKaaAAC-_T8DSEYe'
|
16 |
+
url = f'https://drive.google.com/uc?id='
|
17 |
+
output = f'{cur_path}/config.json'
|
18 |
+
gdown.download(f"{url}{file_id}", output, quiet=False)
|
19 |
+
|
20 |
+
|
21 |
+
##load model
|
22 |
+
fake_voice=TTS(model_path=f"{cur_path}/best_model.pth",
|
23 |
+
config_path=f"{cur_path}/config.json")
|
24 |
+
|
25 |
+
def text_to_speech(text="Hola soy gustavo petro y esto es una prueba",output_name="test_audio.wav",model=fake_voice):
|
26 |
+
|
27 |
+
model.tts_to_file(text,file_path=output_name)
|
28 |
+
rate, data = wavfile.read(output_name)
|
29 |
+
reduced_noise = nr.reduce_noise(y=data, sr=rate)
|
30 |
+
wavfile.write(output_name, rate, reduced_noise)
|
31 |
+
return output_name
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
TTS==0.13.3
|
2 |
+
git+https://github.com/openai/whisper.git
|
3 |
+
pydub
|
4 |
+
noisereduce
|
5 |
+
gdown
|
6 |
+
numpy
|
7 |
+
gdown
|