Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 이행은이미다른
- 자바스크립트날짜
- 자바스크립트날짜형식
- webkitrecognition
- 장고웹프로젝트
- 이행은이미다른테이블에속해있습니다
- 개발
- 다른테이블에속해있습니다
- Python
- javaScriptError
- 장고웹
- 안드로이드
- 청소년복지론
- 자바스크립트날짜get
- 자바스크립트forinforof차이
- 파이썬
- speechAPI
- 장고프로젝트
- 사례관리
- 장고
- forof문
- cmd명령어
- speechtoText
- 오류종류
- PostgreSQL
- Android
- R데이터분석
- 자바스크립트수학
- sqlite
- 자바스크립트for문
Archives
- Today
- Total
EMDI는 지금도 개발중
Node.js : webkitSpeechRecognition 를 이용해서 Speech-to-text 본문
이번 글에서는 google의 Speech-to-Text API 정보를 찾아보다가 알게 된 webkitSpeechRecognition에 대해 포스팅해보도록 하겠습니다. webkitSpeechRecognition을 이용하면 내가 녹음하는 동안 연결했던 html의 text에 자동으로 출력되는 것을 확인할 수 있습니다.
1) html에 녹음버튼과 결과값 출력할 text 만들기
<a href="#" id="record_start" style="text-decoration:none;color:black;">녹음시작</a>
<span id="record_msg" style="margin-left: 50px;"></span>
2) webitSpeechRecognition으로 출력하기
var r=document.getElementById('record_msg');
function webkitSpeech()
{
if('webkitSpeechRecognition'in window){
//Web speech API Function
var speechRecognizer = new webkitSpeechRecognition();
speechRecognizer.continuous = true;
speechRecognizer.interimResults = true;
//lang : language (ko-KR : Korean, en-IN : englist)
speechRecognizer.lang="ko-KR";
speechRecognizer.start();
var finalTranscripts = '';
speechRecognizer.onresult=function(event){
var interimTranscripts='';
for(var i=event.resultIndex; i < event.results.length; i++)
{
var transcript=event.results[i][0].transcript;
transcript.replace("\n","<br>");
//isFinal : if speech recognition is finished, isFinal = true
if(event.results[i].isFinal){
finalTranscripts+=transcript;
}
else{
interimTranscripts+=transcript;
}
}
//insert into HTML
r.innerHTML=finalTranscripts+'<span style="color:#999">'+interimTranscripts+'</span>';
};
speechRecognizer.onerror = function(event){
};
}
else{
//if browser don't support this function. this message will show in your web
r.innerHTML ="your browser is not supported. If google chrome. Please upgrade!";
}
}
Comments