摘要
微信同声传译插件是微信自研的语音输入,文本翻译等功能的插件封装,用于提供给第三方小程序调用。
这里只使用此插件的语音输入功能实现语音识别,识别结果显示在输入框,并将识别结果传入后台进行查找,实现搜索功能。
效果图
添加同声传译插件
小程序管理后台-设置-第三方服务
目前最新版本为0.3.4
AppID:wx069ba97219f66d99
app.json
{
...
"plugins": {
...
"WechatSI": {
"version": "0.3.4",
"provider": "wx069ba97219f66d99"
}
}
}
wxml
<!-- 搜索框 -->
<view class="searchBox">
<input type="text" name="id" value="{
{
inputValue}}" />
</view>
<!-- 语音识别长按键 -->
<view class="{
{
voiceBtn}}" bindtouchstart="touchStart" bindtouchend="touchEnd">
<image class="{
{
voiceStyle}}" src="/images/voice.png"></image>
<text>长按说话</text>
</view>
<!-- 显示搜索到的垃圾 -->
<view>
<view wx:for="{
{
garSearchList}}" wx:key="item">
<view id="{
{
item.gar_id}}&#