I'm looking for a way to time the input it takes for someone to speak a block of text on a webpage only using HTML5.
I've looked into the x-webkit-speech and can record the sentence but am looking a way to time the input for instance "onwebkitspeechstart"
<input id="speech" type="text" speech x-webkit-speech onwebkitspeechstart="alert('Timer Start');" onwebkitspeechend="alert('Timer End');"/>
Also does anyone know how to change the amount of 开发者_运维技巧time the webkit speech waits before it thinks the speech has ended to allow for longer pauses between sentences.
I've done a lot of Googling on the subject but can't find a list of supported attributes/events.
From a comment from the Original Poster who thought incorrectly that they were not allowed to "Self-Answer" but did figured this out.
Taking a step back this was pretty simple:
<input id="speech" type="text" speech x-webkit-speech onClick="StartTimer();" onwebkitspeechchange="StopTimer();"/>
Then having two Javascripts functions to get the time and then do a compare:
var timeStart;
var timeEnd
function StartTimer(){
timeStart = new Date();
}
function StopTimer() {
timeEnd = new Date(); //get the number of seconds it took to record.
var duration = (timeEnd - timeStart) / 1000;
}
精彩评论