Delay pocketsphinxDidDetectSpeech

Home Forums OpenEars Delay pocketsphinxDidDetectSpeech

Viewing 9 posts - 1 through 9 (of 9 total)

  • Author
    Posts
  • #15077
    kelvin
    Participant

    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.

    #15078
    Halle Winkler
    Politepix

    Welcome,

    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?

    #15079
    kelvin
    Participant

    I 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];
    }
    }

    #15080
    kelvin
    Participant

    I 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.

    #15081
    Halle Winkler
    Politepix

    OK, 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.

    #15082
    kelvin
    Participant

    Ok 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?

    #15083
    Halle Winkler
    Politepix

    OK, 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.

    #15084
    kelvin
    Participant

    I’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) fliteDidFinishSpeaking

    but it didn’t vibrate on the device.

    #15085
    Halle Winkler
    Politepix

    Sorry, 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.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.