- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 convert a .wav file to a spectrogram in Python3?
To convert a .wav file to a spectrogram in python3, we can take the following steps −
Load a .wav file from local machine.
Compute a spectrogram with consecutive Fourier transforms using spectrogram() method.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
Use imshow() method with spectrogram.
To display the figure, use show() method.
Example
import matplotlib.pyplot as plt from scipy import signal from scipy.io import wavfile plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True sample_rate, samples = wavfile.read('test.wav') frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate) plt.pcolormesh(times, frequencies, spectrogram, shading='flat') plt.imshow(spectrogram) plt.show()
Output
- Related Articles
- How to plot a wav file using Matplotlib?
- Playing a WAV file on iOS Safari
- How to convert a Kotlin source file to a Java source file?
- How to convert File into a Stream in Java?
- How to save a Librosa spectrogram plot as a specific sized image?
- How to implement Dictionary with Python3
- How to place X-axis grid over a spectrogram in Python Matplotlib?
- How to convert JSON file to CSV file using PowerShell?
- How to convert XML file into array in PHP?
- How to convert JSON to CSV file using PowerShell?
- Text Analysis in Python3
- How to truncate a file in C#?
- How to compress a file in Java?
- How to truncate a file in Java?
- How to upload a file in Cypress?

Advertisements