khmer-tts / app.py
seanghay's picture
rename
d6fe989 verified
raw
history blame
1.13 kB
# -*- coding: utf-8 -*-
import re
from ttsmms import TTS
import gradio as gr
tts = TTS("khm")
def sanitize(text):
return re.sub(r"\u200b", "", text)
def generate_voice(text):
audio = tts.synthesis(text)
return (audio['sampling_rate'], audio['x'])
with gr.Blocks(title="Khmer Text to Speech with MMS") as blocks:
gr.Markdown('# Khmer Text to Speech - MMS')
gr.Markdown('MMS: Scaling Speech Technology to 1000+ languages by Meta AI')
input_text = gr.Textbox(label="αž’αž€αŸ’αžŸαžš", lines=3)
examples = gr.Examples(examples=["αž“αŸαŸ‡β€‹αž‡αžΆβ€‹αžšαžΌαž”αžαžβ€‹αž‡αž“αžŸαž„αŸ’αžŸαŸαž™β€‹αžŠαŸ‚αž›β€‹αž”αŸαžΈαž€αž‘αžΆαž“αŸ”"], inputs=[input_text])
run_button = gr.Button(
text="Generate",
type="button",
)
out_audio = gr.Audio(
label="αžŸαŸ†αž‘αŸαž„αžŠαŸ‚αž›αž”αžΆαž“αž”αž„αŸ’αž€αžΎαž",
type="numpy",
)
inputs = [input_text]
outputs = [out_audio]
run_button.click(
fn=generate_voice,
inputs=inputs,
outputs=outputs,
queue=True,
)
blocks.queue(concurrency_count=1).launch(debug=True)