Commit 9240570c by 前端

格式

1 parent 27fc18fe
......@@ -339,7 +339,7 @@ Page({
if (next_step == "over") {
setTimeout(() => {
this.toResult();
}, 2000);
}, 3000);
}
});
},
......
......@@ -34,8 +34,6 @@ Component({
*/
data: {
times: 0,
recorder1: wx.getRecorderManager(),
recorder2: wx.getRecorderManager(),
},
lifetimes:{
attached() {
......@@ -44,7 +42,7 @@ Component({
},
detached: function() {
this.data.srStart = false
this.data.recorder1.stop()
wx.getRecorderManager().stop()
if (this.data.sr) {
this.data.sr.shutdown()
} else {
......@@ -66,8 +64,7 @@ Component({
},
onSrStop: async function () {
console.log('onSrStop')
this.data.recorder1.stop()
this.data.recorder2.stop();
wx.getRecorderManager().stop()
await sleep(500)
if (this.data.srStart && this.data.sr) {
try {
......@@ -111,14 +108,7 @@ Component({
console.log("start failed:" + e)
return
}
this.data.recorder1.start({
duration: 600000,
numberOfChannels: 1,
sampleRate: 16000,
format: "PCM",
frameSize: 4
})
this.data.recorder2.start({
wx.getRecorderManager().start({
duration: 600000,
numberOfChannels: 1,
sampleRate: 16000,
......@@ -127,7 +117,7 @@ Component({
})
},
connectSr: async function (options) {
this.data.recorder1.onFrameRecorded((res) => {
wx.getRecorderManager().onFrameRecorded((res) => {
if (res.isLastFrame) {
console.log("record done")
}
......@@ -136,23 +126,10 @@ Component({
this.data.sr.sendAudio(res.frameBuffer)
}
})
this.data.recorder1.onStart(() => {
wx.getRecorderManager().onStart(() => {
console.log("start recording...")
})
this.data.recorder2.onStop((res) => {
console.log(res.tempFilePath)
// if (res.tempFilePath) {
// const {isClose} = this.data
// if(isClose) {
// wx.removeSavedFile({
// filePath: res.tempFilePath
// })
// }else {
// this.setData({filePath:res.tempFilePath})
// }
// }
})
this.data.recorder1.onStop((res) => {
wx.getRecorderManager().onStop((res) => {
console.log("stop recording...")
if (res.tempFilePath) {
const {isClose} = this.data
......@@ -165,7 +142,7 @@ Component({
}
}
})
this.data.recorder1.onError((res) => {
wx.getRecorderManager().onError((res) => {
console.log("recording failed:" + res)
})
try {
......
......@@ -122,7 +122,7 @@ Component({
duration: 600000,
numberOfChannels: 1,
sampleRate: 16000,
format: "PCM",
format: "mp3",
frameSize: 4
})
},
......
......@@ -29,7 +29,7 @@ class SpeechRecognition {
defaultStartParams() {
return {
format:"pcm",
format:"mp3",
sample_rate:16000,
enable_intermediate_result:true,
enable_punctuation_prediction:true,
......
......@@ -29,7 +29,7 @@ class SpeechTranscription {
defaultStartParams() {
return {
format:"pcm",
format:"mp3",
sample_rate:16000,
enable_intermediate_result:true,
enable_punctuation_prediction:true,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!