Git Product home page Git Product logo

ios-dragon-mobile-sdk-example's Introduction

Nuance Dragon Mobile SDK and ObjectAL

In iOS 8 I’m faced with a problem with working Nuance Dragon Mobile SDK and ObjectAL together. When I set up Nuance SDK, and if I already have used the ObjectAL before, I have got the error in the log:

ERROR:     [0x3c1779dc] AVAudioSession.mm:646: -[AVAudioSession setActive:withOptions:error:]: 
Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior
to deactivating the audio session.

And I can’t play or record an audio, because session was deactivated in the application.

What does it mean? It means that Nuance SDK tries to set up the active session, and you have some sessions in the ObjectAL.

iOS 8 provides some information about this. In AVAudioSession header:

/* Set the session active or inactive. Note that activating an audio session is a synchronous
(blocking) operation. Therefore, we recommend that applications not activate their session from
a thread where a long blocking operation will be problematic.
Note that this method will throw an exception in apps linked on or after iOS 8 if the session is
set inactive while it has running or paused I/O (e.g. audio queues, players, recorders,
converters, remote I/Os, etc.).
*/

And unfortunately Nuance SDK is private API. And we don’t have access to the source code ☹

You can found some post in the official forum of this SDK. And there’re no any solutions. And the Nuance team did not particularly hurry to solve this issue ☹

But, it’s not all bad. Because we have ObjectAL with opened source code ☺ And I can suggest the solution, maybe it’s not really good solution, but it works. Before using the Nuance SDK you remove the ObjectAL from memory, wait for deallocating framework, and will set up the Nuance SDK after that. During the recognition you should not use ObjectAL, because it’s will deactivate the audio session, but you can use for example AVAudioPlayer.

For stop the ObjectAL you should call the next:

[[OALSimpleAudio sharedInstance] stopEverything];
[OALSimpleAudio purgeSharedInstance];

If you play some audios during the recognition, you should no forgot to stop the playing audio in the didFinishWithResults and didFinishWithError methods, for example for AVAudioPlayer:

- (void)recognizer:(SKRecognizer *)recognizer didFinishWithResults:(SKRecognition *)results
{
    if (audioPlayer) {
        [audioPlayer stop];
    }

    ...
}

- (void)recognizer:(SKRecognizer *)recognizer didFinishWithError:(NSError *)error
        suggestion:(NSString *)suggestion
{
    if (audioPlayer) {
        [audioPlayer stop];
    }

    ...
}

You can check and try this in current repository.
It’s modified sample from Nuance SDK.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.