您的位置:首页 > 科技 > 能源 > 关键词排名软件官网_青岛嘎嘎_西安霸屏推广_临沂百度推广的电话

关键词排名软件官网_青岛嘎嘎_西安霸屏推广_临沂百度推广的电话

2025/3/14 14:16:03 来源:https://blog.csdn.net/liux6687/article/details/146157307  浏览:    关键词:关键词排名软件官网_青岛嘎嘎_西安霸屏推广_临沂百度推广的电话
关键词排名软件官网_青岛嘎嘎_西安霸屏推广_临沂百度推广的电话

 

import voice from './voice/index'const install = function(Vue) {Vue.directive('voice', voice)
}export default install
import voiceHandler from "./voiceHandler"export default {inserted: function (el, binding) {const newElement = document.createElement('span');newElement.className = 'el-icon-video-play';newElement.addEventListener('click', function () {if(this.className === "el-icon-video-play") {this.className = "el-icon-video-pause";voiceHandler.initVoice(el, binding.value);}else {this.className = "el-icon-video-play";voiceHandler.stopRecording();}});el.parentNode.insertBefore(newElement, el.nextSibling);}
}
import WebAudioSpeechRecognizer from './speechrecognizer'
import config from './config'export default {el: null,bindingVal: null,webAudioSpeechRecognizer: null,result: null,initVoice(el, bindingVal) {this.el = el;this.bindingVal = bindingVal;this.result = '';this.startRecording();},startRecording() {this.webAudioSpeechRecognizer = new WebAudioSpeechRecognizer({// 用户参数secretid:  config.secretId,secretkey: config.secretKey,appid: config.appId,engine_model_type : '16k_zh', // 因为内置WebRecorder采样16k的数据,所以参数 engineModelType 需要选择16k的引擎,为 '16k_zh'});// 开始识别this.webAudioSpeechRecognizer.OnRecognitionStart = (res) => {console.log('开始识别', res);};// 识别变化时this.webAudioSpeechRecognizer.OnRecognitionResultChange = (res) => {console.log('识别变化时', res);this.result += res.result.voice_text_str;};// 识别结束this.webAudioSpeechRecognizer.OnRecognitionComplete = (res) => {console.log('识别结束', res);};// 识别错误this.webAudioSpeechRecognizer.OnError = (res) => {console.log('识别失败', res)};this.webAudioSpeechRecognizer.start(); // 开始录音并识别语音},stopRecording() {console.log('停止识别')if (this.webAudioSpeechRecognizer) {this.webAudioSpeechRecognizer.stop(); // 停止录音并结束识别过程this.el.value = this.result; // 将识别结果赋值给输入框this.result = ''; // 清空识别结果}}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com