Spaces:
Sleeping
Sleeping
from TTS.api import TTS | |
from scipy.io import wavfile | |
import noisereduce as nr | |
import gdown | |
import os | |
cur_path=os.getcwd() | |
## download weights and config file | |
file_id = '1-uVNiBjN9d6GBZy3jubvgq7slyEgObyr' | |
url = f'https://drive.google.com/uc?id=' | |
output = f'{cur_path}/best_model.pth' | |
gdown.download(f"{url}{file_id}", output, quiet=False) | |
file_id = '1-Jot_x7bkWUE5SyAcKaaAAC-_T8DSEYe' | |
url = f'https://drive.google.com/uc?id=' | |
output = f'{cur_path}/config.json' | |
gdown.download(f"{url}{file_id}", output, quiet=False) | |
##load model | |
fake_voice=TTS(model_path=f"{cur_path}/best_model.pth", | |
config_path=f"{cur_path}/config.json") | |
def text_to_speech(text="Hola soy gustavo petro y esto es una prueba",output_name="test_audio.wav",model=fake_voice): | |
model.tts_to_file(text,file_path=output_name) | |
rate, data = wavfile.read(output_name) | |
reduced_noise = nr.reduce_noise(y=data, sr=rate) | |
wavfile.write(output_name, rate, reduced_noise) | |
return output_name | |