diff --git a/beginner_source/audio_preprocessing_tutorial.py b/beginner_source/audio_preprocessing_tutorial.py index 01c5a4a748a..309ba9d3db2 100644 --- a/beginner_source/audio_preprocessing_tutorial.py +++ b/beginner_source/audio_preprocessing_tutorial.py @@ -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 @@ -10,7 +10,8 @@ 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 `__ to learn more. For this tutorial, please make sure the ``matplotlib`` package is installed for easier visualization. @@ -19,6 +20,7 @@ import torch import torchaudio +import requests import matplotlib.pyplot as plt ###################################################################### @@ -29,7 +31,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())) @@ -207,7 +215,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