Skip to content

Updating 1.7 branch #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
eventAction: 'click',
eventLabel: $(this).attr("data-response")
});
gtag('event', 'click', {
'event_category': $(this).attr("data-response"),
'event_label': $("h1").first().text(),
'tutorial_link': window.location.href
});
});

$("[data-behavior='was-this-helpful-event']").on('click', function(){
Expand Down
20 changes: 15 additions & 5 deletions beginner_source/audio_preprocessing_tutorial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
torchaudio Tutorial
===================
Audio I/O and Pre-Processing with torchaudio
============================================

PyTorch is an open source deep learning platform that provides a
seamless path from research prototyping to production deployment with
Expand All @@ -10,15 +10,19 @@
preparation. ``torchaudio`` leverages PyTorch’s GPU support, and provides
many tools to make data loading easy and more readable. In this
tutorial, we will see how to load and preprocess data from a simple
dataset.
dataset. Please visit
`Audio I/O and Pre-Processing with torchaudio <https://pytorch.org/tutorials/beginner/audio_preprocessing_tutorial.html>`__ to learn more.

For this tutorial, please make sure the ``matplotlib`` package is
installed for easier visualization.

"""

# Uncomment the following line to run in Google Colab
# !pip install torchaudio
import torch
import torchaudio
import requests
import matplotlib.pyplot as plt

######################################################################
Expand All @@ -29,7 +33,13 @@
# call waveform the resulting raw audio signal.
#

filename = "../_static/img/steam-train-whistle-daniel_simon-converted-from-mp3.wav"
url = "https://pytorch.org/tutorials/_static/img/steam-train-whistle-daniel_simon-converted-from-mp3.wav"
r = requests.get(url)

with open('steam-train-whistle-daniel_simon-converted-from-mp3.wav', 'wb') as f:
f.write(r.content)

filename = "steam-train-whistle-daniel_simon-converted-from-mp3.wav"
waveform, sample_rate = torchaudio.load(filename)

print("Shape of waveform: {}".format(waveform.size()))
Expand Down Expand Up @@ -207,7 +217,7 @@ def normalize(tensor):
plt.plot(mu_law_encoding_waveform[0,:].numpy())

######################################################################
# You can see how the output fron ``torchaudio.functional.mu_law_encoding`` is the same as
# You can see how the output from ``torchaudio.functional.mu_law_encoding`` is the same as
# the output from ``torchaudio.transforms.MuLawEncoding``.
#
# Now let's experiment with a few of the other functionals and visualize their output. Taking our
Expand Down