Skip to content

Commit

Permalink
Minor clean up, and verified usage through testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Apr 14, 2022
1 parent 0532737 commit 74126af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export const recognizeSpeech =
if (typeof (webkitSpeechRecognition) !== "undefined" && recognitionImplementation == null)
recognitionImplementation = webkitSpeechRecognition;

if (recognitionImplementation == null) {
dotnetObj.invokeMethodAsync(onErrorMethodName, key, { "error": "Not supported", "message": "This browser does not support any known SpeechRecognition method."});
if (onErrorMethodName && recognitionImplementation == null) {
dotnetObj.invokeMethod(onErrorMethodName, key, {
Error: "Not supported",
Message: "This browser does not support any known SpeechRecognition method."
});
return;
}

Expand All @@ -63,7 +66,10 @@ export const recognizeSpeech =
}
if (onErrorMethodName) {
_recognition.onerror = (error) => {
dotnetObj.invokeMethod(onErrorMethodName, key, error);
dotnetObj.invokeMethod(onErrorMethodName, key, {
Error: error.error,
Message: error.message
});
};
}
_recognition.onresult = (result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export const recognizeSpeech =
if (typeof (webkitSpeechRecognition) !== "undefined" && recognitionImplementation == null)
recognitionImplementation = webkitSpeechRecognition;

if (recognitionImplementation == null) {
dotnetObj.invokeMethodAsync(onErrorMethodName, key, { "error": "Not supported", "message": "This browser does not support any known SpeechRecognition method." });
if (onErrorMethodName && recognitionImplementation == null) {
dotnetObj.invokeMethodAsync(onErrorMethodName, key, {
Error: "Not supported",
Message: "This browser does not support any known SpeechRecognition method."
});
return;
}

Expand All @@ -63,7 +66,10 @@ export const recognizeSpeech =
}
if (onErrorMethodName) {
_recognition.onerror = (error) => {
dotnetObj.invokeMethodAsync(onErrorMethodName, key, error);
dotnetObj.invokeMethodAsync(onErrorMethodName, key, {
Error: error.error,
Message: error.message
});
};
}
_recognition.onresult = (result) => {
Expand Down

0 comments on commit 74126af

Please sign in to comment.