js浏览器中实时显示麦克风输入音量并将麦克风输入的说话声音转换文本效果代码
代码语言:html
所属分类:多媒体
代码描述:js浏览器中实时显示麦克风输入音量并将麦克风输入的说话声音转换文本效果代码,浏览器端实时识别你说话的文字内容。
代码标签: js 浏览器 实时 显示 麦克风 输入 音量 输入 说话 声音 转换 文本
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Speech Recognition with Volume Bar</title>
<style>
#volumeBar {
width: 100%;
height: 20px;
background-color: #ddd;
}
#volumeLevel {
height: 100%;
background-color: #4CAF50;
width: 0%;
}
</style>
</head>
<body>
<button id="startButton">Start</button>
<p id="output"></p>
<div id="volumeBar">
<div id="volumeLevel"></div>
</div>
注意识别麦克风在chrome中需要魔法上网,可以在edge中试试。
<script>
const startButton = document.getElementById('startButton');
const output = document.getElementById('output');
const volumeLevel = document.getElementById('volumeLevel');
startButton.addEventListener('click', () => {
if (!('webkitSpeechRecognition' in window)) {
.........完整代码请登录后点击上方下载按钮下载查看
网友评论0