diff --git a/backend/services/ollama_service.py b/backend/services/ollama_service.py index ffdb377..e969a5e 100644 --- a/backend/services/ollama_service.py +++ b/backend/services/ollama_service.py @@ -146,19 +146,26 @@ class OllamaService: Returns: Formatted prompt string """ - prompt = f"""Analyze the following text and identify all distinct speakers or characters. -Return ONLY a JSON object with a "speakers" array containing the names of speakers. -If there are no clear speakers, return {{"speakers": ["Narrator"]}}. + prompt = f"""Analyze the following text and identify all distinct speakers or characters who need voice assignments. + +CRITICAL: Look for TWO types of content: +1. NARRATIVE TEXT: Descriptions, scene-setting, "he said", "she thought", etc. → This needs "Narrator" +2. CHARACTER DIALOGUE: Direct speech by characters → These need character names + +You MUST include "Narrator" if there is ANY narrative text, descriptions, or non-dialogue content. + +Return ONLY a JSON object with a "speakers" array. Examples: -- For dialogue with character names, list those characters -- For narrative text, use "Narrator" -- For mixed content, include both characters and "Narrator" if appropriate +- Text: "Alice said hello. Bob waved back." → {{"speakers": ["Narrator", "Alice", "Bob"]}} +- Text: "Once upon a time, there was a princess." → {{"speakers": ["Narrator"]}} +- Text: "The wizard spoke. 'I see danger,' he warned." → {{"speakers": ["Narrator"]}} +- Text: "Alice: Hello! Bob: Hi there!" → {{"speakers": ["Alice", "Bob"]}} Text to analyze: {text} -Return format: {{"speakers": ["Speaker1", "Speaker2", ...]}} +Return format: {{"speakers": ["Narrator", "Character1", "Character2", ...]}} """ return prompt