Spaces:
Runtime error
Runtime error
File size: 1,752 Bytes
5e334c0 96dd0a7 84f4ed8 2dadc0d 4f802fe 5e334c0 99a10fe 35c62b8 a816c10 5e334c0 2dadc0d 287b0f4 2dadc0d 5e334c0 155ba90 5e334c0 f9f52a1 287b0f4 5e334c0 155ba90 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 |
import tempfile
from typing import Optional
import gradio as gr
import subprocess
import numpy as np
from TTS.utils.synthesizer import Synthesizer
MAX_TXT_LEN = 1000
subprocess.check_output("git lfs install", shell=True)
subprocess.check_output("git clone https://huggingface.co/DigitalUmuganda/Kinyarwanda_YourTTS",
shell=True)
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.")
synthesizer = Synthesizer("./Kinyarwanda_YourTTS/model.pth",
"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 = synthesizer.tts(text, speaker_wav="Kinyarwanda_YourTTS/conditioning_audio.wav")
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="Muraho neza! nizere ko umunsi uri kugenda neza.",
),
],
outputs=gr.outputs.Audio(type="filepath",label="Output"),
#outputs=gr.outputs.Textbox(label="Recognized speech from speechbrain model"),
title="Kinyarwanda tts Demo",
description="Kinyarwanda tts build By Digital Umuganda, using the Bible dataset, and trained on YourTTS model.",
allow_flagging=False,
flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
layout="vertical",
live=False
)
iface.launch(share=False) |