MZhaovo's picture
Upload folder using huggingface_hub
f9e0ede
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,
)