Recommend method to play sound with active speech recognition?

Home Forums OpenEars Recommend method to play sound with active speech recognition?

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

  • Author
    Posts
  • #1020026
    wfilleman
    Participant

    Hi Halle,

    Just wanted to thank you again for getting arm64 supported. I’m just about to submit my app to the App Store for approval, but I’m running into a problem.

    I’ve got a couple of very short sound effects that play in response to user input. Since I’ve got the speech recognizer running in the background, I’m having a hard time figuring out how to also play small sound effects.

    Do you have a recommended way or sample code on the acceptable way to play short .wav files?

    Other info: I’m not using the FliteController at all. Not instantiated or created anywhere. Only using PocketsphinxController with the flags:
    outputAudio = NO;
    audioSessionMixing = YES;

    I’ve tried setting the audioMode flag to “VoiceChat” with no difference.

    Thanks for the help and suggestions.

    Wes

    #1020033
    Halle Winkler
    Politepix

    Hi Wes,

    Have you tried playing them with an AVAudioPlayer, for instance, ones that are properties of the view controller that you can load and prepareToPlay in advance so they aren’t laggy? It’s the only audio object that has absolutely no issues I’m aware of being played while the PlayAndRecord audio session is in place. You can also easily suspend and resume before and after playback so it doesn’t interfere with recognition accuracy. Let me know if that works for you.

    #1020036
    wfilleman
    Participant

    Hi Halle,

    Perfect, thanks. I can confirm that using AVAudioPlayer works as well as another method I found where you make a call to:

    OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)aFileURL, &aSoundID);

    with your sound URL to create a system sound ID that can be played back later using:

    AudioServicesPlaySystemSound(_soundID);

    Just for completeness, while both worked, I found that the AudioServices method worked the best in my scenario.

    Thanks Halle!
    Wes

    #1020037
    wfilleman
    Participant

    UPDATE:

    For clarity, I did have to set the .audioMode flag of the PocketsphinxController object to @”VoiceChat” in order to get iOS to play and record from the mic.

    Wes

    #1020038
    Halle Winkler
    Politepix

    Good to know — there was an old bug preventing AudioServicesPlaySystemSound from working with PlayAndRecord, so I’m happy to hear that it’s working better now.

    #1020039
    Halle Winkler
    Politepix

    For clarity, I did have to set the .audioMode flag of the PocketsphinxController object to @”VoiceChat” in order to get iOS to play and record from the mic.

    Aha, maybe having VoiceChat available now is the reason this works.

    #1020041
    wfilleman
    Participant

    Sounds reasonable. I’m happy to have stumbled into it. :)

    #1020979
    lory
    Participant

    Hi,

    Can you confirm I can’t use SoundSystem when Openears is started ?
    Before startListening call, I can play my sound with:
    AudioServicesPlaySystemSound(answerSounds[0]);

    Then it’s doesn’t work even if I suspend recognition. No error but I can’t hear the sound. Do you have a trick ? I’ve to use AVAudioPlayer way ?

    I’m not using PlayAndRecord, juste simple recognition.

    #1020980
    Halle Winkler
    Politepix

    Hello,

    PlayAndRecord is always used with recognition so this system sounds bug is always in effect when performing recognition. I can confirm that if you want to have sound effects it’s necessary to queue them up in an AVAudioPlayer by instantiating them and calling prepareToPlay.

    #1027030
    tbrandt78
    Participant

    Posted in wrong forum – edited to delete.
    Excuse me.

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