From fb3c3c7c05f8a5b16ff7c78c5f0590a7464c8e20 Mon Sep 17 00:00:00 2001 From: Kagamine Rin Date: Sun, 31 May 2026 11:01:08 -0400 Subject: [PATCH] fix: soften Lyria API error messages Error messages no longer over-attribute failures to user prompt phrasing. The Lyria API has strict/loose constraints we haven't fully mapped yet, so blaming the user's prompt when the API silently returns no audio is misleading. Updated messages to acknowledge the API as the source. --- backend/src/kithara_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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", "")