Question: See the following instructions and write the code in Python: import numpy as np import scipy.io.wavfile as wavfile # Other imports as needed class AudioFrames:

See the following instructions and write the code in Python:

import numpy as np import scipy.io.wavfile as wavfile

# Other imports as needed

class AudioFrames: """AudioFrames  A class for iterating over frames of audio data  """   def __init__(self, filename, adv_ms, len_ms): """"AudioFrames(filename, adv_ms, len_ms)  Create a stream of audio frames where each is in len_ms milliseconds long  and frames are advanced by adv_ms.  """   def get_framelen_samples(self): "get_framelen_ms - Return frame length in samples"   def get_framelen_ms(self): "get_framelen_ms - Return frame length in ms"   def get_frameadv_samples(self): "get_frameadv_ms - Return frame advance in samples"   def get_frameadv_ms(self): "get_frameadv_ms - Return frame advance in ms"   def get_Fs(self): "get_Fs() - Return sample rate"   def __len__(self): "len() - number of frames"    def get_Nyquist(self): """get_Nyquist - Return Nyquist rate (highest frequency that can  be represented with the sample rate.  """   def get_params(self): """Return dictionary with file parameters  fields:  filename - name of sound file  Fs - sample rate  framing - nested dictionary with fields:  adv_ms - frame advance in ms  len_ms - frame length in ms  adv_N, len_N - frame advance & length in samples  """   def shape(self): """shape() - shape of tensor generated by iterator  Returns a numpy array containing the dimensions of each frame.   This will be useful later on. Tensors are generalizations of  vectors and matrices (see Wolfram MathWorld for a concise definition)  and generally can be thought of as arbitrary-dimensioned matrices.  """   # You can create a numpy array from list l with np.asarray(l) def size(self): """size() - Returns a Numpy array of size 1 with the number of elements  in the tensor associated with each frame  """   # You can create a numpy array from list l iwth np.asarray(l) def __iter__(self): """"iter() - Return a frame iterator  (Multiple iterators on same soundfile are not guaranteed to work as expected)  """   # Implementation decision # You can return self and implement a __next__(self) in this class # or you can create and return an instance of an iteration class # of your design that supports __next__(self). def seek_sample(self, N): "seek_sample(N) - Next iterator will start with sample N"    def get_data(self, startidx, N): """get_data(startidx, N) - Retrieve N samples starting at startidx.  This has no side effects, the file position of iterators is unchanged.  Raises a ValueError if outside range of signal.  """

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!