alibabasglab commited on
Commit
6e44725
1 Parent(s): b66c175

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -37
app.py CHANGED
@@ -9,33 +9,8 @@ BATCH_SIZE = 1
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:
20
- milliseconds = round(seconds * 1000.0)
21
-
22
- hours = milliseconds // 3_600_000
23
- milliseconds -= hours * 3_600_000
24
-
25
- minutes = milliseconds // 60_000
26
- milliseconds -= minutes * 60_000
27
-
28
- seconds = milliseconds // 1_000
29
- milliseconds -= seconds * 1_000
30
-
31
- hours_marker = f"{hours:02d}:" if always_include_hours or hours > 0 else ""
32
- return f"{hours_marker}{minutes:02d}:{seconds:02d}{decimal_marker}{milliseconds:03d}"
33
- else:
34
- # we have a malformed timestamp so just return it as is
35
- return seconds
36
-
37
-
38
- def score(test_file, ref_file, score_list, return_timestamps):
39
  mySpeechScore = SpeechScore(score_list)
40
  scores = mySpeechScore(test_path=test_file, reference_path=ref_file, window=None, score_rate=16000, return_mean=False)
41
  return scores
@@ -48,25 +23,50 @@ file_score = gr.Interface(
48
  inputs=[
49
  gr.Audio(sources=["upload"], label="test file", type="filepath"),
50
  gr.Audio(sources=["upload"], label="reference file", type="filepath"),
51
- #gr.Radio(["without reference", "with reference"], label="Task", info="choose non-instrusive or instrusive scoring"),
52
- #gr.Checkbox(default=False, label="DNSMOS"),
53
- #gr.Checkbox(default=False, label="PESQ"),
54
  gr.Dropdown(
55
- ["DNSMOS", "PESQ", "NB-PESQ", "SISNR"], value=["DNSMOS", "PESQ"], multiselect=True, label="Scores", info="By checking the following scores, include them in the output."
 
 
 
 
 
 
56
  ),
57
  ],
58
  outputs="text",
59
- #layout="horizontal",
60
- #theme="huggingface",
61
- title="Score speech from a file",
62
  description=(
63
- "Score audio inputs with the click of a button! Demo uses the"
64
- " commonly used speech quality assessment methods for the audio files"
65
  " of arbitrary length."
66
  ),
67
  )
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  with demo:
70
- gr.TabbedInterface([file_score], ["Score Audio File"])
71
 
72
  demo.launch()
 
9
 
10
  device = 0 if torch.cuda.is_available() else "cpu"
11
 
12
+ def score(test_file, ref_file, score_list_nis, score_list_is, return_timestamps):
13
+ score_list = score_list_nis + score_list_is
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  mySpeechScore = SpeechScore(score_list)
15
  scores = mySpeechScore(test_path=test_file, reference_path=ref_file, window=None, score_rate=16000, return_mean=False)
16
  return scores
 
23
  inputs=[
24
  gr.Audio(sources=["upload"], label="test file", type="filepath"),
25
  gr.Audio(sources=["upload"], label="reference file", type="filepath"),
 
 
 
26
  gr.Dropdown(
27
+ ["DNSMOS", "SRMR"], value=["DNSMOS", "SRMR"], multiselect=True, label="Non-Intrusive Scores", info="Choose scores to include, no reference audio is required."
28
+ ),
29
+ gr.Dropdown(
30
+ ["PESQ", 'NB_PESQ', 'STOI', 'SISDR',
31
+ 'FWSEGSNR', 'LSD', 'BSSEval', 'DNSMOS',
32
+ 'SNR', 'SSNR', 'LLR', 'CSIG', 'CBAK',
33
+ 'COVL', 'MCD'], value=["PESQ", "STOI"], multiselect=True, label="Intrusive Scores", info="Choose scores to include, reference audio is required."
34
  ),
35
  ],
36
  outputs="text",
37
+ title="Score speech quality for an audio clip",
 
 
38
  description=(
39
+ "Score speech quality with the click of a button! Demo includes the"
40
+ " commonly used speech quality assessments for the audio file"
41
  " of arbitrary length."
42
  ),
43
  )
44
 
45
+ mic_score = gr.Interface(
46
+ fn=score,
47
+ inputs=[
48
+ gr.Audio(sources=["microphone"],
49
+ waveform_options=gr.WaveformOptions(
50
+ waveform_color="#01C6FF",
51
+ waveform_progress_color="#0066B4",
52
+ skip_length=2,
53
+ show_controls=False,
54
+ ),
55
+ ),
56
+ gr.Dropdown(
57
+ ["DNSMOS", "SRMR"], value=["DNSMOS", "SRMR"], multiselect=True, label="Non-Intrusive Scores", info="Choose scores to include, no reference audio is required."
58
+ ),
59
+ ],
60
+ outputs="text",
61
+ title="Test microphone quality using speech score",
62
+ description=(
63
+ "Score your microphone quality with the click of a button!"
64
+ " Uses the most popular method to test your microphone quality"
65
+ " with a short speech clip."
66
+ ),
67
+ )
68
+
69
  with demo:
70
+ gr.TabbedInterface([mic_score, file_score], ["Score Microphone Quality", "Score Speech Quality"])
71
 
72
  demo.launch()