Skip to content

Instantly share code, notes, and snippets.

@mikezucc
Last active January 18, 2018 20:47
Show Gist options
  • Save mikezucc/e822a4bfa714fc93d112423d39bacf87 to your computer and use it in GitHub Desktop.
Save mikezucc/e822a4bfa714fc93d112423d39bacf87 to your computer and use it in GitHub Desktop.
-(void) microphone:(EZMicrophone *)microphone
hasAudioReceived:(float **)buffer
withBufferSize:(UInt32)bufferSize
withNumberOfChannels:(UInt32)numberOfChannels {
dispatch_async(dispatch_get_main_queue(),^{
NSLog(@"\tbuffer size %ld", (long)bufferSize);
float buffInternal[557] = { 0 };
float *buffCopy[1] = {buffInternal};
memcpy(buffCopy, buffer, sizeof(buffCopy));
NSLog(@"first buffCopy %f", *buffCopy[0]);
int result = _snowboyDetect->RunDetection(buffer[0], bufferSize);
if (result == 1) {
self.detected.text = @"Hotword Detected";
detection_countdown = 30;
[[AudioCortexTransport sharedInstance] queueSampleBuffersToCortex:buffCopy
bufferSize:bufferSize
channels:numberOfChannels];
} else {
if (detection_countdown == 0){
self.detected.text = @"No Hotword Detected";
} else {
detection_countdown--;
[[AudioCortexTransport sharedInstance] queueSampleBuffersToCortex:buffCopy
bufferSize:bufferSize
channels:numberOfChannels];
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment