respeaker/respeaker_python_library

save mic.listen() data in a .wav

Closed this issue · 5 comments

Hello,
I'm using Microphone() for vad, listen...
Need to save as wav each detected vocal sequence (no need to recognize words)

I don't have success.
Recording produce very big noizzy sound (record done in very quiet space)
Please help
Vincent

import time
import os
import wave
from respeaker import Microphone

def task():
    mic = Microphone()

    while 1:
            print("à l'écoute")
            data = mic.listen()
            data = b''.join(data)
            record(data)


def record(data):
    f = wave.open('/home/nvidia/Documents/wav/test.wav', 'wb')
    f.setframerate(16000)
    f.setsampwidth(2)
    f.setnchannels(1)
    f.writeframes(data)
    f.close()

def main():
    print('quit event')
    while True:
        try:
            task()
            print('en attente')
            time.sleep(1)
        except KeyboardInterrupt:
            print('Quit')
            break
    print('join')

if __name__ == '__main__':
    main()

http://dl.free.fr/nHJSLP8LH

example of wavefile.
Very bad recording, with vbery clear space and perfect conditions.
An idea ??

Cloud you try to use 8 channels raw audio firmware to verify if there is any mic broken?
See https://github.com/respeaker/mic_array_dfu

@xiongyihui
hello,
raw firmware done.

tested listen_and_get_position.py

File "/home/nvidia/Downloads/respeaker-xmos-hid-master/listen_and_get_position.py", line 102, in main
  mic_gain = read_register(0x10, 1)[0]
IndexError: list index out of range

??

hot to test 8 individually micros ?

Audacity doesn't work !
(each channels, with all frequencies)

When using audacity on windows, Windows WASAPI should be used to read 8 channel data.
image

To get DOA information, we use https://github.com/respeaker/mic_array/blob/master/vad_doa.py or https://github.com/respeaker/mic_array/blob/master/kws_doa.py

@xiongyihui
Hello. Please could you tell me if the python code on first post could work ?
Recording doesn t stop !
Just a small help ?
Ps : the recorded voices with audacity are really clear...perfect.. thanks a lot for this perfect product.
Vincent