mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
fix(tts): surface TTS errors from Python to Node.js logs and DB
- Python: capture tts_error_msg on exception, return in response - Python: log tts_provider, minimax_api_key presence before call - ffmpeg.ts: read tts_error from response, log and return it - reels.ts: store TTS error in post.generationError for visibility
This commit is contained in:
1 parent
211b7dc272
commit
cf20b0a264
3 files changed
+24
-9
No files matched your search
+10
-5
@@ -872,13 +872,15 @@ async def process_reel(request: ReelRequest, x_api_key: str = Header(None)):
|
||||
# 3. Generate TTS (if enabled)
|
||||
has_tts = False
|
||||
tts_clean_text = ""
|
||||
tts_error_msg = None
|
||||
|
||||
if request.tts_enabled and request.text:
|
||||
try:
|
||||
# Clean text for TTS (remove hashtags/emojis)
|
||||
tts_clean_text = clean_text_for_tts(request.text)
|
||||
print(f"🔊 TTS enabled. Original: '{request.text}'")
|
||||
print(f"🔊 TTS cleaned: '{tts_clean_text}'")
|
||||
print(f"🔊 TTS enabled. Provider: {request.tts_provider}, Voice: {request.tts_voice}")
|
||||
print(f"🔊 TTS has minimax_api_key: {bool(request.minimax_api_key)}")
|
||||
print(f"🔊 TTS cleaned: '{tts_clean_text[:80]}...'")
|
||||
|
||||
# Check for male/female voice map (edge_tts only)
|
||||
voice = request.tts_voice
|
||||
@@ -913,12 +915,14 @@ async def process_reel(request: ReelRequest, x_api_key: str = Header(None)):
|
||||
)
|
||||
has_tts = True
|
||||
else:
|
||||
print("❌ TTS audio file missing or empty!")
|
||||
tts_error_msg = "TTS audio file missing or empty after generation"
|
||||
print(f"❌ {tts_error_msg}")
|
||||
else:
|
||||
print("⚠️ TTS text is empty after cleaning, skipping.")
|
||||
tts_error_msg = "TTS text empty after cleaning (hashtags/emojis removed)"
|
||||
print(f"⚠️ {tts_error_msg}")
|
||||
except Exception as e:
|
||||
import traceback
|
||||
|
||||
tts_error_msg = str(e)
|
||||
print(f"❌ Failed to generate TTS: {e}")
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -1247,6 +1251,7 @@ async def process_reel(request: ReelRequest, x_api_key: str = Header(None)):
|
||||
"output_base64": out_b64,
|
||||
"duration": duration,
|
||||
"processing_stats": stats,
|
||||
"tts_error": tts_error_msg,
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -640,6 +640,11 @@ async function processReelBackground(
|
||||
|
||||
console.log(`⏱️ [Background] FFmpeg took ${(Date.now() - startTime) / 1000}s`);
|
||||
|
||||
if (ffmpegResult.ttsError) {
|
||||
console.error(`❌ [Background] TTS FAILED: ${ffmpegResult.ttsError}`);
|
||||
await storage.updatePost(postId, { generationError: `TTS échoué: ${ffmpegResult.ttsError}` });
|
||||
}
|
||||
|
||||
if (!ffmpegResult.success || !ffmpegResult.videoBase64) {
|
||||
throw new Error(ffmpegResult.error || 'Erreur de traitement vidéo FFmpeg');
|
||||
}
|
||||
|
||||
@@ -27,9 +27,10 @@ interface FFmpegReelRequest {
|
||||
|
||||
interface FFmpegReelResponse {
|
||||
success: boolean;
|
||||
output_base64?: string; // Vidéo traitée en base64
|
||||
duration?: number; // Durée de la vidéo en secondes
|
||||
detail?: string; // Message d'erreur si échec
|
||||
output_base64?: string;
|
||||
duration?: number;
|
||||
detail?: string;
|
||||
tts_error?: string;
|
||||
}
|
||||
|
||||
interface FFmpegConfig {
|
||||
@@ -189,7 +190,7 @@ export class FFmpegService {
|
||||
storeName?: string;
|
||||
enableEndingEffect?: boolean;
|
||||
} = {}
|
||||
): Promise<{ success: boolean; videoBase64?: string; duration?: number; error?: string }> {
|
||||
): Promise<{ success: boolean; videoBase64?: string; duration?: number; error?: string; ttsError?: string }> {
|
||||
const config = this.ensureConfigured();
|
||||
|
||||
const requestBody: FFmpegReelRequest = {
|
||||
@@ -262,11 +263,15 @@ export class FFmpegService {
|
||||
};
|
||||
}
|
||||
|
||||
if (data.tts_error) {
|
||||
console.error('❌ TTS failed in Python service:', data.tts_error);
|
||||
}
|
||||
console.log('✅ Reel video processed successfully from URL');
|
||||
return {
|
||||
success: true,
|
||||
videoBase64: data.output_base64,
|
||||
duration: data.duration,
|
||||
ttsError: data.tts_error,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user