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 |
Tags
- sqlite
- 사례관리
- speechAPI
- forof문
- 장고프로젝트
- 안드로이드
- webkitrecognition
- javaScriptError
- Python
- 청소년복지론
- Android
- 개발
- 자바스크립트수학
- PostgreSQL
- 장고웹
- 파이썬
- 이행은이미다른
- 이행은이미다른테이블에속해있습니다
- R데이터분석
- 자바스크립트날짜형식
- 다른테이블에속해있습니다
- 자바스크립트for문
- 장고웹프로젝트
- 자바스크립트forinforof차이
- 장고
- 자바스크립트날짜
- cmd명령어
- 오류종류
- speechtoText
- 자바스크립트날짜get
Archives
- Today
- Total
지금도 개발중
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