Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
fix: clarify audio translation progress wait
Leggett33d062ce2eb5
diff --git a/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx b/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsxindex 29497064..e02b036f 100644--- a/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx+++ b/apps/web/src/features/dashboard/CreatorCollaborationPanel.test.tsx@@ -107,6 +107,7 @@ describe('shared video progress timing', () => {it.each([['subtitle', 'processing_audio', '字幕翻译', '音频分段 4/4;语音识别 3/4 段;字幕翻译 1/4 段;第 2 段已翻译 5/12 句'],+ ['subtitle', 'translating_audio', '字幕翻译', '音频分段 1/1;语音识别 1/1 段;字幕翻译 0/1 段'],['tts', 'generating_voice', '配音生成', '已生成配音 1/4 段'],['render-horizontal', 'rendering_video', '横屏成片', '正在编码并合成字幕视频;已处理 12 秒 / 60 秒']])('shows video details and elapsed time for %s without advancing progress while waiting', (stageId, phase, label, message) => {@@ -121,7 +122,10 @@ describe('shared video progress timing', () => {<CreatorCollaborationPanel adapter={videoTranslationPanelAdapter} stepLabel="视频翻译" contextSummary="英语 → 简体中文" /></CreatorSessionProvider></LanguageProvider>);- expect(screen.getByText(message)).toBeVisible();+ const messageElement = phase === 'translating_audio'+ ? screen.getByText(message, { exact: false })+ : screen.getByText(message);+ expect(messageElement).toBeVisible();act(() => { vi.advanceTimersByTime(30_000); });expect(screen.getByText('已运行 0:35')).toBeVisible();expect(screen.getByRole('progressbar', { name: `${label}进度` })).toHaveAttribute('aria-valuenow', '45');diff --git a/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx b/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsxindex c267f915..5f3fe8c7 100644--- a/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx+++ b/apps/web/src/features/dashboard/CreatorCollaborationPanel.tsx@@ -710,11 +710,16 @@ function CreatorStageProgressDetails(props: { stage: CreatorStageRun; progress:const elapsedSeconds = Math.max(0, Math.floor((now - (Number.isFinite(startedAt) ? startedAt : observedRef.current.firstSeenAt)) / 1_000));const receivedSeconds = Math.max(0, Math.floor((now - observedRef.current.receivedAt) / 1_000));const duration = `${Math.floor(elapsedSeconds / 60)}:${String(elapsedSeconds % 60).padStart(2, '0')}`;+ const waitingForTranslation = progress.phase === 'translating_audio' || progress.phase === 'translating_subtitles';const waitingForProvider = progress.phase === 'queued' || progress.phase === 'generating';const disconnected = session?.connection !== undefined && session.connection.status !== 'connected';const warning = !showTiming ? null : disconnected? localize('任务连接已中断,正在尝试恢复;恢复后会同步最新状态。', 'The task connection is interrupted. Reconnecting to receive the latest status.', 'Anslutningen till uppgiften har brutits. Återansluter för att hämta den senaste statusen.')- : waitingForProvider && receivedSeconds >= 30+ : waitingForTranslation && receivedSeconds >= 30+ ? localize('翻译服务尚未返回新的结果,正在等待翻译完成。', 'No new translation result has arrived yet. Waiting for the translation service to finish.', 'Inget nytt översättningsresultat har kommit ännu. Väntar på att översättningstjänsten ska bli klar.')+ : waitingForTranslation && elapsedSeconds >= 120+ ? localize('仍在等待翻译服务返回结果,翻译时间由服务商决定。可以离开当前页面,任务会在后台继续。', 'Still waiting for the translation service. Translation time depends on the provider. You can leave this page; the task continues in the background.', 'Väntar fortfarande på översättningstjänsten. Översättningstiden beror på leverantören. Du kan lämna sidan; uppgiften fortsätter i bakgrunden.')+ : waitingForProvider && receivedSeconds >= 30? localize('暂未收到新的生成状态,仍在等待服务商响应。', 'No new generation status has arrived yet. Waiting for the provider to respond.', 'Ingen ny genereringsstatus har kommit ännu. Väntar på svar från leverantören.'): waitingForProvider && elapsedSeconds >= 120? localize('仍在等待服务商返回结果,生成时间由服务商决定。可以离开当前页面,任务会在后台继续。', 'Still waiting for the provider result. Generation time depends on the provider. You can leave this page; the task continues in the background.', 'Väntar fortfarande på leverantörens resultat. Genereringstiden beror på leverantören. Du kan lämna sidan; uppgiften fortsätter i bakgrunden.')diff --git a/apps/web/src/features/dashboard/creator-panel-adapters.test.ts b/apps/web/src/features/dashboard/creator-panel-adapters.test.tsindex cfd50365..ae4bc4ee 100644--- a/apps/web/src/features/dashboard/creator-panel-adapters.test.ts+++ b/apps/web/src/features/dashboard/creator-panel-adapters.test.ts@@ -163,6 +163,19 @@ describe('video translation component progress', () => {if (language !== 'zh-CN') expect(progress.message).not.toMatch(/\p{Script=Han}/u);});+ it.each(['zh-CN', 'en-US', 'sv-SE'] as const)('explains that audio translation is waiting for the next provider result in %s', language => {+ const localize = createLocalizedCopy(language);+ const running = { ...stage('subtitle', '', 'running', null, 'subtitle'), progress: {+ phase: 'translating_audio', percent: 57, completed: 0, total: 1,+ message: '音频分段 1/1;语音识别 1/1 段;字幕翻译 0/1 段'+ } };+ const progress = videoTranslationPanelAdapter.readStageProgress(running, localize);+ expect(progress).toMatchObject({ showMessage: true, showTiming: true, percent: 57, completed: 0, total: 1 });+ expect(videoTranslationPanelAdapter.runningProgressText?.(running, progress, localize)).toContain('0/1');+ expect(progress.message).toContain(language === 'zh-CN' ? '等待翻译服务返回结果' : language === 'en-US' ? 'Waiting for the translation service' : 'Väntar på att översättningstjänsten');+ if (language !== 'zh-CN') expect(progress.message).not.toMatch(/\p{Script=Han}/u);+ });+it.each([['downloading_media', '正在下载视频:12.0 MiB / 24.0 MiB;2.0 MiB/s;预计剩余 6 秒', '12.0 MiB / 24.0 MiB'],['extracting_audio', '正在提取音频;已处理 12 秒 / 60 秒', '12 s / 60 s'],diff --git a/apps/web/src/features/dashboard/creator-panel-adapters.ts b/apps/web/src/features/dashboard/creator-panel-adapters.tsindex 20a58c9c..7362998b 100644--- a/apps/web/src/features/dashboard/creator-panel-adapters.ts+++ b/apps/web/src/features/dashboard/creator-panel-adapters.ts@@ -142,6 +142,7 @@ export const videoTranslationPanelAdapter: CreatorPanelAdapter = {dependencies_ready: l('组件已就绪,开始转录', 'Components ready; starting transcription'),transcribing_audio: l('识别视频语音', 'Transcribing video audio'),processing_audio: l('识别语音并翻译字幕', 'Transcribing audio and translating subtitles'),+ translating_audio: l('翻译音频字幕', 'Translating audio subtitles', 'Översätter ljudundertexter'),downloading_media: l('下载视频与音频', 'Downloading video and audio'),extracting_audio: l('提取视频音频', 'Extracting video audio'),preparing_render: l('准备视频画面和字幕', 'Preparing video and subtitles'),@@ -161,6 +162,7 @@ export const videoTranslationPanelAdapter: CreatorPanelAdapter = {if (progress.phase === 'translating_subtitles') return l(`翻译字幕,已完成 ${amount} 句`, `Translating subtitles, ${amount} sentences completed`);if (progress.phase === 'recovering_translation') return l(`正在恢复字幕处理,已完成 ${amount} 句`, `Recovering subtitle processing, ${amount} sentences completed`, `Återställer undertextbearbetning, ${amount} meningar klara`);if (progress.phase === 'processing_audio') return l(`处理音频,字幕翻译完成 ${amount} 段`, `Processing audio, ${amount} segments translated`);+ if (progress.phase === 'translating_audio') return l(`翻译音频字幕,已完成 ${amount} 段`, `Translating audio subtitles, ${amount} segments completed`, `Översätter ljudundertexter, ${amount} segment klara`);if (progress.phase === 'transcribing_audio') return l(`识别语音,已完成 ${amount} 段`, `Transcribing audio, ${amount} segments completed`);if (progress.phase === 'generating_voice') return l(`生成配音,已完成 ${amount} 段`, `Generating dubbing, ${amount} segments completed`);}@@ -233,13 +235,19 @@ export const videoTranslationPanelAdapter: CreatorPanelAdapter = {const phase = standard.phase ?? readString(legacy?.phase);const phaseLabel = phase === null ? null : videoTranslationPanelAdapter.phaseLabel(phase, localize);const translating = phase === 'translating_subtitles';+ const translatingAudio = phase === 'translating_audio';const detailed = phase !== null && videoTranslationDetailedPhases.has(phase);const rawMessage = standard.message ?? readString(legacy?.message);const localizedMessage = localizeVideoProgressMessage(rawMessage, localize);const detailMessage = localizedMessage- ?? (translating- ? localize('正在等待翻译服务返回结果,进度随已完成的句子更新。', 'Waiting for the translation service. Progress updates as sentences are completed.')- : phaseLabel);+ ? translatingAudio+ ? `${localizedMessage} ${localize('正在等待翻译服务返回结果。', 'Waiting for the translation service to return the next result.', 'Väntar på att översättningstjänsten ska returnera nästa resultat.')}`+ : localizedMessage+ : (translatingAudio+ ? localize('正在等待翻译服务返回结果,进度随已完成的音频段更新。', 'Waiting for the translation service. Progress updates as audio segments are completed.', 'Väntar på översättningstjänsten. Förloppet uppdateras när ljudsegment blir klara.')+ : translating+ ? localize('正在等待翻译服务返回结果,进度随已完成的句子更新。', 'Waiting for the translation service. Progress updates as sentences are completed.')+ : phaseLabel);return {summary: translating && localizedMessage !== null && /^初译 \d+\/\d+;字幕完成 \d+\/\d+;/.test(rawMessage ?? '')? detailMessage ?? undefined : undefined,@@ -345,7 +353,7 @@ function videoTranslationTaskProgress(job: CreatorJob, l: CreatorPanelLocalize):const videoTranslationDetailedPhases = new Set(['preparing_source', 'reading_platform_captions', 'processing_platform_captions','preparing_original_media', 'preparing_audio', 'downloading_media', 'extracting_audio',- 'transcribing_audio', 'processing_audio', 'translating_subtitles', 'recovering_translation', 'planning_voice',+ 'transcribing_audio', 'processing_audio', 'translating_audio', 'translating_subtitles', 'recovering_translation', 'planning_voice','generating_voice', 'fitting_voice', 'assembling_voice', 'muxing_voice','preparing_render', 'rendering_video']);diff --git a/runtime/krillinai/internal/service/audio2subtitle.go b/runtime/krillinai/internal/service/audio2subtitle.goindex 84093259..3ec198e0 100644--- a/runtime/krillinai/internal/service/audio2subtitle.go+++ b/runtime/krillinai/internal/service/audio2subtitle.go@@ -917,6 +917,10 @@ func (s Service) startResultHandler(ctx context.Context, eg *errgroup.Group, steTRANSCRIBE_WEIGHT,TRANSLATE_WEIGHT,)+ phase := "processing_audio"+ if transcribed == segmentNum && translated < segmentNum {+ phase = "translating_audio"+ }message := fmt.Sprintf("音频分段 %d/%d;语音识别 %d/%d 段;字幕翻译 %d/%d 段", splitCompleted, segmentNum, transcribed, segmentNum, translated, segmentNum)for id := 0; id < segmentNum; id++ {if fraction := transcriptionProgress[id]; fraction > 0 && fraction < 1 {@@ -931,7 +935,7 @@ func (s Service) startResultHandler(ctx context.Context, eg *errgroup.Group, stebreak}}- stepParam.TaskPtr.ReportProgress(types.TaskProgress{Phase: "processing_audio", Percent: int(percent), Message: message, Completed: translated, Total: segmentNum})+ stepParam.TaskPtr.ReportProgress(types.TaskProgress{Phase: phase, Percent: int(percent), Message: message, Completed: translated, Total: segmentNum})}updateProgress()// 完成的任务数量diff --git a/runtime/krillinai/internal/service/audio_progress_test.go b/runtime/krillinai/internal/service/audio_progress_test.goindex b8504b39..49cb959f 100644--- a/runtime/krillinai/internal/service/audio_progress_test.go+++ b/runtime/krillinai/internal/service/audio_progress_test.go@@ -80,3 +80,38 @@ func TestAudioProgressReportsOverlappingRecognitionAndTranslation(t *testing.T)t.Fatalf("missing real simultaneous progress: %+v, error=%v", last, err)}}++func TestAudioProgressMarksTranslationWaitAfterTranscription(t *testing.T) {+ log.InitLogger()+ ctx, cancel := context.WithCancel(context.Background())+ defer cancel()+ group, groupCtx := errgroup.WithContext(ctx)+ split := make(chan DataWithId[string], 1)+ transcribe := make(chan DataWithId[string], 1)+ transcriptProgress := make(chan DataWithId[float64], 1)+ transcribed := make(chan DataWithId[*types.TranscriptionData], 1)+ translate := make(chan DataWithId[string], 1)+ translationProgress := make(chan DataWithId[TranslationProgress], 1)+ translated := make(chan DataWithId[[]*TranslatedItem], 1)+ pendingSplit := make(chan DataWithId[[2]float64], 1)+ split <- DataWithId[string]{Id: 0, Data: "audio.wav"}+ go func() {+ <-transcribe+ transcribed <- DataWithId[*types.TranscriptionData]{Id: 0, Data: &types.TranscriptionData{Text: "Hello world."}}+ }()+ var waiting types.TaskProgress+ task := &types.SubtitleTask{}+ task.SetDetailedProgressReporter(func(progress types.TaskProgress) {+ if progress.Phase == "translating_audio" {+ waiting = progress+ cancel()+ }+ })+ (Service{}).startResultHandler(groupCtx, group, &types.SubtitleTaskStepParam{TaskPtr: task}, 1, []float64{0, 1}, make([]AudioSegment, 1), split, transcribe, transcriptProgress, transcribed, translate, translationProgress, translated, pendingSplit)+ if err := group.Wait(); err != nil {+ t.Fatalf("audio progress handler failed: %v", err)+ }+ if waiting.Phase != "translating_audio" || waiting.Percent != 52 || waiting.Completed != 0 || waiting.Total != 1 {+ t.Fatalf("translation wait progress = %+v", waiting)+ }+}