Commit 9240570c by 前端

格式

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