Spaces:
Runtime error
Runtime error
| import nltk, ssl | |
| from nltk.corpus import cmudict | |
| nltk.data.path.append("./nltk_data") | |
| from presets import * | |
| with gr.Blocks(css=customCSS) as demo: | |
| exceed_flag = gr.State(value=False) | |
| tmp_string = gr.Textbox(value="", visible=False) | |
| character_area = gr.HTML(get_character_html("你好呀!"), elem_id="character_area") | |
| with gr.Tab("Speak", elem_id="tab-speak"): | |
| speak_input = gr.Textbox(lines=1, label="Talking Flower will say:", elem_classes="wonder-card input_text", elem_id="speak_input") | |
| speak_button = gr.Button("Speak!", elem_id="speak_button", elem_classes="main-button wonder-card") | |
| example_category = gr.Examples(["夸夸你 | Praise", "游戏台词 | Scripts", "玩梗 | Meme"], inputs=[tmp_string], elem_id="examples") | |
| with gr.Tab("Chat", elem_id="tab-chat"): | |
| chat_input = gr.Textbox(lines=1, placeholder="Coming Soon...", label="Chat to Talking Flower:", elem_classes="wonder-card input_text", elem_id="chat_input", interactive=False) | |
| chat_button = gr.Button("Chat!", elem_id="chat_button", elem_classes="main-button wonder-card") | |
| with gr.Tab("Mimic", elem_id="tab-mimic"): | |
| gr.Textbox(lines=1, placeholder="Coming Soon...", label="Choose sound to mimic:", elem_classes="wonder-card input_text", elem_id="mimic_input", interactive=False) | |
| mimic_button = gr.Button("Mimic!", elem_id="mimic_button", elem_classes="main-button wonder-card") | |
| audio_output = gr.Audio(label="输出音频", show_label=False, autoplay=False, elem_id="audio_output", elem_classes="wonder-card") | |
| demo.load( | |
| init_fn, | |
| inputs=[], | |
| outputs=[character_area] | |
| ) | |
| speak_input.submit(submit_lock_fn, show_progress=False).then( | |
| speak_fn, | |
| inputs=[speak_input, exceed_flag], | |
| outputs=[audio_output, character_area, exceed_flag, speak_button], | |
| ) | |
| speak_button.click(submit_lock_fn, show_progress=False).then( | |
| speak_fn, | |
| inputs=[speak_input, exceed_flag], | |
| outputs=[audio_output, character_area, exceed_flag, speak_button], | |
| ) | |
| if __name__ == "__main__": | |
| reload_javascript() | |
| demo.launch( | |
| allowed_paths=["./assets", "./javascript", "./css"], | |
| show_api=False, | |
| # inbrowser=True, | |
| ) | |