将译制语音重新嵌入原始时间轴:AI 配音中的时长难题
原题Fitting Translated Speech Back Into the Original Timeline: The Duration Problem in AI Dubbing
读前速览
本文探讨 AI 配音流程中的时长不匹配问题:由于不同语言的文本长度和语速存在差异,译制语音往往无法与原始时间轴对齐;为此,文章提出一套多阶段方案,包括计算时长预算、限制幅度的变速处理、受长度约束的重新翻译,以及人工审核。
由于不同语言的文本长度和语速存在差异,译制语音的时长会与原始时间轴不匹配。
不同语言的文本长度会按不同比例增加或缩短(例如,德语增加 10-35%,日语缩短约 33%),而且语速也各不相同(德语每秒 6.0 个音节,英语为 6.2 个),导致合成音频与画面线索无法对齐。
时长差异较大时,简单的变速处理会失效;压缩幅度超过 15% 后,音频质量会下降。
基于相位声码器或 WSOLA 的变速处理,在压缩幅度约为 10% 时效果尚可;超过 15% 后,听感便会变得不自然,因此不适合德语等可能需要调整 20-40% 的语言。
采用受限策略的四阶段流程能够有效解决时长不匹配问题。
该方案包括:(1)根据下一段语音的起始时间和允许的余量计算时长预算;(2)进行上限为 12% 的轻度变速;(3)在音节长度约束和术语表一致性要求下重新翻译;(4)对仍然超时的片段进行人工审核。
时长超限的第 95 百分位数是衡量用户满意度最可靠的指标。
如果视频的 synth_dur/budget 第 95 百分位数低于 1.0,用户很少会投诉;若高于 1.15,几乎总会引发问题,因为用户会记住那个溢出到场景切换之后的句子。
德语最需要人工介入,因此是配音工具的重要测试案例。
应用完整流程后,德语仍有约 25% 的片段需要人工审核;日语和普通话则无需人工审核,西班牙语和法语仅约 10% 的片段需要审核。这凸显了在具有挑战性的语言上进行测试的重要性。
完整摘要
AI 配音流程面临一个关键的时间安排问题:由于不同语言的文本长度和语速各异,译制语音片段往往无法适配原视频的时间轴。例如,德语的字符数会增加 10-35%,语速也较慢(每秒 6.0 个音节),导致片段时长最多比原文长 40%。直接对音频进行变速的简单方案,在失真超过 10-15% 后就会失效。作者介绍了一套四阶段流程:(1)根据下一段语音的起始时间,而非片段结束时间,计算时长预算,并考虑静音间隔;(2)进行轻度变速,幅度上限为 12%;(3)使用术语表确保译法一致,并在音节长度约束下重新翻译片段;(4)将仍然存在时长不匹配的片段标记出来,交由人工审核。系统将时长超限的第 95 百分位数作为关键指标,结果发现德语最常需要人工介入。实践经验包括:根据语音起始时间计算时长预算、将说话人切换点视为不可逾越的边界,以及避免只用日语这类简单案例进行调优。
每个搭建 AI 配音流水线的人,到了第二周都会遇到同一个难题。ASR 能正常工作,翻译读起来也不错,TTS 听起来像原说话人。可当你把合成的德语音轨叠到原视频上时,说话人的嘴都闭上 1.3 秒了,配音还在继续,而下一句已经叠上来了。Everyone who builds an AI dubbing pipeline hits the same wall in week two. The ASR works, the translation reads fine, the TTS sounds like the speaker. Then you lay the synthesized German over the original video and it is still talking 1.3 seconds after the speaker’s mouth closed, and the next line starts on top of it.
这篇文章讲的是那道壁垒。不是语音模型,也不是翻译模型,而是两者之间那一步——很少有人谈起:如何处理译文片段自然口语时长不合适的问题,让它在原片段结束的时间点结束。在 AI Video Translator,这一步经过了四次重写,才终于不再引发支持工单;而最终版本比第一个版本更朴实。This post is about that wall. Not the voice model, not the translation model, but the step between them that nobody writes about: taking a translated segment whose natural spoken duration is wrong and making it land where the original did. At AI Video Translator this step went through four rewrites before it stopped generating support tickets, and the final version is less clever than the first one.
https://ai-video-translator.com/https://ai-video-translator.com/
为什么这些时长一开始就不对Why the durations are wrong in the first place
译文的长度与原文不同。按字符数计算,英语译成德语通常会扩长 10% 到 35%,译成西班牙语会扩长 15% 到 25%,译成法语会扩长 15% 到 20%,而译成日语和中文则会缩短三分之一或更多。语速又会对这一情况产生调节:说西班牙语和日语的人每秒大约发出 7.8 个音节,英语约为 6.2 个,德语约为 6.0 个。因此,西班牙语译文长度的增加会部分抵消,日语译文长度的缩减几乎会被完全抵消,而德语则会受到双重影响:内容更多,语速更慢。Translated text is a different length from the source. By character count, English to German typically expands 10 to 35 percent, Spanish 15 to 25, French 15 to 20, while Japanese and Chinese contract by a third or more. Speech rate then modulates this: Spanish and Japanese speakers produce around 7.8 syllables per second, English about 6.2, German about 6.0. So Spanish expansion partly cancels out, Japanese contraction almost fully cancels out, and German gets hit twice: more material and a slower rate.
实际结果是:一个 4.0 秒的英语片段,经 TTS 转换后,日语大约为 4.0 到 4.4 秒,西班牙语为 4.3 到 4.8 秒,德语为 4.8 到 5.6 秒。这并不是缺陷,而是这些语言本身的特性。The practical result: a 4.0 s English segment comes back from TTS as roughly 4.0 to 4.4 s in Japanese, 4.3 to 4.8 s in Spanish, and 4.8 to 5.6 s in German. Nothing about that is a defect. It is what the languages do.
简单粗暴的修复方法及其失败原因The naive fix and why it fails
每个人首先会做的事:The first thing everyone does:
python ratio = target_duration / synthesized_duration audio = time_stretch(audio, ratio) # 相位声码器 / WSOLApython
ratio = target_duration / synthesized_duration
audio = time_stretch(audio, ratio) # phase vocoder / WSOLA
把每个片段都拉伸到原本分配的时长。压缩幅度在约 10% 以内时,这种方法还行。压缩幅度在 10% 到 15% 之间时,听众会察觉不对劲,尽管说不出具体哪里不对。超过 15% 后,配音听起来就像广播广告结尾那种法律免责声明。德语碰上难处理的台词时,需要压缩 20% 到 40%,因此这种简单粗暴的修补办法会让德语配音完全无法使用,尽管用日语测试片段时听起来一切正常。如果你的测试集只有日语,你就会把它发布出去,然后等用户来告诉你问题。Stretch every segment to its original slot. It works up to about a 10 percent compression. Between 10 and 15 percent listeners notice something is off even if they cannot say what. Beyond 15 percent the dub sounds like legal disclaimers at the end of a radio ad. German needs 20 to 40 percent on a bad line, so the naive fix produces unusable German while looking fine on Japanese test clips. If your test set is Japanese, you will ship this and find out from users.
最终版本的功能What the final version does
当前采用的是预算与回退链式方案。每个片段都带有一个根据原始内容推导出的时间预算,并按对结果的损害程度依次尝试四种策略。The current approach is a budget-and-fallback chain. Each segment carries a timing budget derived from the original, and four strategies are tried in order of how much they damage the result.
- 计算实际预算,而不是片段时长Compute the real budget, not the segment duration
原始片段从 t_start 延续到 t_end,但说话者不一定会在 t_end 时立即再次开口。片段之后通常会有一段静音:一次呼吸、一处剪辑,或是下一句话开始前的停顿。只要这段静音属于同一位说话者,它就是可用的空闲时间。The original segment runs from t_start to t_end, but the speaker does not necessarily start talking again at t_end. There is usually silence after it: a breath, a cut, a pause before the next sentence. That silence is free time, as long as it belongs to the same speaker.
python def budget(seg, next_seg, speaker_turn_end): hard_end = min(next_seg.start, speaker_turn_end) slack = hard_end - seg.end return seg.duration + min(slack, MAX_SPILL) # MAX_SPILL 约为 0.6 秒python
def budget(seg, next_seg, speaker_turn_end):
hard_end = min(next_seg.start, speaker_turn_end)
slack = hard_end - seg.end
return seg.duration + min(slack, MAX_SPILL) # MAX_SPILL ~ 0.6 s
有两个细节很重要。第一,要限制溢出时长;如果一段台词整整晚了一秒,即使没有和其他内容撞上,听起来也会不对,因为观众看得到说话者的嘴停了下来。第二,说话者轮次的边界是一道不可逾越的墙。只有一位说话者时,你可以借用任何停顿;但有两位说话者时,A 的台词结束后的停顿可能是 B 开始说话前的引入,借用这段停顿会让合成的两种声音发生重叠,而原始音频里从未如此。Two details that mattered. First, cap the spill; a line that drifts a full second late feels wrong even if nothing collides with it, because the viewer sees the mouth stop. Second, the speaker-turn boundary is a hard wall. With one speaker you can borrow any pause. With two, the pause after speaker A’s line may be the lead-in to speaker B’s line, and borrowing it makes the two synthesized voices overlap where the originals never did.
- 轻微时间拉伸,设定上限 python MAX_STRETCH = 1.12 needed = synth_dur / budget if needed <= MAX_STRETCH: return time_stretch(audio, 1 / needed)Mild time stretch, bounded python MAX_STRETCH = 1.12 needed = synth_dur / budget if needed <= MAX_STRETCH: return time_stretch(audio, 1 / needed)
12% 的上限较为保守。这也是我们自己的听音测试开始无法就语音是否“还不错”达成一致的临界点,因此自动处理流程会在这里停止。A 12 percent ceiling is conservative. It is also the point past which our own listening tests stopped agreeing on whether the voice was “fine”, so it is where the automatic path stops.
- 根据长度目标重新翻译Re-translate against a length target
这是提升空间最大的一种策略,也是大多数流水线会跳过的策略,因为它要求翻译步骤和时序步骤彼此协作。This is the strategy with the most headroom and the one most pipelines skip because it means the translation step and the timing step have to talk to each other.
当某个片段超出延展上限时,我们会在相同上下文的基础上再次调用翻译模型,并附加一项约束:目标译文不得超过 N 个音节(对于音节计数不可靠的语言,则以字符数计),且应优先保留含义,而非措辞。N 根据时长预算和该语言的语速确定:When a segment exceeds the stretch ceiling, we call the translation model again with the same context plus a constraint: the target rendering should be at most N syllables (or characters, for languages where syllable counting is unreliable) and should preserve meaning over phrasing. N is derived from the budget and the language’s speech rate:
python syllable_rate = {"de": 5.97, "en": 6.19, "es": 7.82, "fr": 7.18, "ja": 7.84} max_syllables = int(budget * syllable_rate[lang] * 0.95)python
syllable_rate = {"de": 5.97, "en": 6.19, "es": 7.82, "fr": 7.18, "ja": 7.84}
max_syllables = int(budget * syllable_rate[lang] * 0.95)
模型很擅长这种处理。“我们现在来看看这在实践中是如何运作的”会变成“现在我们来看看它是怎么运作的。”意思保留了下来,句子也更简洁。我们最多允许进行两次重译,并逐步收紧预算;之后就停止,因为第三次尝试开始丢失信息。The model is good at this. “We’re now going to take a look at how this works in practice” becomes “Now let’s see how this works.” The meaning survives and the line fits. We allow at most two re-translation attempts with tightening budgets; after that we stop, because the third attempt starts dropping information.
有一点需要注意:单独重新翻译某一行,可能会破坏它与周围行的一致性(同一个术语在长版本和短版本中译法不同)。这里也会应用确保全文术语统一的术语表层,而且重新翻译时传入的上下文窗口与第一轮翻译时相同。One subtlety: re-translating a single line in isolation can break consistency with the lines around it (a term rendered one way in the long version and another way in the short one). The glossary layer that pins fixed terms across the whole document also applies here, and the re-translation call gets the same surrounding-context window the first pass got.
- 将其标记出来,交由人工处理。Flag it for a human
如果重新翻译并适度拉伸后,这一行仍然放不下,审核界面就会标出超出的时长,用户可以修改文本并仅对这一行重新配音。计费方式如下:只对一行重新配音,费用按新生成语音的秒数计算,而不是按完整视频渲染收费,因为如果修复一行的成本和制作整条视频一样,就没人会去修了。If the line still does not fit after re-translation plus mild stretch, it gets marked in the review UI with the overrun amount, and the user can edit the text and re-voice just that line. The billing follows: re-voicing one line costs seconds of new speech, not a full render, because if fixing a line costs the same as the whole video nobody fixes lines.
顺序才是关键。拉伸成本低,但有上限。重新翻译从音频角度来说是免费的,而且调整空间最大。人工编辑是最后一道保障。这个流程的第一个版本把顺序弄反了(能拉多狠就拉多狠,然后放弃),而第四个版本就是上面那个。The order is the point. Stretch is cheap and bounded. Re-translation is free in audio terms and has the most range. Human editing is the backstop. The first version of this pipeline did them in the wrong order (stretch as hard as needed, then give up) and the fourth version is the one above.
对其进行测量Measuring it
最能反映用户投诉情况的指标,不是平均超时量,而是应用所有自动策略后,每个视频的 synth_dur / budget 的第 95 百分位数。p95 低于 1.0 的视频几乎不会引发时长方面的投诉。p95 高于 1.15 的视频几乎总会引发投诉,即使平均值看起来还不错,因为观众记住的往往是那句延伸到场景切换之后的台词。The metric that tracks user complaints best is not average overrun but the 95th percentile of synth_dur / budget per video, after all automatic strategies. A video with a p95 under 1.0 almost never gets a timing complaint. A video with p95 above 1.15 almost always does, even if the mean looks fine, because the viewer remembers the one line that spilled over the scene cut.
按我们内容组合中的各语言来看,经过完整流程后,大多数日语和普通话片段都无需重新翻译;西班牙语和法语约每十个片段需要重译一个,德语则约每四个需要重译一个。德语仍是需要人工介入的语言;如果要评估其他人的配音工具,我会首先测试德语。Per language on our content mix, after the full chain: Japanese and Mandarin need no re-translation on most segments; Spanish and French need it on roughly one segment in ten; German on roughly one in four. German remains the language where the human step gets used, and it is the language I would test first if I were evaluating anyone else’s dubbing tool.
如果能回到一开始,我会告诉自己这些:从下一段语音开始的时间点计算时长预算,而不是从当前片段的结尾算。大部分可用时间都在停顿里。从第一天起就把说话人边界当作不可逾越的界限,即使目前只支持一位说话人。按时长限制重新翻译,是最关键的杠杆。把机器翻译步骤接好,让它能接收时长预算。别用日语来调优。日语是个简单案例,会误导你。逐行向用户显示超时情况。他们修正那两行关键内容的速度,远比你调优模型快得多。Things I’d tell myself at the start
Build the budget from the next speech onset, not the segment end. Most of the free time is in the pauses.
Treat speaker boundaries as walls from day one, even if you only support one speaker today.
Length-constrained re-translation is the big lever. Wire the MT step so it can be called with a budget.
Don’t tune on Japanese. It is the easy case and it will lie to you.
Expose overruns to the user per line. They will fix the two lines that matter far faster than you can tune the model to.
面向用户的版本在这里,背后是 W3C 和里昂的语速数据:The user-facing version of this, with the W3C and Lyon speech-rate numbers behind it, is here:
https://ai-video-translator.com/blog/why-ai-dubs-run-longhttps://ai-video-translator.com/blog/why-ai-dubs-run-long