Aan de slagGa gratis aan de slag

Processing audio data with Python

You've seen how a sound waves can be turned into numbers but what does all that conversion look like?

And how about another similar sound wave? One slightly different?

In this exercise, we're going to use MatPlotLib to plot the sound wave of good_morning against good_afternoon.

To have the good_morning and good_afternoon sound waves on the same plot and distinguishable from each other, we'll use MatPlotLib's alpha parameter.

You can listen to the good_morning audio here and good_afternoon audio here.

Deze oefening maakt deel uit van de cursus

Spoken Language Processing in Python

Cursus bekijken

Oefeninstructies

  • Set the title to reflect the plot we are making.
  • Add the good_afternoon time variable (time_ga) and amplitude variable (soundwave_ga) to the plot.
  • Do the same with the good_morning time variable (time_gm) and amplitude variable (soundwave_gm) to the plot.
  • Set the alpha variable to 0.5.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Setup the title and axis titles
plt.title('Good Afternoon vs. Good ____')
plt.ylabel('Amplitude')
plt.xlabel('Time (seconds)')

# Add the Good Afternoon data to the plot
plt.plot(____, ____, label='Good Afternoon')

# Add the Good Morning data to the plot
plt.plot(____, ____, label='Good Morning',
   # Set the alpha variable to 0.5
   alpha=____)

plt.legend()
plt.show()
Code bewerken en uitvoeren