Commit ffee4d1a by 前端

fixed

1 parent d9e1b533
......@@ -23,14 +23,19 @@ Component({
},
// 对话灵感内容
inspirationContent: {
type: String
type: String,
observer: function (n) {
this.setData({content:n})
}
}
},
/**
* 组件的初始数据
*/
data: {
times: 0
times: 0,
recorder1: wx.getRecorderManager(),
recorder2: wx.getRecorderManager(),
},
lifetimes:{
attached() {
......@@ -39,7 +44,7 @@ Component({
},
detached: function() {
this.data.srStart = false
wx.getRecorderManager().stop()
this.data.recorder1.stop()
if (this.data.sr) {
this.data.sr.shutdown()
} else {
......@@ -61,7 +66,8 @@ Component({
},
onSrStop: async function () {
console.log('onSrStop')
wx.getRecorderManager().stop()
this.data.recorder1.stop()
this.data.recorder2.stop();
await sleep(500)
if (this.data.srStart && this.data.sr) {
try {
......@@ -105,16 +111,23 @@ Component({
console.log("start failed:" + e)
return
}
wx.getRecorderManager().start({
this.data.recorder1.start({
duration: 600000,
numberOfChannels: 1,
sampleRate: 16000,
format: "PCM",
frameSize: 4
})
this.data.recorder2.start({
duration: 600000,
numberOfChannels: 1,
sampleRate: 16000,
format: "mp3",
frameSize: 4
})
},
connectSr: async function (options) {
wx.getRecorderManager().onFrameRecorded((res) => {
this.data.recorder1.onFrameRecorded((res) => {
if (res.isLastFrame) {
console.log("record done")
}
......@@ -123,10 +136,23 @@ Component({
this.data.sr.sendAudio(res.frameBuffer)
}
})
wx.getRecorderManager().onStart(() => {
this.data.recorder1.onStart(() => {
console.log("start recording...")
})
wx.getRecorderManager().onStop((res) => {
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) => {
console.log("stop recording...")
if (res.tempFilePath) {
const {isClose} = this.data
......@@ -139,7 +165,7 @@ Component({
}
}
})
wx.getRecorderManager().onError((res) => {
this.data.recorder1.onError((res) => {
console.log("recording failed:" + res)
})
try {
......@@ -216,7 +242,7 @@ Component({
this.onSrStart()
})
},300)
},1000)
},1500),
onClose() {
this.setData({
......
<!--packageEquity/pages/aiCheck/components/SpeechPopup/SpeechPopup.wxml-->
<pop-up class="speech-popup" title="{{inspirationContent?'对话灵感':'正在录音'}}" show="{{show}}" height="{{inspirationContent ? '850rpx':'530rpx'}}" bindcancel="onClose">
<pop-up class="speech-popup" title="{{content?'对话灵感':'正在录音'}}" show="{{show}}" height="{{content ? '850rpx':'530rpx'}}" bindcancel="onClose">
<!-- <view class="inspiration-title">
<view wx:if="{{inspirationContent}}">对话灵感</view> -->
<view wx:if="{{content}}">对话灵感</view> -->
<!-- <view class="inspiration-title-icon" bindtap="openInspiration">
<gl-image class="inspiration-icon" src="/aiCheck/inspiration-icon.png"></gl-image>
对话灵感
</view> -->
<!-- <view class="inspiration-title-description">用自己的话说出来效果更佳~</view> -->
<!-- </view> -->
<view class="inspiration-content" wx:if="{{inspirationContent}}">
<view class="inspiration-content" wx:if="{{content}}">
<scroll-view scroll-y class="inspiration-scroll">
<view class="content">{{inspirationContent}}</view>
<view class="content">{{content}}</view>
</scroll-view>
<!-- <block wx:else>
<view class="first loadding"></view>
<view class="second loadding"></view>
<view class="third loadding"></view>
</block>
<view wx:if="{{!inspirationContent}}" class="loadding-text">对话灵感生成中...</view> -->
<view wx:if="{{!content}}" class="loadding-text">对话灵感生成中...</view> -->
</view>
<view class="inspiration-line" wx:if="{{inspirationContent}}">用自己的话说出来效果更佳</view>
<view class="inspiration-line" wx:if="{{content}}">用自己的话说出来效果更佳</view>
<view class="loading-box">
<view class="loading-item" wx:for="{{36}}">
</view>
......
......@@ -71,6 +71,7 @@ Page({
wx.navigateBack({
delta: 1,
});
prevPage.setData({tabIndex:1})
} else {
wx.navigateBack({
delta: 2,
......
......@@ -67,7 +67,6 @@ console.log(wx.$util.getUserInfo(), '==============')
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({tabIndex:1})
},
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!