File size: 2,320 Bytes
5e334c0
 
 
 
8e663ab
60c42f1
96dd0a7
4f802fe
5e334c0
 
4f802fe
60c42f1
5e334c0
 
 
 
8e663ab
 
 
 
 
 
 
 
 
 
 
96dd0a7
 
 
 
 
 
 
 
 
 
8e663ab
 
 
5e334c0
 
 
 
 
 
 
 
 
96dd0a7
 
5e334c0
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import tempfile
from typing import Optional
import gradio as gr
import numpy as np
from TTS.api import TTS
from huggingface_hub import snapshot_download
import subprocess


MAX_TXT_LEN = 100

snapshot_download(repo_id="DigitalUmuganda/Kinyarwanda_YourTTS",revision="main")
def generate_audio(text):
    if len(text) > MAX_TXT_LEN:
        text = text[:MAX_TXT_LEN]
        print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
    # model_path, config_path, model_item = manager.download_model(model_name)
    # vocoder_name: Optional[str] = model_item["default_vocoder"]
    # vocoder_path = None
    # vocoder_config_path = None
    # if vocoder_name is not None:
    #     vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name)
    # synthesizer = Synthesizer(
    #     model_path, config_path, None, None, vocoder_path, vocoder_config_path,
    # )
    # if synthesizer is None:
    #     raise NameError("model not found")
    # 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
    text1 = subprocess.check_output("ls", shell=True)+'   '+ subprocess.check_output("ls", shell=True)
    text2 = text1.decode("utf-8")
    return text2
    # with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
    #     synthesizer.save_wav(wav, fp)
    #     return fp.name

iface = gr.Interface(
    fn=generate_audio,
    inputs=[
        gr.inputs.Textbox(
            label="Input Text",
            default="This sentence has been generated by a speech synthesis system.",
        ),
    ],
    # outputs=gr.outputs.Audio(type="numpy",label="Output"),
    outputs=gr.outputs.Textbox(label="Recognized speech from speechbrain model"),
    title="Kinyarwanda tts Demo",
    description="Kinyarwanda tts build with ",
    allow_flagging=False,
    flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
    layout="vertical",
    live=False
)
iface.launch(share=False)