Skip to content

Commit 2c3eb44

Browse files
committed
fix file access.
1 parent 622b35a commit 2c3eb44

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

beginner_source/audio_preprocessing_tutorial.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import torch
2323
import torchaudio
24+
import requests
2425
import matplotlib.pyplot as plt
2526

2627
######################################################################
@@ -31,7 +32,13 @@
3132
# call waveform the resulting raw audio signal.
3233
#
3334

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

3744
print("Shape of waveform: {}".format(waveform.size()))

0 commit comments

Comments
 (0)