網站首頁 編程語言 正文
常見應用:游戲界面
?文字語音、商城導航欄
的語音輸入搜索框、聊天界面
的語音文字輸入等.
引自官方?unicloud官方語音:
語音輸入接口可使得網頁開發人員能快速調用設備的麥克風進行語音輸入,而不需要安裝額外的瀏覽器插件。規范不定義底層語音識別引擎的技術架構,瀏覽器實現可基于語音識別服務器或本地內置語音識別模塊。
配置SDK–識別訊飛語音(如果用不了訊飛語音,可換百度語音,自己去看接入文檔)
進入項目根目錄下的?manifest.json
?->?App模塊配置
->speech
?勾選 訊飛語音識別,如下圖所示:
index.vue
文件寫入
<template> <view class="content"> <image class="logo" src="/static/logo.png"></image> <button @click="voiceBegain">訊飛語音識別</button> <view v-if="words1"> 這是searchValue:{{words1}} </view> <view v-if="words2"> 這是searchText:{{words2}} </view> </view> </template> <script> export default { data() { return { title: 'Hello', words1: '', words2: '' } }, onLoad() { }, methods: { send() { uniCloud.callFunction({ name: 'sendcode', success: (e) => { console.log('這是發送驗證碼', e); } }) }, // 調用訊飛語音識別 voiceBegain() { let _this = this; let options = {}; //#ifdef APP-PLUS || APP-PLUS-NVUE options.engine = 'iFly'; options.punctuation = false; // 是否需要標點符號 options.timeout = 10 * 1000; //語音錄入持續時長 plus.speech.startRecognize(options, function(s) { _this.searchText = _this.searchText + s; console.log(_this.searchText) //拿到語音識別的結果 //下面是邏輯 _this.searchValue = s; _this.searchText = "" // 打印輸出結果 _this.words1 = _this.searchValue _this.words2 = _this.searchText // 關閉語音 plus.speech.stopRecognize(); }); //#endif // #ifdef H5 alert("只有h5平臺才有alert方法") // #endif } } } </script> <style> .content { display: flex; flex-direction: column; align-items: center; justify-content: center; } .logo { height: 200rpx; width: 200rpx; margin-top: 200rpx; margin-left: auto; margin-right: auto; margin-bottom: 50rpx; } .text-area { display: flex; justify-content: center; } .title { font-size: 36rpx; color: #8f8f94; } </style>
如圖:
運行云打包
或自定義調試基座
生成?apk?文件,apk安裝到手機上;
點擊button
按鈕,觸發自定義回調函數
此時頁面輸出
注意:
普通瀏覽器里沒有?plus
?環境,只有 HBuilder 真機運行和打包后才能運行plus api
。否則報錯:
原文鏈接:https://blog.csdn.net/qq_44469200/article/details/108753002
相關推薦
- 2022-03-23 C語言新手初階教程之三子棋實現_C 語言
- 2022-05-25 Redis的安裝和使用(windows)
- 2023-07-05 【nacos優化】定時刪除access日志
- 2022-04-27 Shell獲取路徑操作(dirname?$0?pwd)的實現_linux shell
- 2022-08-14 Qt控件點擊消息獲取的方法詳解_C 語言
- 2022-11-11 docker修改默認存儲位置圖文教程_docker
- 2022-05-10 bean作用域 設置創建bean是單實例還是多實例
- 2022-07-21 vscode代碼保存時自動格式化
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支