Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- app.py +13 -17
- assets/lines.json +38 -0
- gradio_cached_examples/7/log.csv +4 -0
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import random
|
2 |
import nltk
|
3 |
import ssl
|
4 |
|
@@ -10,18 +9,17 @@ else:
|
|
10 |
ssl._create_default_https_context = _create_unverified_https_context
|
11 |
nltk.download("cmudict")
|
12 |
|
|
|
|
|
|
|
13 |
import gradio as gr
|
14 |
import numpy as np
|
15 |
import torch
|
16 |
-
import os
|
17 |
import re_matching
|
18 |
-
from tools.sentence import split_by_language, sentence_split
|
19 |
import utils
|
20 |
from infer import infer, latest_version, get_net_g
|
21 |
import gradio as gr
|
22 |
-
import webbrowser
|
23 |
from config import config
|
24 |
-
from tools.translate import translate
|
25 |
from tools.webui import reload_javascript, get_character_html
|
26 |
|
27 |
device = config.webui_config.device
|
@@ -112,30 +110,28 @@ def init_fn():
|
|
112 |
gr.Info("Only support Chinese now. Trying to train a mutilingual model. 欢迎在 Community 中提建议~")
|
113 |
|
114 |
index = random.randint(1,7)
|
115 |
-
|
116 |
-
1: "哇!你来找我玩啦!",
|
117 |
-
2: "你好呀!",
|
118 |
-
3: "哇!你来啦~",
|
119 |
-
4: "真高兴见到你!",
|
120 |
-
5: "我一朵花好无聊啊!",
|
121 |
-
6: "欢迎你!",
|
122 |
-
7: "来找我玩啦!",
|
123 |
-
}
|
124 |
|
125 |
-
return gr.update(value=f"./assets/audios/Welcome{index}.wav"), get_character_html(
|
126 |
|
|
|
|
|
|
|
|
|
127 |
|
128 |
with open("./css/style.css", "r", encoding="utf-8") as f:
|
129 |
customCSS = f.read()
|
|
|
|
|
130 |
|
131 |
with gr.Blocks(css=customCSS) as demo:
|
132 |
exceed_flag = gr.State(value=False)
|
133 |
-
|
134 |
character_area = gr.HTML(get_character_html("你好呀!"), elem_id="character_area")
|
135 |
with gr.Tab("Speak", elem_id="tab-speak"):
|
136 |
speak_input = gr.Textbox(lines=1, label="Talking Flower will say:", elem_classes="wonder-card", elem_id="input_text")
|
137 |
speak_button = gr.Button("Speak!", elem_id="speak_button", elem_classes="main-button wonder-card")
|
138 |
-
gr.Examples(["
|
139 |
with gr.Tab("Chat", elem_id="tab-chat"):
|
140 |
chat_input = gr.Textbox(lines=1, placeholder="Coming Soon...", label="Chat to Talking Flower:", elem_classes="wonder-card", elem_id="input_text", interactive=False)
|
141 |
chat_button = gr.Button("Chat!", elem_id="chat_button", elem_classes="main-button wonder-card")
|
|
|
|
|
1 |
import nltk
|
2 |
import ssl
|
3 |
|
|
|
9 |
ssl._create_default_https_context = _create_unverified_https_context
|
10 |
nltk.download("cmudict")
|
11 |
|
12 |
+
import os
|
13 |
+
import json
|
14 |
+
import random
|
15 |
import gradio as gr
|
16 |
import numpy as np
|
17 |
import torch
|
|
|
18 |
import re_matching
|
|
|
19 |
import utils
|
20 |
from infer import infer, latest_version, get_net_g
|
21 |
import gradio as gr
|
|
|
22 |
from config import config
|
|
|
23 |
from tools.webui import reload_javascript, get_character_html
|
24 |
|
25 |
device = config.webui_config.device
|
|
|
110 |
gr.Info("Only support Chinese now. Trying to train a mutilingual model. 欢迎在 Community 中提建议~")
|
111 |
|
112 |
index = random.randint(1,7)
|
113 |
+
welcome_text = get_sentence("Welcome", index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
+
return gr.update(value=f"./assets/audios/Welcome{index}.wav"), get_character_html(welcome_text)
|
116 |
|
117 |
+
def get_sentence(category, index=-1):
|
118 |
+
if index == -1:
|
119 |
+
index = random.randint(1, len(full_lines[category]))
|
120 |
+
return full_lines[category][f"{index}"]
|
121 |
|
122 |
with open("./css/style.css", "r", encoding="utf-8") as f:
|
123 |
customCSS = f.read()
|
124 |
+
with open("./assets/lines.json", "r", encoding="utf-8") as f:
|
125 |
+
full_lines = json.load(f)
|
126 |
|
127 |
with gr.Blocks(css=customCSS) as demo:
|
128 |
exceed_flag = gr.State(value=False)
|
129 |
+
tmp_string = gr.Textbox(value="", visible=False)
|
130 |
character_area = gr.HTML(get_character_html("你好呀!"), elem_id="character_area")
|
131 |
with gr.Tab("Speak", elem_id="tab-speak"):
|
132 |
speak_input = gr.Textbox(lines=1, label="Talking Flower will say:", elem_classes="wonder-card", elem_id="input_text")
|
133 |
speak_button = gr.Button("Speak!", elem_id="speak_button", elem_classes="main-button wonder-card")
|
134 |
+
example_category = gr.Examples(["夸夸你 | Praise", "游戏台词 | Scripts", "玩梗 | Meme"], fn=get_sentence, inputs=[tmp_string], outputs=[speak_input], run_on_click=True, elem_id="examples")
|
135 |
with gr.Tab("Chat", elem_id="tab-chat"):
|
136 |
chat_input = gr.Textbox(lines=1, placeholder="Coming Soon...", label="Chat to Talking Flower:", elem_classes="wonder-card", elem_id="input_text", interactive=False)
|
137 |
chat_button = gr.Button("Chat!", elem_id="chat_button", elem_classes="main-button wonder-card")
|
assets/lines.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"Welcome": {
|
3 |
+
"1": "哇!你来找我玩啦!",
|
4 |
+
"2": "你好呀!",
|
5 |
+
"3": "哇!你来啦~",
|
6 |
+
"4": "真高兴见到你!",
|
7 |
+
"5": "我一朵花好无聊啊!",
|
8 |
+
"6": "欢迎你!",
|
9 |
+
"7": "来找我玩啦!"
|
10 |
+
},
|
11 |
+
"夸夸你 | Praise": {
|
12 |
+
"1": "你今天好棒!",
|
13 |
+
"2": "冲呀冲呀!",
|
14 |
+
"3": "我好喜欢你呀!",
|
15 |
+
"4": "嫁给我好吗!",
|
16 |
+
"5": "你今天已经很优秀了呢!",
|
17 |
+
"6": "祝你做个好梦!",
|
18 |
+
"7": "你真的好厉害啊!"
|
19 |
+
},
|
20 |
+
"游戏台词 | Scripts": {
|
21 |
+
"1": "雄蕊羊痒的~",
|
22 |
+
"2": "我一朵花好害怕",
|
23 |
+
"3": "冲呀冲呀!",
|
24 |
+
"4": "欸??我很吵吗?",
|
25 |
+
"5": "舔一口!",
|
26 |
+
"6": "所以我就说了嘛!!!",
|
27 |
+
"7": "我觉得你别管我,快点走比较好哦!"
|
28 |
+
},
|
29 |
+
"玩梗 | Meme": {
|
30 |
+
"1": "塔塔开!一字摸塔塔开!",
|
31 |
+
"2": "好了是闺蜜,不好嘞是敌咪",
|
32 |
+
"3": "读书的拟人最美丽!",
|
33 |
+
"4": "形成两面包夹芝士!",
|
34 |
+
"5": "反正他都不难受!他只要自由!",
|
35 |
+
"6": "嗯?哪里出现了什么问题?",
|
36 |
+
"7": "原氨神!启动!"
|
37 |
+
}
|
38 |
+
}
|
gradio_cached_examples/7/log.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Talking Flower will say:,flag,username,timestamp
|
2 |
+
冲呀冲呀!,,,2023-11-25 16:24:34.033852
|
3 |
+
我一朵花好害怕,,,2023-11-25 16:24:34.059410
|
4 |
+
好了是闺蜜,不好嘞是敌咪,,,2023-11-25 16:24:34.079006
|