vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

Feature addition: Save audio stream into .wav file (Python wrapper)

Open antondim opened this issue 5 years ago • 4 comments

Hello,

would it be helpful to add my implementation of such a feature on "test_microphone.py" ?

This would enable someone (who's not very familiar with audio data manipulation) to listen to the (uncompressed and lossless) stream audio input which is parsed to the Recognizer for audio device debugging or w/e reasons.

antondim avatar Sep 14 '20 14:09 antondim

Was this done already? Sounds useful!

aaronse avatar Feb 02 '21 13:02 aaronse

It's quite easy to do in Python. Here's an example:

import wave

wav = wave.open(name, "wb")
wav.setparams((CHANNELS, 2, SAMPLE_RATE, 0, 'NONE', 'not compressed'))
wav.writeframes(audio_chunk)
wav.close()

sskorol avatar Feb 04 '21 09:02 sskorol

Was this done already? Sounds useful!

I Added a simple version of test_microphone.py with wav saving option on a different branch of my forked version of vosk-api on my github.

Bear in mind that my initial version of "test_microphone.py" was of an older state of vosk-api. I did not check the updated versions, although I doubt that the logic would be any different. So you can somehow, incorporate the same logic on newer versions of "test_microphone.py" scripts.

antondim avatar Feb 06 '21 08:02 antondim

I gave this a try and when I try to open the file in Media Player on Windows 11 and it won't open, showing the error:

We can't open [filename.wav]. This may be because the file type is unsupported, the file extension is incorrect or the file is corrupt. 0xC00D36C4

Any ideas on why that would be happening?

GabiSchaffzin avatar Jul 29 '23 02:07 GabiSchaffzin