0

I have a below requirement in Windows Phone 8 to run voice listener in background agent whenever an incoming call comes or for an outgoing call. The voice listener should stop when there was NO call.

Eg: When I lift an incoming call and while speaking. I would like to say a voice command say "SPEAKER", then the speaker should ON

I saw obscured events can be used for detecting calls. But am unable to start the voice listener from background agent. Kindly please assist.

Here is the method I am using in the ScheduledAgent.cs file, but no luck

private async void SpeakTest()
{
    SpeechRecognizerUI speechRecognition = new SpeechRecognizerUI();

    SpeechRecognitionUIResult recoResult = await speechRecognition.RecognizeWithUIAsync();
     if (recoResult.ResultStatus == SpeechRecognitionUIStatus.Succeeded)
     {
         lblMessage.Text = recoResult.RecognitionResult.Text;
     }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

First, You can not run a background task whenever you want. OS will decide when to run your task agent. It'll not run continuously. Rather it'll run in interval
Second, In windows phone 8 ( not elsewhere) the microphone is muted to external app.
Third, You shouldn't try to run SpeechRecognizerUI from background agent.

deeiip
  • 3,319
  • 2
  • 22
  • 33