From f98227197accd870928b70cd361861094bc008f2 Mon Sep 17 00:00:00 2001 From: nuatmochoi Date: Sat, 10 Oct 2020 14:52:19 +0900 Subject: [PATCH] Modify: full text with all speech recognition results --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4e5677e..0c2d058 100644 --- a/index.js +++ b/index.js @@ -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.'); } @@ -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(); }); });