iSpeech. Recognize when user is speaking

105 Views Asked by At

I am new to iSpeech trying to implement this on an iPhone app and would like to know how/if I can identify if the user is speaking. For example, when the mic is active and the user is saying something, I would like to capture that event so as to show some animation and when the user is silent, I would stop the animation.

Is there something in their api to do something like that? or is it possible for me to do it from the AVaudioSession parallel to the iSpeech when iSpeech is already embedded in my project?

Please help.

Thank you

1

There are 1 best solutions below

0
On BEST ANSWER

If you want to find out when the user is speaking, you're using a framework like iSpeech, you can set a timer to find out the volume. This will happen with the AVAudioRecorderDelegate. Inherit this class

helloWorldTimer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("sayHello"), userInfo: nil, repeats: true)

This timer helps to keep monitoring the volume every 0.1 second. So if it's so much as a burst of sound, it will still get detected

This function shows the amount of volume in every 0.1 second. When the mic is active, have this function active using the timer as shown above.

When the mic is turned off, deactivate the timer. Simple

Any other animations you want to make, write them

func sayHello()
{
    if (soundRecorder?.recording == true) {
        soundRecorder?.updateMeters();
        let power:Float = soundRecorder!.averagePowerForChannel(0)
           write your animation etc based on the power (volume) here
        print("Volume is \(power)");
    }
}