Spaces:
Running
Running
Update speechscore.py
Browse files- speechscore.py +24 -22
speechscore.py
CHANGED
@@ -57,31 +57,33 @@ class ScoresList:
|
|
57 |
print(f'Please provide audio path for test_path')
|
58 |
return
|
59 |
results = {}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
for audio_id in audio_list:
|
65 |
-
results_id = {}
|
66 |
-
if reference_path is not None:
|
67 |
-
data = self.audio_reader(test_path+'/'+audio_id, reference_path+'/'+audio_id)
|
68 |
-
else:
|
69 |
-
data = self.audio_reader(test_path+'/'+audio_id, None)
|
70 |
-
for score in self.scores:
|
71 |
-
result_score = score.scoring(data, window, score_rate)
|
72 |
-
results_id[score.name] = result_score
|
73 |
-
results[audio_id] = results_id
|
74 |
-
|
75 |
-
elif os.path.isfile(test_path):
|
76 |
-
data = self.audio_reader(test_path, reference_path)
|
77 |
-
for score in self.scores:
|
78 |
-
result_score = score.scoring(data, window, score_rate)
|
79 |
-
results[score.name] = result_score
|
80 |
-
else:
|
81 |
-
data = test_path
|
82 |
for score in self.scores:
|
83 |
result_score = score.scoring(data, window, score_rate)
|
84 |
results[score.name] = result_score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
if return_mean:
|
87 |
mean_result = compute_mean_results(*results.values())
|
|
|
57 |
print(f'Please provide audio path for test_path')
|
58 |
return
|
59 |
results = {}
|
60 |
+
if isinstance(test_path, tuple):
|
61 |
+
sr, data = test_path
|
62 |
+
if sr != 16000:
|
63 |
+
data = resampy.resample(data, sr, 16000, axis=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
for score in self.scores:
|
65 |
result_score = score.scoring(data, window, score_rate)
|
66 |
results[score.name] = result_score
|
67 |
+
else:
|
68 |
+
if os.path.isdir(test_path):
|
69 |
+
audio_list = self.get_audio_list(test_path)
|
70 |
+
if audio_list is None: return
|
71 |
+
for audio_id in audio_list:
|
72 |
+
results_id = {}
|
73 |
+
if reference_path is not None:
|
74 |
+
data = self.audio_reader(test_path+'/'+audio_id, reference_path+'/'+audio_id)
|
75 |
+
else:
|
76 |
+
data = self.audio_reader(test_path+'/'+audio_id, None)
|
77 |
+
for score in self.scores:
|
78 |
+
result_score = score.scoring(data, window, score_rate)
|
79 |
+
results_id[score.name] = result_score
|
80 |
+
results[audio_id] = results_id
|
81 |
+
|
82 |
+
elif os.path.isfile(test_path):
|
83 |
+
data = self.audio_reader(test_path, reference_path)
|
84 |
+
for score in self.scores:
|
85 |
+
result_score = score.scoring(data, window, score_rate)
|
86 |
+
results[score.name] = result_score
|
87 |
|
88 |
if return_mean:
|
89 |
mean_result = compute_mean_results(*results.values())
|