I am doing a speech emotion recognition ML.
I currently use pyAudioAnalysis
to do a multi-directory feature extraction. However, the dataset involved in audios containing a lot of approximately silent sections. My objective is to remove the approximately silent parts from all the audios then extract meaningful features.
My current approach is to use librosa
to trim the silent parts.
from librosa.effects import trim
import librosa
from pyAudioAnalysis import audioBasicIO
import matplotlib.pyplot as plt
signal, Fs = librosa.load(file_directory)
trimed_signal = trim(signal,top_db=60)
fig, ax = plt.subplots(nrows=3, sharex=True, sharey=True)
librosa.display.waveplot(trimed_signal, sr=Fs, ax=ax[0])
ax[0].set(title='Monophonic')
ax[0].label_outer()
I tried to plot the wave after trimming using librosa.display.waveplot
but an AttributeError occurred showing AttributeError: module 'librosa' has no attribute 'display'
My questions are
- How to plot the trimmed wave?
- Is it possible to generate a trimmed .wav file? This is because
pyAudioAnalysis
's input for feature extraction is .wav file path but the output oflibrosa
is array.
import librosa.display
separately. See this issue for the reason.librosa.output.write_wav
(check the docs) to store the trimmed array as a wave file. E.g.librosa.output.write_wav(path, trimed_signal, Fs)
.