import numpy as np from TTS.api import TTS from huggingface_hub import hf_hub_download import subprocess REPO_NAME="DigitalUmuganda/Kinyarwanda_YourTTS" class TextToSpeech(): def __init__(self) -> None: hf_hub_download(repo_id=REPO_NAME,filename="config.json") hf_hub_download(repo_id=REPO_NAME,filename="SE_checkpoint.pth.tar") hf_hub_download(repo_id=REPO_NAME,filename="config_se.json") hf_hub_download(repo_id=REPO_NAME,filename="model.pth") hf_hub_download(repo_id=REPO_NAME,filename="speakers.pth") hf_hub_download(repo_id=REPO_NAME,filename="conditioning_audio.wav") def run_tts(self,text): tts = TTS(model_path="model.pth", config_path="config.json", tts_speakers_file="speakers.pth", encoder_checkpoint="SE_checkpoint.pth.tar", encoder_config="config_se.json",) wav = tts.tts(text, speaker_wav="conditioning_audio.wav") return wav