I'm trimming some audio files with librosa. This works fine, but instead of saving the trimmed file, I would like to get the length before trimming and after trimming. The code I have now can print all the information I need, I just need to get it into a pandas data frame where column1 = filename, column2 = length before trim, column3 = length after trim. I don't need 'sr'. I can't seem to figure out how to do that right... help appreciated.
here's the code:
for file in files:
print(file)
audio, sr = librosa.load(file, sr= 16000, mono=True)
print(audio.shape, sr)
trimmed = librosa.effects.trim(audio, top_db= 45)
print(trimmed[0].shape, sr)
here's the output I'm getting with the print command:
/Desktop/py_scripts/audio_experiments/wav/1031_8637_73170.wav
(39680,) 16000
(38144,) 16000
/Desktop/py_scripts/audio_experiments/wav/1060_8777_76783.wav
(28160,) 16000
(28160,) 16000
/Desktop/py_scripts/audio_experiments/wav/1128_8634_82873.wav
(74240,) 16000
(74240,) 16000