Skip to content

Commit c819dbe

Browse files
Remove reference metrics for squim tutorial (#4027)
Co-authored-by: Sam Anklesaria <[email protected]>
1 parent 89cf282 commit c819dbe

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

examples/tutorials/squim_tutorial.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@
7373
#
7474
# First import the modules and define the helper functions.
7575
#
76-
# We will need torch, torchaudio to use Torchaudio-squim, Matplotlib to
77-
# plot data, pystoi, pesq for computing reference metrics.
76+
# We will need torch and torchaudio to use Torchaudio-squim and Matplotlib to
77+
# plot data.
7878
#
7979

8080
try:
81-
from pesq import pesq
82-
from pystoi import stoi
8381
from torchaudio.pipelines import SQUIM_OBJECTIVE, SQUIM_SUBJECTIVE
8482
except ImportError:
8583
try:
@@ -92,8 +90,6 @@
9290
of the notebook before running it:
9391
!pip3 uninstall -y torch torchvision torchaudio
9492
!pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
95-
!pip3 install pesq
96-
!pip3 install pystoi
9793
"""
9894
)
9995
except Exception:
@@ -280,12 +276,17 @@ def plot(waveform, title, sample_rate=16000):
280276
print(f"PESQ: {pesq_hyp[0]}")
281277
print(f"SI-SDR: {si_sdr_hyp[0]}\n")
282278

283-
pesq_ref = pesq(16000, WAVEFORM_SPEECH[0].numpy(), WAVEFORM_DISTORTED[0].numpy(), mode="wb")
284-
stoi_ref = stoi(WAVEFORM_SPEECH[0].numpy(), WAVEFORM_DISTORTED[0].numpy(), 16000, extended=False)
285-
si_sdr_ref = si_snr(WAVEFORM_DISTORTED[0:1], WAVEFORM_SPEECH)
279+
# To calculate the STOI and PESQ reference metrics,
280+
# we would need to install the pystoi and pesq packages and execute the following:
281+
# ```python
282+
# pesq_ref = pesq(16000, WAVEFORM_SPEECH[0].numpy(), WAVEFORM_DISTORTED[0].numpy(), mode="wb")
283+
# stoi_ref = stoi(WAVEFORM_SPEECH[0].numpy(), WAVEFORM_DISTORTED[0].numpy(), 16000, extended=False)
284+
# ```
285+
# These values are precomputed and hard-coded below.
286286
print(f"Reference metrics for distorted speech at {snr_dbs[0]}dB are\n")
287-
print(f"STOI: {stoi_ref}")
288-
print(f"PESQ: {pesq_ref}")
287+
print(f"STOI: 0.9670831113894452")
288+
print(f"PESQ: 2.7961528301239014")
289+
si_sdr_ref = si_snr(WAVEFORM_DISTORTED[0:1], WAVEFORM_SPEECH)
289290
print(f"SI-SDR: {si_sdr_ref}")
290291

291292

@@ -300,12 +301,11 @@ def plot(waveform, title, sample_rate=16000):
300301
print(f"PESQ: {pesq_hyp[0]}")
301302
print(f"SI-SDR: {si_sdr_hyp[0]}\n")
302303

303-
pesq_ref = pesq(16000, WAVEFORM_SPEECH[0].numpy(), WAVEFORM_DISTORTED[1].numpy(), mode="wb")
304-
stoi_ref = stoi(WAVEFORM_SPEECH[0].numpy(), WAVEFORM_DISTORTED[1].numpy(), 16000, extended=False)
305304
si_sdr_ref = si_snr(WAVEFORM_DISTORTED[1:2], WAVEFORM_SPEECH)
305+
# STOI and PESQ metrics are precomputed and hardcoded below.
306306
print(f"Reference metrics for distorted speech at {snr_dbs[1]}dB are\n")
307-
print(f"STOI: {stoi_ref}")
308-
print(f"PESQ: {pesq_ref}")
307+
print(f"STOI: 0.5743247866630554")
308+
print(f"PESQ: 1.1112866401672363")
309309
print(f"SI-SDR: {si_sdr_ref}")
310310

311311

0 commit comments

Comments
 (0)