Picovoice / picovoice

On-device voice assistant platform powered by deep learning
Apache License 2.0
561 stars 109 forks source link

Understanding the pv_picovoice_process() function. #809

Closed GSkoumal closed 5 months ago

GSkoumal commented 5 months ago

Hello, I am currently working on an STM32F407G-DISC1 attempting to use picovoice. I am able to read in PDM data and convert it to PCM, but I am struggling to understand what needs to be sent into the pv_picovoice_process() function. I understand that it is a different buffer of int16_t based on the API documentation. Mainly I need to understand what conversion is being done in the below loops present in the demo, what do these do? Why are we not just passing in the PCM buffer? image

mrrostam commented 5 months ago

As stated in the API documentation, "the number of samples per frame can be obtained by calling pv_picovoice_frame_length." In other words, to use the process function, we need to pass 512 samples in this instance. Therefore, a helper ping pong buffer is employed instead of directly passing the output of the PDMToPCM function. This buffer accumulates the PCM samples, ensuring that the requirement is met