Does not seem to work with FLAC files
karkirowle opened this issue · 3 comments
When attempted, throws the error:
"ValueError: File format b'fLaC'... not understood."
you must be reading file with import scipy.io.wavfile as wav
which can only read/load wav files.
To work this with .flac files you need to change your loader function, change it to soundfile or librosa. my personal favorite librosa.
import librosa
import soundfile as sf
path = 'path/to/file.flac'
data, samplerate = sf.read(path)
data, samplerate = librosa.load(path) #or you can use this
Thank you for your reply. Your answer assumes that one has to load the file in order to do the voice activity detection in it.
In fact, the minimal working example you provide says:
from vad import VoiceActivityDetector
filename = '/Users/user/wav-sample.wav'
v = VoiceActivityDetector(filename)
v.plot_detected_speech_regions()
Replacing with flac did not work for me, and I don't want to spend time to make it work, I found alternatives.
I think it is very clear that a wav file should not be read with scipy.io.wavfile, and in the library, it is probably source of the problem. However, this does not change the fact, that this wrapper currently does not support wav files "as-is".
Solution I provided was a workaround, it's not part of this wrapper.
Yes, I agree with that "wav file should not be read with scipy.io.wavfile". kindly share your solution in reply as well so that in future others may get help from that.