Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,6 +43,7 @@ gr.Audio.postprocess = audio_postprocess
|
|
43 |
|
44 |
limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
|
45 |
max_len = 150
|
|
|
46 |
languages = ['日本語', '简体中文', 'English']
|
47 |
characters = ['0:特别周', '1:无声铃鹿', '2:东海帝王', '3:丸善斯基',
|
48 |
'4:富士奇迹', '5:小栗帽', '6:黄金船', '7:伏特加',
|
@@ -97,19 +98,19 @@ def infer(text_raw, character, language, duration, noise_scale, noise_scale_w):
|
|
97 |
# check character & duraction parameter
|
98 |
if language not in languages:
|
99 |
print("Error: No such language\n")
|
100 |
-
return "Error: No such language",
|
101 |
if character not in characters:
|
102 |
print("Error: No such character\n")
|
103 |
-
return "Error: No such character",
|
104 |
# check text length
|
105 |
if limitation:
|
106 |
text_len = len(re.sub("\[([A-Z]{2})\]", "", text_raw))
|
107 |
if text_len > max_len:
|
108 |
print(f"Refused: Text too long ({text_len}).")
|
109 |
-
return "Error: Text is too long",
|
110 |
if text_len == 0:
|
111 |
print("Refused: Text length is zero.")
|
112 |
-
return "Error: Please input text!",
|
113 |
if language == '日本語':
|
114 |
text = text_raw
|
115 |
elif language == '简体中文':
|
|
|
43 |
|
44 |
limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
|
45 |
max_len = 150
|
46 |
+
empty_audio = np.zeros(22050)
|
47 |
languages = ['日本語', '简体中文', 'English']
|
48 |
characters = ['0:特别周', '1:无声铃鹿', '2:东海帝王', '3:丸善斯基',
|
49 |
'4:富士奇迹', '5:小栗帽', '6:黄金船', '7:伏特加',
|
|
|
98 |
# check character & duraction parameter
|
99 |
if language not in languages:
|
100 |
print("Error: No such language\n")
|
101 |
+
return "Error: No such language", (22050, empty_audio)
|
102 |
if character not in characters:
|
103 |
print("Error: No such character\n")
|
104 |
+
return "Error: No such character", (22050, empty_audio)
|
105 |
# check text length
|
106 |
if limitation:
|
107 |
text_len = len(re.sub("\[([A-Z]{2})\]", "", text_raw))
|
108 |
if text_len > max_len:
|
109 |
print(f"Refused: Text too long ({text_len}).")
|
110 |
+
return "Error: Text is too long", (22050, empty_audio)
|
111 |
if text_len == 0:
|
112 |
print("Refused: Text length is zero.")
|
113 |
+
return "Error: Please input text!", (22050, empty_audio)
|
114 |
if language == '日本語':
|
115 |
text = text_raw
|
116 |
elif language == '简体中文':
|