Can't play audio

Home Forums OpenEars Can't play audio

Tagged: ,

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

  • Author
    Posts
  • #1021452
    derekm9292
    Participant

    I cannot, for the life of me, get audio files to play. I’ve been trying to suspend speech recognition and then play a small sound, but it just doesn’t work.

    I attempted to to add the code to play the file to the demo project too and that doesn’t work either. I saw the other forum post about not being able to play files using AVAudioPlayer and he said that he just rebuilt and cleaned his project and it started working. I don’t know why that would fix my issue, but I tried it anyway and nothing.

    Here’s my code for playing a small wav file.

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@”sound” ofType:@”wav”]];

    NSError *error;
    AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];

    if (audioPlayer == nil)
    NSLog(@”%@”,[error description]);
    else
    [audioPlayer play];

    I could really use some help here.
    Thanks!

    #1021453
    Halle Winkler
    Politepix

    Hi Derek,

    This is default functionality (FliteController and FliteController+NeatSpeech both use AVAudioPlayer to play back synthesized speech simultaneously with PocketsphinxController whether suspended or not, so it has to be compatible), so I would start by troubleshooting the actual audio file and its playback outside of the OpenEars context.

    It isn’t clear from the code excerpt above how you resume listening, but if your goal is to suspend, completely play your audio, and resume, you probably also need to hook up the AVAudioPlayer delegate methods so you can resume on the callback that your AVAudioPlayer playback completed rather than simultaneously starting playback and calling resume, which could maybe turn into a race condition for audio resources.

    You can also peek at FliteController to see an example of AVAudioPlayer usage during PocketsphinxController listening which is known to work.

    Signature: Did you know that OpenEars has a credit requirement in its license? It’s true! You can read more about it here: https://www.politepix.com/openears/support/#Q_What_license_does_OpenEars_use

    #1021466
    derekm9292
    Participant

    Hi Halle,

    I’ve been looking around, maybe I’m just blind, but I can’t seem to find the source for FliteController. Could you link me to it?

    Thanks,
    Derek

    #1021467
    Halle Winkler
    Politepix

    Hi Derek,

    It will be the first hit for FliteController in either Spotlight or Xcode’s file search.

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