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="Kinyarwanda_YourTTS/model.pth", config_path="Kinyarwanda_YourTTS/config.json", tts_speakers_file="Kinyarwanda_YourTTS/speakers.pth", encoder_checkpoint="Kinyarwanda_YourTTS/SE_checkpoint.pth.tar", encoder_config="Kinyarwanda_YourTTS/config_se.json",) wav = tts.tts(text, speaker_wav="kinyarwanda_YourTTS/conditioning_audio.wav") return wav