Spaces:
Runtime error
Runtime error
File size: 913 Bytes
e41ca58 1ffb58d 9f0bf0f 1ffb58d e41ca58 cfc8501 1ffb58d e41ca58 1ffb58d cfc8501 1ffb58d e41ca58 1ffb58d e41ca58 1ffb58d e41ca58 9f0bf0f 1ffb58d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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 |