diff --git a/backend/src/kithara_client.py b/backend/src/kithara_client.py index e1f7670..4440f70 100644 --- a/backend/src/kithara_client.py +++ b/backend/src/kithara_client.py @@ -51,24 +51,24 @@ async def generate_clip(prompt: str, model: str = "lyria-3-clip-preview", durati if block_reason: block_message = data.get("blockReasonMessage", "") logger.warning(f"Google Lyria API blocked: {block_reason} — {block_message}") - return {"success": False, "error": f"Prompt was filtered. Try describing the sound using mood, instruments, and tempo instead of genre names. ({block_message or block_reason})"} + return {"success": False, "error": f"Prompt was filtered by the Lyria API. ({block_message or block_reason}) Try rephrasing your description."} # Extract base64 audio from response # Google Lyria returns parts array: first part may be text (e.g. ""), # audio is in inlineData of a subsequent part. candidates = data.get("candidates", []) if not candidates: - return {"success": False, "error": "Prompt was filtered. Try describing the sound using mood, instruments, and tempo instead of genre names."} + return {"success": False, "error": "Prompt was filtered by the Lyria API. Try rephrasing your description."} # Check finish_reason for blocks finish_reason = candidates[0].get("finishReason", "") if finish_reason == "SAFETY": - return {"success": False, "error": "Prompt was filtered by safety controls. Try rephrasing — describe the sound using mood, instruments, and tempo instead of specific genre or artist names."} + return {"success": False, "error": "Prompt was filtered by safety controls. Try rephrasing your description — avoid specific artist or brand names."} content = candidates[0].get("content", {}) parts = content.get("parts", []) if not parts: - return {"success": False, "error": "No audio was generated. Try rephrasing your prompt — describe the sound using mood, instruments, and tempo."} + return {"success": False, "error": "The Lyria API returned no content. This can happen with certain prompts — try rephrasing or adjusting your description."} # Find the part with inlineData (audio) — not necessarily parts[0] audio_part = None @@ -79,7 +79,7 @@ async def generate_clip(prompt: str, model: str = "lyria-3-clip-preview", durati if audio_part is None: # No audio in any part — likely filtered - return {"success": False, "error": "No audio was generated. Try rephrasing your prompt — describe the sound using mood, instruments, and tempo instead of specific genre names."} + return {"success": False, "error": "The Lyria API accepted the prompt but returned no audio. Try rephrasing your description."} inline_data = audio_part.get("inlineData", {}) mime_type = inline_data.get("mimeType", "")