diff --git a/ai-hub/app/core/providers/tts/gemini.py b/ai-hub/app/core/providers/tts/gemini.py index 8e6e32b..617c3df 100644 --- a/ai-hub/app/core/providers/tts/gemini.py +++ b/ai-hub/app/core/providers/tts/gemini.py @@ -39,8 +39,19 @@ def __init__(self, api_key: str, model_name: str = "", voice_name: str = "Kore", **kwargs): from app.config import settings - raw_model = model_name or settings.TTS_MODEL_NAME + raw_model = model_name or settings.TTS_MODEL_NAME or "models/gemini-1.5-flash" + + # Ensure raw_model is a string to prevent 'NoneType' attribute errors + if not isinstance(raw_model, str): + raw_model = "models/gemini-1.5-flash" + model_id = raw_model.split("/")[-1] + + # Strip redundant '-tts' suffix if present (common typo) + if model_id.endswith("-tts"): + model_id = model_id[:-4] + + self.model_name = model_id # Route to Vertex AI ONLY when the key is a Vertex service-account key (starting with "AQ.") # AI Studio keys start with "AIza" and must use the generativelanguage endpoint.