mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
fix tts and texte on vidéo
This commit is contained in:
1 parent
a512084f1b
commit
23abe41903
4 files changed
+26
-1
No files matched your search
@@ -66,6 +66,7 @@ export default function NewReel() {
|
||||
const [musicVolume, setMusicVolume] = useState([25]);
|
||||
const [ttsEnabled, setTtsEnabled] = useState(false);
|
||||
const [ttsVoice, setTtsVoice] = useState("female");
|
||||
const [drawText, setDrawText] = useState(true);
|
||||
|
||||
// État audio preview
|
||||
const [isPlaying, setIsPlaying] = useState<string | null>(null);
|
||||
@@ -310,6 +311,7 @@ export default function NewReel() {
|
||||
musicVolume: musicVolume[0] / 100,
|
||||
ttsEnabled,
|
||||
ttsVoice,
|
||||
drawText,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -697,6 +699,17 @@ export default function NewReel() {
|
||||
rows={4}
|
||||
/>
|
||||
|
||||
<div className="flex items-center space-x-2 mt-4">
|
||||
<Switch
|
||||
id="draw-text"
|
||||
checked={drawText}
|
||||
onCheckedChange={setDrawText}
|
||||
/>
|
||||
<Label htmlFor="draw-text" className="font-medium cursor-pointer">
|
||||
Afficher le texte sur la vidéo
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center space-x-2 mt-4">
|
||||
<Switch
|
||||
id="tts-mode"
|
||||
|
||||
@@ -34,6 +34,7 @@ class ReelRequest(BaseModel):
|
||||
music_volume: float = 0.25
|
||||
tts_enabled: bool = False
|
||||
tts_voice: str = "fr-FR-VivienneNeural"
|
||||
draw_text: bool = True
|
||||
|
||||
|
||||
def clean_text_for_tts(text: str) -> str:
|
||||
@@ -155,7 +156,8 @@ async def process_reel(request: ReelRequest, x_api_key: str = Header(None)):
|
||||
# Text Overlay
|
||||
# If TTS is enabled, we use the generated VTT subtitles for perfect sync
|
||||
# If not, we use the standard drawtext
|
||||
if request.text:
|
||||
# Only apply if draw_text is True
|
||||
if request.text and request.draw_text:
|
||||
if has_tts:
|
||||
# Use subtitles filter
|
||||
# Force style to look like TikTok/Reels text (Bottom center, white, black box)
|
||||
|
||||
@@ -187,6 +187,7 @@ reelsRouter.post('/reels/preview', async (req: Request, res: Response) => {
|
||||
wordDuration = 0.6,
|
||||
fontSize = 60,
|
||||
musicVolume = 0.25,
|
||||
drawText = true,
|
||||
} = req.body;
|
||||
|
||||
// Récupérer le média vidéo
|
||||
@@ -217,6 +218,7 @@ reelsRouter.post('/reels/preview', async (req: Request, res: Response) => {
|
||||
wordDuration,
|
||||
fontSize,
|
||||
musicVolume,
|
||||
drawText,
|
||||
});
|
||||
|
||||
if (!result.success) {
|
||||
@@ -255,6 +257,7 @@ reelsRouter.post('/reels', async (req: Request, res: Response) => {
|
||||
wordDuration = 0.6,
|
||||
fontSize = 60,
|
||||
musicVolume = 0.25,
|
||||
drawText = true,
|
||||
} = req.body;
|
||||
|
||||
// Validation
|
||||
@@ -302,6 +305,7 @@ reelsRouter.post('/reels', async (req: Request, res: Response) => {
|
||||
wordDuration,
|
||||
fontSize,
|
||||
musicVolume,
|
||||
drawText,
|
||||
});
|
||||
|
||||
if (!ffmpegResult.success || !ffmpegResult.videoBase64) {
|
||||
|
||||
@@ -16,6 +16,7 @@ interface FFmpegReelRequest {
|
||||
word_duration?: number; // Durée par mot (default: 0.6s)
|
||||
font_size?: number; // Taille police (default: 60)
|
||||
music_volume?: number; // Volume musique (default: 0.25)
|
||||
draw_text?: boolean; // Dessiner le texte sur la vidéo (default: true)
|
||||
}
|
||||
|
||||
interface FFmpegReelResponse {
|
||||
@@ -69,6 +70,7 @@ export class FFmpegService {
|
||||
wordDuration?: number;
|
||||
fontSize?: number;
|
||||
musicVolume?: number;
|
||||
drawText?: boolean;
|
||||
} = {}
|
||||
): Promise<{ success: boolean; videoBase64?: string; duration?: number; error?: string }> {
|
||||
const config = this.ensureConfigured();
|
||||
@@ -83,6 +85,7 @@ export class FFmpegService {
|
||||
word_duration: options.wordDuration ?? 0.6,
|
||||
font_size: options.fontSize ?? 60,
|
||||
music_volume: options.musicVolume ?? 0.25,
|
||||
draw_text: options.drawText ?? true,
|
||||
};
|
||||
|
||||
// Remove undefined values
|
||||
@@ -98,6 +101,7 @@ export class FFmpegService {
|
||||
hasMusicId: !!options.musicId,
|
||||
hasMusicUrl: !!options.musicUrl,
|
||||
hasTTS: options.ttsEnabled,
|
||||
drawText: options.drawText,
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -159,6 +163,7 @@ export class FFmpegService {
|
||||
wordDuration?: number;
|
||||
fontSize?: number;
|
||||
musicVolume?: number;
|
||||
drawText?: boolean;
|
||||
} = {}
|
||||
): Promise<{ success: boolean; videoBase64?: string; duration?: number; error?: string }> {
|
||||
const config = this.ensureConfigured();
|
||||
@@ -173,6 +178,7 @@ export class FFmpegService {
|
||||
word_duration: options.wordDuration ?? 0.6,
|
||||
font_size: options.fontSize ?? 60,
|
||||
music_volume: options.musicVolume ?? 0.25,
|
||||
draw_text: options.drawText ?? true,
|
||||
};
|
||||
|
||||
// Remove undefined values
|
||||
|
||||
Reference in new issue
Block a user