Last active
January 18, 2018 20:47
-
-
Save mikezucc/e822a4bfa714fc93d112423d39bacf87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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