mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-22 14:38:11 +02:00
fix: precise TTS word-boundary timing and remove wasted sync calculations
- ffmpeg-service/main.py: replace ffsubsync path with exact word-boundary timing from edge_tts for TTS subtitles. Karaoke styling preserved. - server/services/ttsSync.ts: fix word count to match TTS-cleaned text, remove artificial punctuationPause subtraction, strip punctuation tokens from count. - server/routes/reels.ts: remove redundant ttsSyncService calls in preview/background; word_duration is ignored by Python, these only wasted TTS generations. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ce735dc23
commit
37aba33425
3 files changed
+43
-68
No files matched your search
+2
-22
@@ -350,17 +350,7 @@ reelsRouter.post('/reels/preview', async (req: Request, res: Response) => {
|
||||
console.error('Error fetching watermark configuration', e);
|
||||
}
|
||||
|
||||
// Calculer le word_duration synchronisé si TTS activé
|
||||
let finalWordDuration = wordDuration;
|
||||
if (ttsEnabled && overlayText) {
|
||||
try {
|
||||
const sync = await ttsSyncService.calculateSyncTiming(overlayText, ttsVoice);
|
||||
finalWordDuration = sync.wordDuration;
|
||||
console.log(`🎯 TTS Sync (preview): ${sync.wordCount} mots, ${sync.audioDuration.toFixed(2)}s audio, word_duration=${finalWordDuration.toFixed(3)}s`);
|
||||
} catch (syncErr) {
|
||||
console.warn('⚠️ TTS sync failed (preview), using default word_duration:', syncErr);
|
||||
}
|
||||
}
|
||||
const finalWordDuration = wordDuration;
|
||||
|
||||
// Traiter la vidéo via FFmpeg
|
||||
const result = await ffmpegService.processReelFromUrl(resolveInternalUrl(media.originalUrl), {
|
||||
@@ -593,17 +583,7 @@ async function processReelBackground(
|
||||
console.error('Error fetching watermark configuration', e);
|
||||
}
|
||||
|
||||
// Calculer le word_duration synchronisé si TTS activé
|
||||
let finalWordDuration = wordDuration ?? 0.6;
|
||||
if (ttsEnabled && overlayText && ttsVoice) {
|
||||
try {
|
||||
const sync = await ttsSyncService.calculateSyncTiming(overlayText, ttsVoice);
|
||||
finalWordDuration = sync.wordDuration;
|
||||
console.log(`🎯 TTS Sync (background): ${sync.wordCount} mots, ${sync.audioDuration.toFixed(2)}s audio, word_duration=${finalWordDuration.toFixed(3)}s`);
|
||||
} catch (syncErr) {
|
||||
console.warn('⚠️ TTS sync failed (background), using default word_duration:', syncErr);
|
||||
}
|
||||
}
|
||||
const finalWordDuration = wordDuration ?? 0.6;
|
||||
|
||||
const ffmpegResult = await ffmpegService.processReelFromUrl(resolveInternalUrl(media.originalUrl), {
|
||||
text: overlayText,
|
||||
|
||||
Reference in new issue
Block a user