fix(voice): recover empty failed lessons
This commit is contained in:
@@ -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 '录音中'
|
||||
|
||||
Reference in New Issue
Block a user