48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
export type AsrStatus = 'no_audio_track' | 'silent_audio' | 'has_transcript' | 'processing'
|
|
|
|
export interface AsrData {
|
|
language?: string
|
|
language_probability?: number
|
|
segments?: Array<{
|
|
start_time: number
|
|
end_time: number
|
|
text: string
|
|
}>
|
|
}
|
|
|
|
export function getAsrStatus(asr: AsrData | null | undefined): AsrStatus {
|
|
if (!asr) return 'processing'
|
|
|
|
const segments = asr.segments || []
|
|
const language = asr.language || ''
|
|
const langProb = asr.language_probability || 0
|
|
|
|
if (segments.length === 0) {
|
|
if (language === '' && langProb === 0) {
|
|
return 'no_audio_track'
|
|
}
|
|
return 'silent_audio'
|
|
}
|
|
|
|
return 'has_transcript'
|
|
}
|
|
|
|
export function getAsrStatusLabel(status: AsrStatus): string {
|
|
const labels: Record<AsrStatus, string> = {
|
|
'no_audio_track': '無音軌',
|
|
'silent_audio': '無語音',
|
|
'has_transcript': '有語音',
|
|
'processing': '處理中'
|
|
}
|
|
return labels[status]
|
|
}
|
|
|
|
export function getAsrStatusColor(status: AsrStatus): string {
|
|
const colors: Record<AsrStatus, string> = {
|
|
'no_audio_track': '#999',
|
|
'silent_audio': '#f90',
|
|
'has_transcript': '#0a0',
|
|
'processing': '#59e'
|
|
}
|
|
return colors[status]
|
|
} |