Skip to content

Commit 6174a44

Browse files
brianjopatmellonvincentqbcreduo
authored
Updating 1.7 branch (#1205)
* Update event tracking (#1188) * Update beginner_source/audio_preprocessing_tutorial.py (#1199) * Typo in beginner_source/audio_preprocessing_tutorial.py Typo in beginner_source/audio_preprocessing_tutorial.py fron > from * update title. * fix file access. Co-authored-by: JuHyuk Park <creduo@gmail.com> * Update audio_preprocessing_tutorial.py (#1202) Adds a comment for running this tutorial in Google Colab. Co-authored-by: Pat Mellon <16585245+patmellon@users.noreply.github.com> Co-authored-by: Vincent QB <vincentqb@users.noreply.github.com> Co-authored-by: JuHyuk Park <creduo@gmail.com>
1 parent ae06375 commit 6174a44

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

_templates/layout.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
eventAction: 'click',
5252
eventLabel: $(this).attr("data-response")
5353
});
54+
gtag('event', 'click', {
55+
'event_category': $(this).attr("data-response"),
56+
'event_label': $("h1").first().text(),
57+
'tutorial_link': window.location.href
58+
});
5459
});
5560

5661
$("[data-behavior='was-this-helpful-event']").on('click', function(){

beginner_source/audio_preprocessing_tutorial.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
torchaudio Tutorial
3-
===================
2+
Audio I/O and Pre-Processing with torchaudio
3+
============================================
44
55
PyTorch is an open source deep learning platform that provides a
66
seamless path from research prototyping to production deployment with
@@ -10,15 +10,19 @@
1010
preparation. ``torchaudio`` leverages PyTorch’s GPU support, and provides
1111
many tools to make data loading easy and more readable. In this
1212
tutorial, we will see how to load and preprocess data from a simple
13-
dataset.
13+
dataset. Please visit
14+
`Audio I/O and Pre-Processing with torchaudio <https://pytorch.org/tutorials/beginner/audio_preprocessing_tutorial.html>`__ to learn more.
1415
1516
For this tutorial, please make sure the ``matplotlib`` package is
1617
installed for easier visualization.
1718
1819
"""
1920

21+
# Uncomment the following line to run in Google Colab
22+
# !pip install torchaudio
2023
import torch
2124
import torchaudio
25+
import requests
2226
import matplotlib.pyplot as plt
2327

2428
######################################################################
@@ -29,7 +33,13 @@
2933
# call waveform the resulting raw audio signal.
3034
#
3135

32-
filename = "../_static/img/steam-train-whistle-daniel_simon-converted-from-mp3.wav"
36+
url = "https://pytorch.org/tutorials/_static/img/steam-train-whistle-daniel_simon-converted-from-mp3.wav"
37+
r = requests.get(url)
38+
39+
with open('steam-train-whistle-daniel_simon-converted-from-mp3.wav', 'wb') as f:
40+
f.write(r.content)
41+
42+
filename = "steam-train-whistle-daniel_simon-converted-from-mp3.wav"
3343
waveform, sample_rate = torchaudio.load(filename)
3444

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

209219
######################################################################
210-
# You can see how the output fron ``torchaudio.functional.mu_law_encoding`` is the same as
220+
# You can see how the output from ``torchaudio.functional.mu_law_encoding`` is the same as
211221
# the output from ``torchaudio.transforms.MuLawEncoding``.
212222
#
213223
# Now let's experiment with a few of the other functionals and visualize their output. Taking our

0 commit comments

Comments
 (0)