fix(voice): clarify recording disposition
This commit is contained in:
@@ -25,6 +25,7 @@ import { runWithSessionRefresh } from './voice-actions'
|
||||
import {
|
||||
getFailedVoiceSegments,
|
||||
getVoiceFailureHint,
|
||||
getVoiceLessonStatusText,
|
||||
getVoicePrimaryAction,
|
||||
getVoicePrimaryActionText
|
||||
} from './voice-state'
|
||||
@@ -267,6 +268,7 @@ Page({
|
||||
let suffix = '已就绪'
|
||||
if (session.failedSegmentCount > 0) suffix = `${session.failedSegmentCount}段转录失败`
|
||||
else if (session.processingSegmentCount > 0) suffix = '正在处理'
|
||||
else if (session.needsGeneration) suffix = '待生成反馈'
|
||||
const primaryAction = getVoicePrimaryAction(session)
|
||||
this.setData({
|
||||
voiceStatus: `${prefix} · ${suffix}`,
|
||||
@@ -668,8 +670,7 @@ Page({
|
||||
const session = this.data.session
|
||||
if (!session || session.lessonCount === 0) return
|
||||
const lines = session.lessons.map((lesson) => {
|
||||
const status = lesson.status === 'ready' ? '已就绪' : lesson.status === 'failed' ? '转录失败' : '处理中'
|
||||
return `第${lesson.sequence}节 · ${formatVoiceDuration(lesson.durationMs)} · ${status}`
|
||||
return `第${lesson.sequence}节 · ${formatVoiceDuration(lesson.durationMs)} · ${getVoiceLessonStatusText(lesson)}`
|
||||
})
|
||||
const hasFailures = session.failedSegmentCount > 0
|
||||
wx.showModal({
|
||||
@@ -726,11 +727,12 @@ Page({
|
||||
},
|
||||
|
||||
confirmDiscardFailedSegments(): Promise<boolean> {
|
||||
const failedSegmentCount = this.data.session?.failedSegmentCount || 0
|
||||
return new Promise((resolve) => {
|
||||
wx.showModal({
|
||||
title: '放弃失败录音',
|
||||
content: '失败片段将被删除,并立即开始新的录音。此操作无法撤销。',
|
||||
confirmText: '放弃重录',
|
||||
content: `将删除${failedSegmentCount}段失败录音,其余录音和反馈内容不受影响。此操作无法撤销。`,
|
||||
confirmText: '确认放弃',
|
||||
confirmColor: '#d13f3a',
|
||||
success: (result) => resolve(result.confirm),
|
||||
fail: () => resolve(false)
|
||||
@@ -738,14 +740,13 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
async discardFailedAndRecord() {
|
||||
async discardFailedSegments() {
|
||||
if (this.data.recording || this.data.voiceBusy) return
|
||||
const session = this.data.session
|
||||
if (!session) return
|
||||
const failedSegments = getFailedVoiceSegments(session)
|
||||
if (failedSegments.length === 0 || !(await this.confirmDiscardFailedSegments())) return
|
||||
|
||||
let discarded = false
|
||||
this.setData({
|
||||
voiceBusy: true,
|
||||
voiceStatus: `正在放弃${failedSegments.length}段失败录音`,
|
||||
@@ -760,18 +761,17 @@ Page({
|
||||
},
|
||||
async () => this.loadActiveSession()
|
||||
)
|
||||
discarded = true
|
||||
logVoiceOperation('failed_transcription_discarded', {
|
||||
feedbackSessionId: session.id,
|
||||
segmentIds: failedSegments.map((segment) => segment.id)
|
||||
})
|
||||
wx.showToast({ title: '已放弃失败录音', icon: 'none' })
|
||||
} catch (error) {
|
||||
this.showApiError(error)
|
||||
} finally {
|
||||
this.setData({ voiceBusy: false })
|
||||
this.syncVoicePresentation(this.data.session)
|
||||
}
|
||||
if (discarded) await this.toggleRecording()
|
||||
},
|
||||
|
||||
async saveFeedback() {
|
||||
|
||||
@@ -61,8 +61,8 @@
|
||||
<button
|
||||
class="voice-discard-button"
|
||||
disabled="{{saving || generating || recording || voiceBusy}}"
|
||||
bindtap="discardFailedAndRecord"
|
||||
>放弃并重新录制</button>
|
||||
bindtap="discardFailedSegments"
|
||||
>放弃失败录音</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FeedbackSession, VoiceAudioSegment } from '../../utils/types'
|
||||
import type { FeedbackSession, VoiceAudioSegment, VoiceLesson } from '../../utils/types'
|
||||
|
||||
export type VoicePrimaryAction = 'save' | 'retry' | 'processing' | 'generate'
|
||||
|
||||
@@ -25,6 +25,15 @@ export function getFailedVoiceSegments(session: FeedbackSession): VoiceAudioSegm
|
||||
)
|
||||
}
|
||||
|
||||
export function getVoiceLessonStatusText(lesson: VoiceLesson): string {
|
||||
if (lesson.status === 'failed') return '转录失败'
|
||||
if (lesson.status === 'recording') return '录音中'
|
||||
if (lesson.status === 'processing') return '处理中'
|
||||
if (lesson.appliedDirectly) return '已加入输入框'
|
||||
if (lesson.includedInGeneration) return '已生成反馈'
|
||||
return '待生成反馈'
|
||||
}
|
||||
|
||||
export function getVoiceFailureHint(session: FeedbackSession): string {
|
||||
const failedSegments = getFailedVoiceSegments(session)
|
||||
const hasNoClearSpeech = failedSegments.some((segment) => {
|
||||
@@ -33,7 +42,7 @@ export function getVoiceFailureHint(session: FeedbackSession): string {
|
||||
})
|
||||
const count = session.failedSegmentCount
|
||||
if (hasNoClearSpeech) {
|
||||
return `${count}段录音未识别到清晰语音,可能是录音过短、静音或环境噪声较大。可重试,或放弃后重新录制。`
|
||||
return `${count}段录音未识别到清晰语音,可能是录音过短、静音或环境噪声较大。可重试,或放弃该失败录音。`
|
||||
}
|
||||
return `${count}段录音转录失败,可重试,或放弃后重新录制。`
|
||||
return `${count}段录音转录失败,可重试,或放弃该失败录音。`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user