Skip to content

Commit

Permalink
Modify: full text with all speech recognition results
Browse files Browse the repository at this point in the history
  • Loading branch information
nuatmochoi committed Oct 10, 2020
1 parent 662f00e commit f982271
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
const start_stt = this.document.getElementById('start_stt');
const stop_stt = this.document.getElementById('stop_stt');
let return_str;

start_stt.addEventListener('click', function () {
const speechConfig = SpeechSDK.SpeechConfig.fromSubscription(
'fa50041df8f34ef3a14a9ef22b910602',
'koreacentral',
);

return_str = '';
const audioConfig = SpeechSDK.AudioConfig.fromDefaultMicrophoneInput();
const recognizer = new SpeechSDK.SpeechRecognizer(speechConfig, audioConfig);

recognizer.recognized = (s, e) => {
if (e.result.reason == SpeechSDK.ResultReason.RecognizedSpeech) {
console.log(`RECOGNIZED: Text=${e.result.text}`);
return_str += ` ${e.result.text}`;
} else if (e.result.reason == SppeechSDK.ResultReason.NoMatch) {
console.log('NOMATCH: Speech could not be recognized.');
}
Expand All @@ -25,6 +28,7 @@ start_stt.addEventListener('click', function () {
recognizer.startContinuousRecognitionAsync();

stop_stt.addEventListener('click', function () {
console.log('Whole text:' + return_str); // return_str을 서버로 post하면 완료
recognizer.stopContinuousRecognitionAsync();
});
});

0 comments on commit f982271

Please sign in to comment.