Spaces:
Runtime error
Runtime error
File size: 1,516 Bytes
9156a46 0553379 0216dec 9156a46 127fe57 9156a46 cb60843 8186f23 c39de10 cb60843 9156a46 cb60843 470c595 9156a46 926c699 8186f23 127fe57 3fc9c8f 023437b e397f6e 3fc9c8f 9156a46 |
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 ,os
import gradio as gr
MAX_TXT_LEN = 800
def tts(text: str):
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.")
print(text)
import subprocess
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
#print(fp)
output = subprocess.check_output(f'mimic3 --voice fa/haaniye_low "{text}" > {fp.name}', shell=True, stderr=subprocess.STDOUT)
return fp.name
description="""
Persian tts work by sanaweb group."""
article= ""
#متن زیر فرم
# examples=[
# "شیش سیخ جیگر سیخی شیش هزار",
# "سه شیشه شیر ، سه سیر سرشیر",
# "زندگی فقط یک بار است؛ از آن به خوبی استفاده کن",
# "مثنوی یکی از قالب های شعری است ک هر بیت قافیه ی جداگانه دارد",
# "در گلو ماند خس او سالها، چیست آن خس مهر جاه و مالها",
#]
iface = gr.Interface(
fn=tts,
inputs=[
gr.Textbox(
label="متن خود را وارد کنید",
value="گروه ثنا وب یک تیم حرفه ای فعال در حوزه علوم کامپیوتر",
)
],
outputs=gr.Audio(label="خروجی",type='filepath'),
# examples=examples
title="🗣️ تبدیل متن فارسی به صدای طبیعی 🗣️",
)
iface.launch(share=False) |