Skip to content

Commit 70e0c9d

Browse files
committed
fix file access.
1 parent c2877f3 commit 70e0c9d

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
@@ -20,6 +20,7 @@
2020

2121
import torch
2222
import torchaudio
23+
import requests
2324
import matplotlib.pyplot as plt
2425

2526
######################################################################
@@ -30,7 +31,13 @@
3031
# call waveform the resulting raw audio signal.
3132
#
3233

33-
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"
3441
waveform, sample_rate = torchaudio.load(filename)
3542

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

0 commit comments

Comments
 (0)