fix(voice): recover empty failed lessons

This commit is contained in:
zhangheng
2026-07-22 21:19:22 +08:00
parent 55084a4784
commit 80e670d72b
8 changed files with 226 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import type { FeedbackSession, VoiceAudioSegment, VoiceLesson } from '../../utils/types'
export type VoicePrimaryAction = 'save' | 'retry' | 'processing'
export type VoiceLessonRecoveryAction = 'retry' | 'rerecord' | null
export function getVoicePrimaryAction(session: FeedbackSession | null): VoicePrimaryAction {
if (!session || session.lessonCount === 0) return 'save'
@@ -24,6 +25,15 @@ export function getFailedVoiceSegments(session: FeedbackSession): VoiceAudioSegm
)
}
export function getVoiceLessonRecoveryAction(
lesson: VoiceLesson
): VoiceLessonRecoveryAction {
if (lesson.status !== 'failed') return null
return lesson.segments.some((segment) => segment.status === 'failed')
? 'retry'
: 'rerecord'
}
export function getVoiceLessonStatusText(lesson: VoiceLesson, isInDraft = false): string {
if (lesson.status === 'failed') return '转录失败'
if (lesson.status === 'recording') return '录音中'