Spaces:
Running
Running
| import gradio as gr | |
| from vachanatts import TTS | |
| def generate_tts(text, voice, volume, speed ,noise_w_scale): | |
| output_path = "output.wav" | |
| TTS( | |
| text, | |
| voice=voice, | |
| output=output_path, | |
| volume=volume, | |
| speed=speed, | |
| noise_w_scale=noise_w_scale | |
| ) | |
| return output_path | |
| voices = ["th_f_1", "th_m_1", "th_f_2", "th_m_2"] | |
| minimal_theme = gr.themes.Base( | |
| primary_hue="blue", | |
| secondary_hue="slate", | |
| neutral_hue="gray", | |
| font=[gr.themes.GoogleFont("Inter"), "sans-serif"], | |
| font_mono=[gr.themes.GoogleFont("Fira Mono"), "monospace"], | |
| radius_size="md", | |
| spacing_size="md", | |
| text_size="md" | |
| ) | |
| with gr.Blocks(title="VachanaTTS",theme=minimal_theme) as demo: | |
| gr.Markdown(""" | |
| # VachanaTTS | |
| Text to Speech ภาษาไทยรวดเร็วและใช้งานง่าย. | |
| """) | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| text_input = gr.Textbox(label="📝 ใส่ข้อความ", placeholder="พิมพ์ข้อความที่นี่...", lines=4) | |
| voice_dropdown = gr.Dropdown(choices=voices, value="th_f_1", label="🎤 Voice") | |
| volume_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="🔊 ระดับเสียง") | |
| speed_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="⚡ ความเร็ว") | |
| noise_w_scale_value= gr.Slider(0.2, 1.5, value=0.8, step=0.1, label="🎭 ความหลากหลายของน้ำเสียง") | |
| generate_button = gr.Button("🚀 สร้าง",variant="primary") | |
| with gr.Column(scale=1): | |
| output_audio = gr.Audio(label="🔈 เสียงที่สร้าง", type="filepath") | |
| generate_button.click( | |
| fn=generate_tts, | |
| inputs=[text_input, voice_dropdown, volume_slider, speed_slider, noise_w_scale_value], | |
| outputs=[output_audio] | |
| ) | |
| # Launch app | |
| demo.launch() | |