| 200 | |
| 201 | # UI rendering |
| 202 | def render_interface() -> gr.Blocks: |
| 203 | with gr.Blocks(title="FireRedTTS-2", theme=gr.themes.Default()) as page: |
| 204 | # ======================== UI ======================== |
| 205 | # A large title |
| 206 | title_desc = gr.Markdown(value="# {}".format(i18n("title_md_desc"))) |
| 207 | with gr.Row(): |
| 208 | lang_choice = gr.Radio( |
| 209 | choices=["中文", "English"], |
| 210 | value="中文", |
| 211 | label="Display Language/显示语言", |
| 212 | type="index", |
| 213 | interactive=True, |
| 214 | ) |
| 215 | voice_mode_choice = gr.Radio( |
| 216 | choices=[i18n("voice_model_choice1"), i18n("voice_model_choice2")], |
| 217 | value=i18n("voice_model_choice1"), |
| 218 | label=i18n("voice_mode_label"), |
| 219 | type="index", |
| 220 | interactive=True, |
| 221 | ) |
| 222 | with gr.Row(): |
| 223 | # ==== Speaker1 Prompt ==== |
| 224 | with gr.Column(scale=1): |
| 225 | with gr.Group(visible=True) as spk1_prompt_group: |
| 226 | spk1_prompt_audio = gr.Audio( |
| 227 | label=i18n("spk1_prompt_audio_label"), |
| 228 | type="filepath", |
| 229 | editable=False, |
| 230 | interactive=True, |
| 231 | ) # Audio component returns tmp audio path |
| 232 | spk1_prompt_text = gr.Textbox( |
| 233 | label=i18n("spk1_prompt_text_label"), |
| 234 | placeholder=i18n("spk1_prompt_text_placeholder"), |
| 235 | lines=3, |
| 236 | ) |
| 237 | # ==== Speaker2 Prompt ==== |
| 238 | with gr.Column(scale=1): |
| 239 | with gr.Group(visible=True) as spk2_prompt_group: |
| 240 | spk2_prompt_audio = gr.Audio( |
| 241 | label=i18n("spk2_prompt_audio_label"), |
| 242 | type="filepath", |
| 243 | editable=False, |
| 244 | interactive=True, |
| 245 | ) |
| 246 | spk2_prompt_text = gr.Textbox( |
| 247 | label=i18n("spk2_prompt_text_label"), |
| 248 | placeholder=i18n("spk2_prompt_text_placeholder"), |
| 249 | lines=3, |
| 250 | ) |
| 251 | # ==== Text input ==== |
| 252 | with gr.Column(scale=2): |
| 253 | dialogue_text_input = gr.Textbox( |
| 254 | label=i18n("dialogue_text_input_label"), |
| 255 | placeholder=i18n("dialogue_text_input_placeholder"), |
| 256 | lines=18, |
| 257 | ) |
| 258 | # Generate button |
| 259 | generate_btn = gr.Button( |