Why is JavaScript STT-SDK from a default microphone just for PC, but not for mobile phones?
We use this const audioConfig = AudioConfig.fromDefaultMicrophoneInput().
//code
speech() {
let that = this;
const speechConfig = SpeechConfig.fromSubscription(
"*",
"*"
);
speechConfig.speechRecognitionLanguage = "zh-CN";
const audioConfig = AudioConfig.fromDefaultMicrophoneInput();
const recognizer = new SpeechRecognizer(speechConfig, audioConfig);
recognizer.start;
recognizer.recognizeOnceAsync(result => {
switch (result.reason) {
case ResultReason.RecognizedSpeech:
console.log(RECOGNIZED: Text=${result.text});
that.inputMsg = result.text;
console.log(" Intent not recognized.");
break;
case ResultReason.NoMatch:
console.log("NOMATCH: Speech could not be recognized.");
that.tts("娌℃湁鍚埌鎮ㄨ璇濆枖~");
break;
case ResultReason.Canceled:
const cancellation = CancellationDetails.fromResult(result);
console.log(CANCELED: Reason=${cancellation.reason});
if (cancellation.reason == CancellationReason.Error) {
console.log(CANCELED: ErrorCode=${cancellation.ErrorCode});
console.log(
CANCELED: ErrorDetails=${cancellation.errorDetails}
);
console.log("CANCELED: Did you update the subscription info?");
}
break;
}
});
},
The JavaScript SDK relies on getUserMedia to gain microphone access.
Some browsers don't support this on phone (Chrome and FireFox on iPhone are examples) and the SDK then has no Microphone access. (Safari does work on iPhone).
https://bugs.webkit.org/show_bug.cgi?id=208667 is the root cause for iOS.
What browser / phone combination are you using?
This problem has beem resloved by this method,
(JavaScript Language API) void plus.speech.startRecognize( options, successCB, errorCB );
On the other hand, I face an another problem, when I test an app with the latest released version of the Microsoft Cognitive Services Speech SDK (1.12.0) on iOS devices.
(JavaScript Language API) const audioConfig = AudioConfig.fromDefaultSpeakerOutput( );
And this function does not work on iOS devices.
I think this PR: https://github.com/microsoft/cognitive-services-speech-sdk-js/pull/183 fixes the speaker output on iOS.
Closing the issue as the questions were answered.