Spaces:
Runtime error
Runtime error
Update speech.py
Browse files
speech.py
CHANGED
@@ -59,17 +59,21 @@ def text_score(text):
|
|
59 |
else:
|
60 |
string=text_api(text)
|
61 |
print(string)
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
part2 = str.partition(string, r"probability")
|
66 |
-
want2 = part2[2]
|
67 |
-
prob = float(want2[3:-4])
|
68 |
-
if label=="正向":
|
69 |
-
score=-np.log10(prob*10)
|
70 |
else:
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
return text,score
|
74 |
|
75 |
def speech_score(audio):
|
|
|
59 |
else:
|
60 |
string=text_api(text)
|
61 |
print(string)
|
62 |
+
if string=="[{}]":
|
63 |
+
text="空"
|
64 |
+
score=0
|
|
|
|
|
|
|
|
|
|
|
65 |
else:
|
66 |
+
part1 = str.partition(string, r"text")
|
67 |
+
want1 = part1[2]
|
68 |
+
label = want1[4:6]
|
69 |
+
part2 = str.partition(string, r"probability")
|
70 |
+
want2 = part2[2]
|
71 |
+
prob = float(want2[3:-4])
|
72 |
+
if label=="正向":
|
73 |
+
score=-np.log10(prob*10)
|
74 |
+
else:
|
75 |
+
score=np.log10(prob*10)
|
76 |
+
# print("from func:text_score————,text:",text,",score:",score)
|
77 |
return text,score
|
78 |
|
79 |
def speech_score(audio):
|