Unverified Commit 209145a4 authored by moto's avatar moto Committed by GitHub
Browse files

Fix sections of MVDR tutorial (#1989)

parent b9247022
...@@ -8,7 +8,7 @@ MVDR with torchaudio ...@@ -8,7 +8,7 @@ MVDR with torchaudio
###################################################################### ######################################################################
# Overview # Overview
# ======== # --------
# #
# This is a tutorial on how to apply MVDR beamforming by using `torchaudio <https://github.com/pytorch/audio>`__. # This is a tutorial on how to apply MVDR beamforming by using `torchaudio <https://github.com/pytorch/audio>`__.
# #
...@@ -25,7 +25,7 @@ MVDR with torchaudio ...@@ -25,7 +25,7 @@ MVDR with torchaudio
###################################################################### ######################################################################
# Preparation # Preparation
# =========== # -----------
# #
# First, we import the necessary packages and retrieve the data. # First, we import the necessary packages and retrieve the data.
# #
...@@ -71,12 +71,12 @@ for filename in filenames: ...@@ -71,12 +71,12 @@ for filename in filenames:
###################################################################### ######################################################################
# Generate the Ideal Ratio Mask (IRM) # Generate the Ideal Ratio Mask (IRM)
# =================================== # -----------------------------------
# #
###################################################################### ######################################################################
# Loading audio data # Loading audio data
# ------------------ # ~~~~~~~~~~~~~~~~~~
# #
mix, sr = torchaudio.load('_assets/mix.wav') mix, sr = torchaudio.load('_assets/mix.wav')
...@@ -100,7 +100,7 @@ reverb_clean = reverb_clean.to(torch.double) ...@@ -100,7 +100,7 @@ reverb_clean = reverb_clean.to(torch.double)
###################################################################### ######################################################################
# Compute STFT # Compute STFT
# ------------ # ~~~~~~~~~~~~
# #
stft = torchaudio.transforms.Spectrogram( stft = torchaudio.transforms.Spectrogram(
...@@ -117,7 +117,7 @@ spec_noise = stft(noise) ...@@ -117,7 +117,7 @@ spec_noise = stft(noise)
###################################################################### ######################################################################
# Generate the Ideal Ratio Mask (IRM) # Generate the Ideal Ratio Mask (IRM)
# ----------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
# .. note:: # .. note::
# We found using the mask directly peforms better than using the # We found using the mask directly peforms better than using the
...@@ -143,12 +143,12 @@ irm_speech, irm_noise = get_irms(spec_reverb_clean, spec_noise, spec_mix) ...@@ -143,12 +143,12 @@ irm_speech, irm_noise = get_irms(spec_reverb_clean, spec_noise, spec_mix)
###################################################################### ######################################################################
# Apply MVDR # Apply MVDR
# ========== # ----------
# #
###################################################################### ######################################################################
# Apply MVDR beamforming by using multi-channel masks # Apply MVDR beamforming by using multi-channel masks
# --------------------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
results_multi = {} results_multi = {}
...@@ -160,7 +160,7 @@ for solution in ['ref_channel', 'stv_evd', 'stv_power']: ...@@ -160,7 +160,7 @@ for solution in ['ref_channel', 'stv_evd', 'stv_power']:
###################################################################### ######################################################################
# Apply MVDR beamforming by using single-channel masks # Apply MVDR beamforming by using single-channel masks
# ---------------------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
# We use the 1st channel as an example. # We use the 1st channel as an example.
# The channel selection may depend on the design of the microphone array # The channel selection may depend on the design of the microphone array
...@@ -174,7 +174,7 @@ for solution in ['ref_channel', 'stv_evd', 'stv_power']: ...@@ -174,7 +174,7 @@ for solution in ['ref_channel', 'stv_evd', 'stv_power']:
###################################################################### ######################################################################
# Compute Si-SDR scores # Compute Si-SDR scores
# --------------------- # ~~~~~~~~~~~~~~~~~~~~~
# #
def si_sdr(estimate, reference, epsilon=1e-8): def si_sdr(estimate, reference, epsilon=1e-8):
...@@ -198,12 +198,12 @@ def si_sdr(estimate, reference, epsilon=1e-8): ...@@ -198,12 +198,12 @@ def si_sdr(estimate, reference, epsilon=1e-8):
###################################################################### ######################################################################
# Results # Results
# ======= # -------
# #
###################################################################### ######################################################################
# Single-channel mask results # Single-channel mask results
# --------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
for solution in results_single: for solution in results_single:
...@@ -211,7 +211,7 @@ for solution in results_single: ...@@ -211,7 +211,7 @@ for solution in results_single:
###################################################################### ######################################################################
# Multi-channel mask results # Multi-channel mask results
# -------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
for solution in results_multi: for solution in results_multi:
...@@ -219,73 +219,73 @@ for solution in results_multi: ...@@ -219,73 +219,73 @@ for solution in results_multi:
###################################################################### ######################################################################
# Original audio # Original audio
# ============== # --------------
# #
###################################################################### ######################################################################
# Mixture speech # Mixture speech
# -------------- # ~~~~~~~~~~~~~~
# #
ipd.Audio(mix[0], rate=16000) ipd.Audio(mix[0], rate=16000)
###################################################################### ######################################################################
# Noise # Noise
# ----- # ~~~~~
# #
ipd.Audio(noise[0], rate=16000) ipd.Audio(noise[0], rate=16000)
###################################################################### ######################################################################
# Clean speech # Clean speech
# ------------ # ~~~~~~~~~~~~
# #
ipd.Audio(clean[0], rate=16000) ipd.Audio(clean[0], rate=16000)
###################################################################### ######################################################################
# Enhanced audio # Enhanced audio
# ============== # --------------
# #
###################################################################### ######################################################################
# Multi-channel mask, ref_channel solution # Multi-channel mask, ref_channel solution
# ---------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
ipd.Audio(results_multi['ref_channel'], rate=16000) ipd.Audio(results_multi['ref_channel'], rate=16000)
###################################################################### ######################################################################
# Multi-channel mask, stv_evd solution # Multi-channel mask, stv_evd solution
# ------------------------------------ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
ipd.Audio(results_multi['stv_evd'], rate=16000) ipd.Audio(results_multi['stv_evd'], rate=16000)
###################################################################### ######################################################################
# Multi-channel mask, stv_power solution # Multi-channel mask, stv_power solution
# -------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
ipd.Audio(results_multi['stv_power'], rate=16000) ipd.Audio(results_multi['stv_power'], rate=16000)
###################################################################### ######################################################################
# Single-channel mask, ref_channel solution # Single-channel mask, ref_channel solution
# ----------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
ipd.Audio(results_single['ref_channel'], rate=16000) ipd.Audio(results_single['ref_channel'], rate=16000)
###################################################################### ######################################################################
# Single-channel mask, stv_evd solution # Single-channel mask, stv_evd solution
# ------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
ipd.Audio(results_single['stv_evd'], rate=16000) ipd.Audio(results_single['stv_evd'], rate=16000)
###################################################################### ######################################################################
# Single-channel mask, stv_power solution # Single-channel mask, stv_power solution
# --------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
ipd.Audio(results_single['stv_power'], rate=16000) ipd.Audio(results_single['stv_power'], rate=16000)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment