fix(voice): anchor SiliconFlow subtitle timeline end to full audio duration - #1268
Merged
harry0703 merged 1 commit intoAug 26, 2026
Merged
Conversation
…ration
siliconflow_tts built its subtitle offsets with an ad-hoc loop that
computed each sentence's duration independently using integer division:
sentence_duration = int(sentence_chars * char_duration)
Accumulated truncation meant the last subtitle always ended a few
100-nanosecond units before the real audio end, leaving a subtitle gap
at the tail of every SiliconFlow-generated video.
The root cause is the same one that was already fixed for all other TTS
providers (gemini_tts, mimo_tts, minimax_tts): use the shared
populate_legacy_submaker_with_full_text helper, which explicitly
anchors the last sentence to audio_duration_100ns.
Also removed the redundant `from moviepy import AudioFileClip` local
import (AudioFileClip is already imported at module level) and wrapped
audio_clip.close() in a finally block so it cannot be skipped on error.
Added a unit test that mocks the HTTP response and AudioFileClip and
asserts the last subtitle offset equals the full audio duration.
Owner
|
Thanks for the fix and the regression test! I rechecked it against the latest main, and the full test suite passes. Merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
siliconflow_ttsbuilt its subtitle offsets with a hand-rolled loop:Accumulated integer truncation across multiple sentences means the last
subtitle always ends a few 100-nanosecond units before the actual audio
end. Users see a subtitle gap at the tail of every SiliconFlow-narrated
video.
Fix
Replaced the ad-hoc loop with
populate_legacy_submaker_with_full_text,the shared helper that all other providers (
gemini_tts,mimo_tts,minimax_tts) already use. It explicitly anchors the last subtitle entryto the real
audio_duration_100ns, eliminating the truncation gap.Also removed a redundant local
from moviepy import AudioFileClipimport(already imported at module level) and wrapped
audio_clip.close()in afinallyblock so the handle is always released.Tests
Added a unit test that mocks the HTTP response and
AudioFileClip,calls
siliconflow_ttswith a multi-sentence script, and asserts thatoffsets[-1][1] == int(audio_duration_seconds * 10_000_000).