File size: 974 Bytes
761c6e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c18603b
 
 
 
 
 
761c6e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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