LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Spoken Language Processing in Python

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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 bearbeiten und ausführen