-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex1.html
32 lines (29 loc) · 1.05 KB
/
index1.html
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
32
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Annyang Speech Recognition</title>
</head>
<body>
<h1>语音转文字示例</h1>
<p>说话的内容会显示在下面:</p>
<div id="resultDisplay" style="border: 1px solid #ccc; padding: 10px; min-height: 100px;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.1/annyang.min.js"></script>
<script>
if (annyang) {
// 开启调试模式
annyang.debug();
// 捕捉结果并实时更新到页面
annyang.addCallback('result', function(phrases) {
console.log('识别结果:', phrases);
document.getElementById('resultDisplay').innerText = phrases[0];
});
// 开始监听
annyang.setLanguage('zh-CN');
annyang.start({ autoRestart: true, continuous: true });
} else {
console.log("Annyang 不支持当前浏览器");
}
</script>
</body>
</html>