- This topic has 8 replies, 2 voices, and was last updated 10 years, 9 months ago by Halle Winkler.
-
AuthorPosts
-
December 22, 2012 at 2:13 pm #15077kelvinParticipant
Hi,
How do i delay the pocketsphinxDidDetectSpeech by 5 seconds? I’m playing some sound files during the 5 seconds and i do not want it to detect the sounds. I’ve try suspending the recognition and resuming the recognition. But how do i delay it using [self performSelector:@selector(?:) withObject:nil afterDelay:5.0f];
I’ve try putting [self.pocketsphinxController resumeRecognition]; in a function and calling it in the selector with the delay. But it failed with error unrecognized selector sent to instance.
December 22, 2012 at 3:37 pm #15078Halle WinklerPolitepixWelcome,
pocketsphinxDidDetectSpeech is a delegate method, so you don’t want to delay it since you don’t call it directly, you just want to address the underlying functionality that you control directly which is whether recognition is engaged or not. Suspending recognition before playing your sound and resuming it afterwards should work perfectly for the goal of halting recognition during other media playback, so if it isn’t working perfectly we should figure out why. What happens when you suspend before you play your sound back and resume after your sound is done playing?
December 22, 2012 at 3:55 pm #15079kelvinParticipantI have tried suspending the recognition after flite finished speaking and after a delay of 5 seconds before playing a sound file but it seems that pocketsphinx did detect the sound file which is not what i wanted. Following are my functions for your reference.
– (void) fliteDidFinishSpeaking {
[self.pocketsphinxController suspendRecognition];
[self performSelector:@selector(playAudioAlert:) withObject:nil afterDelay:5.0f];
}-(void) playAudioAlert{
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:
[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@”Audio1″ ofType:@”wav”]] error:nil];player.delegate = self;
[self.player play];
}-(void) audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{
if(flag == YES){
[self.pocketsphinxController resumeRecognition];
}
}December 22, 2012 at 4:10 pm #15080kelvinParticipantI guess my problem would be after flite has finished speaking, i suspended recognition and wait for 5 sec before audio is played but during that time audioPlayerDidFinishPlaying would have been flagged with a “YES” and resumed recognition. So i guess i would have to find a way to stop recognition for 5 sec.
December 22, 2012 at 5:32 pm #15081Halle WinklerPolitepixOK, can you explain to me a little more about why you can’t suspend recognition at the time that you start the playback of your own AVAudioPlayer and resume it when you receive the delegate callback that your own AVAudioPlayer has completed playback? It doesn’t yet make sense to me why you’d need to suspend for an arbitrary period of time when you know the moment that you can suspend and the moment that you can resume in order to not have recognition in progress during your sound playback.
December 22, 2012 at 6:10 pm #15082kelvinParticipantOk got it. Thanks alot for ur help.
Another question is that we can’t vibrate the phone during the sound playback right? I’ve have read some of ur previous post regarding this topic and you mention [AudioSessionManager sharedAudioSessionManager].soundMixing = TRUE; Where do i add this code? Do i need to modify the framework? Any other addition steps?
December 22, 2012 at 6:18 pm #15083Halle WinklerPolitepixOK, glad that was helpful. You don’t actually have to modify the framework in order to turn on sound mixing, it is not currently part of the public API and therefore likely to change in future versions but for the time being you can turn on sound mixing simply by including the line you referenced above right before you do startListeningWithLanguageModelAtPath:. It might be necessary for you to import AudioSessionManager.h in the view controller from which you want to do that.
December 22, 2012 at 6:45 pm #15084kelvinParticipantI’ve added #import to my view controller.
And when i input this
[AudioSessionManager sharedAudioSessionManager].soundMixing = TRUE;the error shows
Property ‘soundMixing’ not found on object of type ‘id’so i did this instead
[[AudioSessionManager sharedAudioSessionManager]setSoundMixing:YES];and added this for vibration
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
to – (void) fliteDidFinishSpeakingbut it didn’t vibrate on the device.
December 22, 2012 at 7:45 pm #15085Halle WinklerPolitepixSorry, that is something you’d need to troubleshoot further on your own. It could be that you aren’t instantiating it at the right point in the logical flow of the app, it could be that there is an issue in the logical flow of your app with where you are trying to initiate the vibration effect (similarly to with the original question in this topic) or it could be that soundMixing isn’t a fix for what you are trying to do. It isn’t a supported feature so regretfully there is a time issue for me with getting too deeply into exploring the different potential reasons it might not be working yet.
-
AuthorPosts
- You must be logged in to reply to this topic.