Session Ready
Exercise

Finding the time stamps

We know the frequency of our sound wave is 48 kHz, but what if we didn't? We could find it by dividing the length of our sound wave array by the duration of our sound wave. However, Python's wave module has a better way. Calling getframerate() on a wave object returns the frame rate of that wave object.

We can then use NumPy's linspace() method to find the time stamp of each integer in our sound wave array. This will help us visualize our sound wave in the future.

The linspace() method takes start, stop and num parameters and returns num evenly spaced values between start and stop.

In our case, start will be zero, stop will be the length of our sound wave array over the frame rate (or the duration of our audio file) and num will be the length of our sound wave array.

Instructions
100 XP
  • Convert the sound wave bytes to integers.
  • Get the frame rate of the good morning audio file using getframerate().
  • Set stop to be the length of soundwave_gm over the frame rate.
  • Set num to be the length of soundwave_gm.