Skip to content

Commit b2b5f40

Browse files
committed
Wrap boto3 response in bytesio
1 parent 98fbd03 commit b2b5f40

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/tutorials/audio_io_tutorial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import torch
2424
import torchaudio
2525
from torchaudio.utils import load_torchcodec
26+
from io import BytesIO
2627

2728
print(torch.__version__)
2829
print(torchaudio.__version__)
@@ -257,7 +258,7 @@ def plot_specgram(waveform, sample_rate, title="Spectrogram"):
257258
key = "VOiCES_devkit/source-16k/train/sp0307/Lab41-SRI-VOiCES-src-sp0307-ch127535-sg0042.wav"
258259
client = boto3.client("s3", config=Config(signature_version=UNSIGNED))
259260
response = client.get_object(Bucket=bucket, Key=key)
260-
waveform, sample_rate = load_torchcodec(response["Body"])
261+
waveform, sample_rate = load_torchcodec(BytesIO(response['Body'].read()))
261262
plot_specgram(waveform, sample_rate, title="From S3")
262263

263264

0 commit comments

Comments
 (0)