Spaces:
Runtime error
Runtime error
Update consult.py
Browse files- consult.py +15 -7
consult.py
CHANGED
@@ -97,10 +97,9 @@ def classify_continuous(audio):
|
|
97 |
return text_results, out_prob.squeeze(0).numpy(), text_lab[-1], Audio
|
98 |
|
99 |
|
100 |
-
|
101 |
#######################################################################
|
102 |
-
|
103 |
-
def
|
104 |
string=text_api(text)
|
105 |
part1 = str.partition(string, r"text")
|
106 |
want1 = part1[2]
|
@@ -112,10 +111,9 @@ def text_score4(text):
|
|
112 |
score=-prob*10
|
113 |
else:
|
114 |
score=prob*10
|
115 |
-
return text,score
|
116 |
|
117 |
-
|
118 |
-
def speech_score4(audio):
|
119 |
print(type(audio))
|
120 |
print(audio)
|
121 |
sample_rate, signal = audio # 这是语音的输入
|
@@ -156,7 +154,17 @@ def speech_score4(audio):
|
|
156 |
print(text,score1)
|
157 |
score=score1+score2
|
158 |
|
159 |
-
return text,score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
|
162 |
|
|
|
97 |
return text_results, out_prob.squeeze(0).numpy(), text_lab[-1], Audio
|
98 |
|
99 |
|
|
|
100 |
#######################################################################
|
101 |
+
#规范函数,只管值输入输出:
|
102 |
+
def text_score(text):
|
103 |
string=text_api(text)
|
104 |
part1 = str.partition(string, r"text")
|
105 |
want1 = part1[2]
|
|
|
111 |
score=-prob*10
|
112 |
else:
|
113 |
score=prob*10
|
114 |
+
return text,score
|
115 |
|
116 |
+
def speech_score(audio):
|
|
|
117 |
print(type(audio))
|
118 |
print(audio)
|
119 |
sample_rate, signal = audio # 这是语音的输入
|
|
|
154 |
print(text,score1)
|
155 |
score=score1+score2
|
156 |
|
157 |
+
return text,score
|
158 |
+
#######################################################################
|
159 |
+
#第四题专用函数:
|
160 |
+
def text_score4(text):
|
161 |
+
text,score=text_score(text)
|
162 |
+
return text,score,gr.Column(visible=True)
|
163 |
+
|
164 |
+
|
165 |
+
def speech_score4(audio):
|
166 |
+
text,score=speech_score(audio)
|
167 |
+
return text,score,gr.Column(visible=True)
|
168 |
|
169 |
|
170 |
|