Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,11 +9,11 @@ BATCH_SIZE = 1
|
|
| 9 |
|
| 10 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 11 |
|
|
|
|
| 12 |
mySpeechScore = SpeechScore([
|
| 13 |
'PESQ','DNSMOS'
|
| 14 |
])
|
| 15 |
-
|
| 16 |
-
|
| 17 |
# Copied from https://github.com/openai/whisper/blob/c09a7ae299c4c34c5839a76380ae407e7d785914/whisper/utils.py#L50
|
| 18 |
def format_timestamp(seconds: float, always_include_hours: bool = False, decimal_marker: str = "."):
|
| 19 |
if seconds is not None:
|
|
@@ -36,7 +36,13 @@ def format_timestamp(seconds: float, always_include_hours: bool = False, decimal
|
|
| 36 |
|
| 37 |
|
| 38 |
def score(test_file, ref_file, dnsmos, pesq, return_timestamps):
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return scores
|
| 41 |
|
| 42 |
|
|
|
|
| 9 |
|
| 10 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 11 |
|
| 12 |
+
"""
|
| 13 |
mySpeechScore = SpeechScore([
|
| 14 |
'PESQ','DNSMOS'
|
| 15 |
])
|
| 16 |
+
"""
|
|
|
|
| 17 |
# Copied from https://github.com/openai/whisper/blob/c09a7ae299c4c34c5839a76380ae407e7d785914/whisper/utils.py#L50
|
| 18 |
def format_timestamp(seconds: float, always_include_hours: bool = False, decimal_marker: str = "."):
|
| 19 |
if seconds is not None:
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
def score(test_file, ref_file, dnsmos, pesq, return_timestamps):
|
| 39 |
+
score_list=[]
|
| 40 |
+
if dnsmos:
|
| 41 |
+
score_list+=['DNSMOS']
|
| 42 |
+
if pesq:
|
| 43 |
+
score_list+=['PESQ']
|
| 44 |
+
mySpeechScore = SpeechScore(score_list)
|
| 45 |
+
scores = mySpeechScore(test_path=test_file, reference_path=ref_file, window=None, score_rate=16000, return_mean=False)
|
| 46 |
return scores
|
| 47 |
|
| 48 |
|