添加语音识别

This commit is contained in:
浅念
2025-03-15 15:52:09 +08:00
parent 22ce788574
commit 1a868f8aed
+7 -6
View File
@@ -54,7 +54,7 @@
<view class="cell1" v-if="form.followType==2"> <view class="cell1" v-if="form.followType==2">
<view>备注(非必填)</view> <view>备注(非必填)</view>
<view class="yuyin"> <view class="yuyin">
<textarea auto-height v-model="form.condition_desc" placeholder="详细情况..."/> <textarea auto-height v-model="form.mom_desc" placeholder="详细情况..."/>
<image src="/static/image/customer/yuyin.png" mode="" @tap="startRecognize"></image> <image src="/static/image/customer/yuyin.png" mode="" @tap="startRecognize"></image>
</view> </view>
</view> </view>
@@ -141,7 +141,8 @@
region: '', region: '',
firstFollow: '2025-03-11 12:00:01', firstFollow: '2025-03-11 12:00:01',
details: '', details: '',
bf_desc:'' bf_desc:'',
mom_desc:'',
} }
} }
}, },
@@ -224,10 +225,10 @@
var options = {}; var options = {};
var that = this; var that = this;
options.engine = 'baidu'; options.engine = 'baidu';
that.valuebd = ""; that.form.bf_desc = "";
plus.speech.startRecognize(options, function (s) { plus.speech.startRecognize(options, function (s) {
console.log(s); console.log(s);
that.valuebd += s; that.form.bf_desc += s;
}, function (e) { }, function (e) {
console.log("语音识别失败:" + e.message); console.log("语音识别失败:" + e.message);
}); });
@@ -242,13 +243,13 @@
// TODO ios 在没有请求过权限之前无法得知是否有相关权限,这种状态下需要直接调用语音,会弹出正在识别的toast // TODO ios 在没有请求过权限之前无法得知是否有相关权限,这种状态下需要直接调用语音,会弹出正在识别的toast
var options = {}; var options = {};
var that = this; var that = this;
that.value = ""; that.form.mom_desc = "";
options.engine = 'iFly'; options.engine = 'iFly';
options.punctuation = false; // 是否需要标点符号 options.punctuation = false; // 是否需要标点符号
options.timeout = 10 * 1000; //语音录入持续时长 options.timeout = 10 * 1000; //语音录入持续时长
plus.speech.startRecognize(options, function(s) { plus.speech.startRecognize(options, function(s) {
console.log(s); console.log(s);
that.value += s; that.form.mom_desc += s;
// 关闭语音 // 关闭语音
plus.speech.stopRecognize(); plus.speech.stopRecognize();
}, function (e) { }, function (e) {