|
|
|
@ -16,6 +16,48 @@
|
|
|
|
|
<title>大数据管理平台</title>
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
<script>
|
|
|
|
|
$(function (){
|
|
|
|
|
const SpeechRecognition=window.SpeechRecognition||window.webkitSpeechRecognition;
|
|
|
|
|
if(!SpeechRecognition){
|
|
|
|
|
console.error("SpeechRecognition not supported");
|
|
|
|
|
}else{
|
|
|
|
|
const recognition=new SpeechRecognition()
|
|
|
|
|
recognition.continuous = true; // 是否持续监听
|
|
|
|
|
recognition.interimResults = true; // 是否显示临时结果
|
|
|
|
|
|
|
|
|
|
// const grammar = '#JSGF V1.0; grammar colors; public <color> = red | green | blue | yellow ;';
|
|
|
|
|
|
|
|
|
|
// const speechGrammarList = new webkitSpeechGrammarList();
|
|
|
|
|
// speechGrammarList.addFromString(grammar, 1); // 1 是语法的优先级
|
|
|
|
|
|
|
|
|
|
// 将语法列表应用到 SpeechRecognition 实例
|
|
|
|
|
// recognition.grammars = speechGrammarList;
|
|
|
|
|
|
|
|
|
|
// 配置识别选项
|
|
|
|
|
recognition.lang = 'zh-CN'; // 设置语言
|
|
|
|
|
recognition.interimResults = false; // 只返回最终结果
|
|
|
|
|
recognition.maxAlternatives = 1; // 只返回一个替代结果
|
|
|
|
|
|
|
|
|
|
// 开始识别
|
|
|
|
|
recognition.start();
|
|
|
|
|
|
|
|
|
|
recognition.onresult = (event) => {
|
|
|
|
|
const result = event.results[0][0].transcript;
|
|
|
|
|
console.log('识别结果:', result);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
recognition.onend = function() {
|
|
|
|
|
console.log('语音识别已结束');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
recognition.onerror = (event) => {
|
|
|
|
|
console.log(event)
|
|
|
|
|
console.error('识别错误:', event.error);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<body >
|
|
|
|
|
<div class="data_bodey">
|
|
|
|
|
<div class="index_nav" >
|
|
|
|
|