调用了start 然后调用stop 不能继续调用start,要等个接近10秒,才能继续start。
报错如下:
代码如下:
const startRecording = async () => {
try {
state.isRecording = true;
const result = await startSpeechToText({
duration: 10000,
lang: "zh_CN",
});
state.textInput = result;
confirmtextInput();
} catch (error) {
console.error("录音转文本操作失败:", error);
uni.showToast({
title: "录音异常:" + error.msg,
icon: "none",
});
} finally {
state.isRecording = false;
}
};
const stopRecording = async () => {
if (state.isRecording == false) return;
try {
setTimeout(() => {
state.isRecording == false;
}, 5000);
await stopSpeechToText();
console.log("录音已停止");
} catch (error) {
console.error("停止录音操作失败:", error);
uni.showToast({
title: "停止录音失败,请稍后重试",
icon: "none",
});
}
};