Spaces:
Running
Running
File size: 1,427 Bytes
b740fff |
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 |
# -*- 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", theme=gr.themes.Default(font=[gr.themes.GoogleFont("Noto Sans Khmer"), "Arial", "sans-serif"])) 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(value="αααααΎα")
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) |