Spaces:
Runtime error
Runtime error
import torch | |
import scipy | |
import time | |
from transformers import set_seed, pipeline | |
def goai_tts(texte, device): | |
""" | |
Pour un texte donné, donner le speech en Mooré correspondant | |
Paramètres | |
---------- | |
texte: str | |
Le texte écrit. | |
device: str | |
GPU ou CPU | |
Return | |
------ | |
L'audio synthétisé. | |
""" | |
### assurer la reproductibilité | |
set_seed(2024) | |
start_time = time.time() | |
### charger le modèle TTS | |
model_id = "anyantudre/mms-tts-mos-V1" | |
synthesiser = pipeline("text-to-speech", model_id, device=device) # add device=0 if you want to use a GPU | |
### inférence | |
speech = synthesiser(texte) | |
wavfile = scipy.io.wavfile.write("finetuned_output.wav", rate=speech["sampling_rate"], data=speech["audio"][0]) | |
print("Temps écoulé: ", int(time.time() - start_time), " secondes") | |
return wavfile |