- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot a wav file using Matplotlib?
To plot a .wav file using matplotlib, we can take following the steps −
To read a .wav file, we can use the read() method.
After reading the .wav file, we will get a tuple. At the 0 th index, rate would be there and at the 1st index, array sample data.
Use the plot() method to plot the .wav file.
Set y and x labels using ylabel and xlabel with “Amplitude” and “Time” label, respectively.
To display the figure, use the show() method.
Example
from scipy.io.wavfile import read import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True input_data = read("my_audio.wav") audio = input_data[1] plt.plot(audio[0:1024]) plt.ylabel("Amplitude") plt.xlabel("Time") plt.show()
Output
- Related Articles
- Plot data from a .txt file using matplotlib
- How to convert a .wav file to a spectrogram in Python3?
- How to plot a very simple bar chart (Python, Matplotlib) using input *.txt file?
- Playing a WAV file on iOS Safari
- How to get a Gantt plot using matplotlib?
- How to plot collections.Counter histogram using Matplotlib?
- How to plot a kernel density plot of dates in Pandas using Matplotlib?
- Make a multiline plot from .CSV file in matplotlib
- Plot data from CSV file with Matplotlib
- How to plot MFCC in Python using Matplotlib?
- How to plot events on time using Matplotlib?
- How to plot vectors in Python using Matplotlib?
- How to plot 3D graphs using Python Matplotlib?
- How to plot 2d FEM results using matplotlib?
- How to plot a rectangle on a datetime axis using Matplotlib?

Advertisements