python – Hi! How to fix ‘tuple’ object has no attribute ‘shape’?


import os
import scipy.io
from scipy.io import wavfile
import numpy as np
import matplotlib as mtl
import matplotlib.pyplot as plt

dataset_path = os.path.join(os.environ(‘HOME’), ‘shared’, ‘data’, ‘assignment_1’)
wavedata = os.path.join(dataset_path, ‘example.wav’)

audio_buffer = scipy.io.wavfile.read(wavedata)
fs = int(audio_buffer(0))
assert fs == 44100

print(“Sample rate is %i.” % fs)
print(‘All tests successful!’)
print(type(audio_buffer))
print(len(audio_buffer))
print(audio_buffer)
print(wavedata)

print(fs)

assert audio_buffer.shape(0) == 264600
assert len(audio_buffer.shape) == 1
assert fs == 44100

print(‘All tests successful!’)
import IPython.display as ipd
ipd.Audio(audio_buffer(1), rate=fs)


gives error

Sample rate is 44100.
All tests successful!
<class ‘tuple’>
2
(44100, array(( 0, 0, 0, …, 13, 14, 15), dtype=int16))
/home/e01641179/shared/data/assignment_1/example.wav
44100

AttributeError Traceback (most recent call last)
in
29
30
—> 31 assert audio_buffer.shape(0) == 264600
32 assert len(audio_buffer.shape) == 1
33 assert fs == 44100

AttributeError: ‘tuple’ object has no attribute ‘shape’