Skip to content

Commit e96ab78

Browse files
vincentqbcreduo
andauthored
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>
1 parent ded4e8d commit e96ab78

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

beginner_source/audio_preprocessing_tutorial.py

Lines changed: 13 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,7 +10,8 @@
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.
@@ -19,6 +20,7 @@
1920

2021
import torch
2122
import torchaudio
23+
import requests
2224
import matplotlib.pyplot as plt
2325

2426
######################################################################
@@ -29,7 +31,13 @@
2931
# call waveform the resulting raw audio signal.
3032
#
3133

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

3543
print("Shape of waveform: {}".format(waveform.size()))
@@ -207,7 +215,7 @@ def normalize(tensor):
207215
plt.plot(mu_law_encoding_waveform[0,:].numpy())
208216

209217
######################################################################
210-
# You can see how the output fron ``torchaudio.functional.mu_law_encoding`` is the same as
218+
# You can see how the output from ``torchaudio.functional.mu_law_encoding`` is the same as
211219
# the output from ``torchaudio.transforms.MuLawEncoding``.
212220
#
213221
# Now let's experiment with a few of the other functionals and visualize their output. Taking our

0 commit comments

Comments
 (0)