Python uses the librosa package to generate audio waveforms

1. Description

When doing speech segmentation, the waveform diagram of the audio file is needed.

2. The code is as follows

import librosa
import librosa.display as ld
import matplotlib.pyplot as plt

# Load audio file
audio_file = 'SA1.WAV'
y, sr = librosa.load(audio_file)

# Plot waveform
plt.figure(figsize=(14, 5))
librosa.display.waveshow(y, sr=sr)
plt.title('Waveform')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.show()

3. Effect drawing

Insert image description here

Guess you like

Origin blog.csdn.net/xdg15294969271/article/details/130648713