Spaces:
Runtime error
Runtime error
File size: 2,842 Bytes
7c2c5f5 425b9a7 ddb4de0 8f472c2 1379699 f9e0ede 84fef35 657d73c 007b414 657d73c 007b414 ac25389 007b414 ac25389 007b414 ac25389 007b414 f2c4c94 ddb4de0 fa8b4be 63bb040 fa8b4be 5df1b32 fa8b4be 657d73c 5df1b32 fa8b4be 657d73c 5df1b32 ddb4de0 2b28532 ac25389 ddb4de0 7c2c5f5 ddb4de0 |
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 46 47 48 49 50 51 52 53 |
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)
gr.HTML("""
<script type="module" src="file=javascript/animation.js"></script>
""")
character_area = gr.HTML(get_character_html("你好呀!我现在支持多语言了呢!"), elem_id="character_area")
with gr.Row(elem_id="tools_area"):
api_key_input = gr.Textbox(lines=1, max_lines=1, label="API Key:", placeholder="Comming Soon...", elem_classes="wonder-card", elem_id="api_key_input")
voice_list = gr.Dropdown(choices=["Chinese", "English", "Japanese"], value="Chinese", label="Choose voice:", elem_id="voice_list", elem_classes="wonder-card")
with gr.Tab("Speak", elem_id="tab-speak"):
speak_input = gr.Textbox(lines=1, max_lines=4, label="Talking Flower will say:", placeholder="Support Chinese, English and Japanese...", 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=True, 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, voice_list],
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, voice_list],
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,
)
|