Skip to content

Commit

Permalink
Add: Continuous Recognition STT
Browse files Browse the repository at this point in the history
연속 STT 인식 시작 로직 추가
  • Loading branch information
nuatmochoi committed Oct 9, 2020
1 parent 735d50c commit fc117d4
Show file tree
Hide file tree
Showing 7 changed files with 27,453 additions and 0 deletions.
123 changes: 123 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Created by https://www.toptal.com/developers/gitignore/api/node,vscode
# Edit at https://www.toptal.com/developers/gitignore?templates=node,vscode

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env*.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/node,vscode
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="microsoft.cognitiveservices.speech.sdk.bundle.js"></script>
</head>
<body>
<button id="start_stt">STT 시작하기</button>
</body>
<script src="index.js"></script>
</html>
43 changes: 43 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const start_stt = this.document.getElementById('start_stt');
start_stt.addEventListener('click', function () {
const speechConfig = SpeechSDK.SpeechConfig.fromSubscription(
'fa50041df8f34ef3a14a9ef22b910602',
'koreacentral',
);

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

// const recognizer = new SpeechSDK.SpeechRecognizer(speechConfig);

// recognizer.recognizing = (s, e) => {
// console.log(`RECOGNIZING: Text=${e.result.text}`);
// };

recognizer.recognized = (s, e) => {
if (e.result.reason == SpeechSDK.ResultReason.RecognizedSpeech) {
console.log(`RECOGNIZED: Text=${e.result.text}`);
} else if (e.result.reason == SppeechSDK.ResultReason.NoMatch) {
console.log('NOMATCH: Speech could not be recognized.');
}
};

recognizer.canceled = (s, e) => {
console.log(`CANCELED: Reason=${e.reason}`);

if (e.reason == SpeechSDK.CancellationReason.Error) {
console.log(`"CANCELED: ErrorCode=${e.errorCode}`);
console.log(`"CANCELED: ErrorDetails=${e.errorDetails}`);
console.log('CANCELED: Did you update the subscription info?');
}

recognizer.stopContinuousRecognitionAsync();
};

recognizer.sessionStopped = (s, e) => {
console.log('\n Session stopped event.');
recognizer.stopContinuousRecognitionAsync();
};

recognizer.startContinuousRecognitionAsync();
});
Loading

0 comments on commit fc117d4

Please sign in to comment.