Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,12 @@ pth_path = config.pth_path
|
|
21 |
config_json = config.config_json
|
22 |
net_g_ms, hps = infer.load_model(config_json, pth_path)
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
# ChatGPT
|
25 |
def chat_hf(audio, custom_token, language):
|
26 |
try:
|
@@ -35,6 +41,7 @@ def chat_hf(audio, custom_token, language):
|
|
35 |
gpt_response = """Sorry, I'm quite busy right now, but please try again later :)"""
|
36 |
|
37 |
# to voice
|
|
|
38 |
if language == 'cn' or 'jp':
|
39 |
text = infer.clean_text(gpt_response)
|
40 |
audio = infer.infer(text, net_g_ms, 2, "demo")
|
|
|
21 |
config_json = config.config_json
|
22 |
net_g_ms, hps = infer.load_model(config_json, pth_path)
|
23 |
|
24 |
+
def trim(s):
|
25 |
+
import re
|
26 |
+
if s.startswith(' ') or s.endswith(' '):
|
27 |
+
return re.sub(r"^(\s+)|(\s+)$", "", s)
|
28 |
+
return s
|
29 |
+
|
30 |
# ChatGPT
|
31 |
def chat_hf(audio, custom_token, language):
|
32 |
try:
|
|
|
41 |
gpt_response = """Sorry, I'm quite busy right now, but please try again later :)"""
|
42 |
|
43 |
# to voice
|
44 |
+
gpt_response = trim(gpt_response)
|
45 |
if language == 'cn' or 'jp':
|
46 |
text = infer.clean_text(gpt_response)
|
47 |
audio = infer.infer(text, net_g_ms, 2, "demo")
|