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
######################################################################
# Overview
# ========
# --------
#
# 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
######################################################################
# Preparation
# ===========
# -----------
#
# First, we import the necessary packages and retrieve the data.
#
......@@ -71,12 +71,12 @@ for filename in filenames:
######################################################################
# Generate the Ideal Ratio Mask (IRM)
# ===================================
# -----------------------------------
#
######################################################################
# Loading audio data
# ------------------
# ~~~~~~~~~~~~~~~~~~
#
mix, sr = torchaudio.load('_assets/mix.wav')
......@@ -100,7 +100,7 @@ reverb_clean = reverb_clean.to(torch.double)
######################################################################
# Compute STFT
# ------------
# ~~~~~~~~~~~~
#
stft = torchaudio.transforms.Spectrogram(
......@@ -117,7 +117,7 @@ spec_noise = stft(noise)
######################################################################
# Generate the Ideal Ratio Mask (IRM)
# -----------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# .. note::
# 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)
######################################################################
# Apply MVDR
# ==========
# ----------
#
######################################################################
# Apply MVDR beamforming by using multi-channel masks
# ---------------------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
results_multi = {}
......@@ -160,7 +160,7 @@ for solution in ['ref_channel', 'stv_evd', 'stv_power']:
######################################################################
# Apply MVDR beamforming by using single-channel masks
# ----------------------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# We use the 1st channel as an example.
# 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']:
######################################################################
# Compute Si-SDR scores
# ---------------------
# ~~~~~~~~~~~~~~~~~~~~~
#
def si_sdr(estimate, reference, epsilon=1e-8):
......@@ -198,12 +198,12 @@ def si_sdr(estimate, reference, epsilon=1e-8):
######################################################################
# Results
# =======
# -------
#
######################################################################
# Single-channel mask results
# ---------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
for solution in results_single:
......@@ -211,7 +211,7 @@ for solution in results_single:
######################################################################
# Multi-channel mask results
# --------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
#
for solution in results_multi:
......@@ -219,73 +219,73 @@ for solution in results_multi:
######################################################################
# Original audio
# ==============
# --------------
#
######################################################################
# Mixture speech
# --------------
# ~~~~~~~~~~~~~~
#
ipd.Audio(mix[0], rate=16000)
######################################################################
# Noise
# -----
# ~~~~~
#
ipd.Audio(noise[0], rate=16000)
######################################################################
# Clean speech
# ------------
# ~~~~~~~~~~~~
#
ipd.Audio(clean[0], rate=16000)
######################################################################
# Enhanced audio
# ==============
# --------------
#
######################################################################
# Multi-channel mask, ref_channel solution
# ----------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
ipd.Audio(results_multi['ref_channel'], rate=16000)
######################################################################
# Multi-channel mask, stv_evd solution
# ------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
ipd.Audio(results_multi['stv_evd'], rate=16000)
######################################################################
# Multi-channel mask, stv_power solution
# --------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
ipd.Audio(results_multi['stv_power'], rate=16000)
######################################################################
# Single-channel mask, ref_channel solution
# -----------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
ipd.Audio(results_single['ref_channel'], rate=16000)
######################################################################
# Single-channel mask, stv_evd solution
# -------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
ipd.Audio(results_single['stv_evd'], rate=16000)
######################################################################
# Single-channel mask, stv_power solution
# ---------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
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