Kitt-AI / snowboy

Future versions with model training module will be maintained through a forked version here: https://github.com/seasalt-ai/snowboy
Other
3.08k stars 997 forks source link

Hi! Raspberry Pi and sd card save #371

Open n1x0id opened 6 years ago

n1x0id commented 6 years ago

Hello!

My question: when snowboy working, it writes a sound file to a SD card (Raspberry Pi 3) or keeps it in RAM? This is pretty critical for me, because if it writes it to SD card, I would make a partition from RAM and write a file to it for a longer save of the SD card.

chenguoguo commented 6 years ago

I'm not sure which demo you are looking at, but Snowboy doesn't have to write a sound file to your SD card.

n1x0id commented 6 years ago

I use my script based on : https://github.com/Kitt-AI/snowboy/blob/master/examples/Python/demo.py

chenguoguo commented 6 years ago

I don't think it's writing to your SD card. Could you post the code snippet?

john170502 commented 6 years ago
def saveMessage(self):
        """
        Save the message stored in self.recordedData to a timestamped file.
        """
        filename = 'output' + str(int(time.time())) + '.wav'
        data = b''.join(self.recordedData)

        #use wave to save data
        wf = wave.open(filename, 'wb')
        wf.setnchannels(1)
        wf.setsampwidth(self.audio.get_sample_size(
            self.audio.get_format_from_width(
                self.detector.BitsPerSample() / 8)))
        wf.setframerate(self.detector.SampleRate())
        wf.writeframes(data)
        wf.close()
        logger.debug("finished saving: " + filename)
        return filename

The function for snowboydecoder.py.

chenguoguo commented 6 years ago

@john170502 if you read the code, the saveMessage part will only get triggered when you provide audio_recorder_callback, the example is in demo4.py

john170502 commented 6 years ago

@chenguoguo yes, i read code for python3 examples. i mean this method will write to the file. snowboy hotword detector don't have wirte sound file. thanks.