Spaces:
Running on Zero
Running on Zero
feat: whisper-large-v3 primary STT with dedicated key + turbo fallback
Browse files170 unmodified lines17117217317417517664 unmodified lines241242243244245246247248249250251252253254255256257258170 unmodified linesgroq_key = env.get("GROQ_API_KEY") or (env.get("LLM_API_KEY", "") if env.get("LLM_API_KEY", "").startswith("gsk_") else "")gemini_key = env.get("GEMINI_API_KEY") or env.get("GOOGLE_API_KEY") or (env.get("LLM_API_KEY", "") if env.get("LLM_API_KEY", "").startswith(("AIza", "AQ.")) else "")64 unmodified linessuspect_whisper_text: Optional[str] = Noneclient = _client(5.0)# Tier 1: Groq Whisper (wake -> turbo super cepat; command -> large-v3 akurasi maksimal)if groq_key:model_order = (("whisper-large-v3-turbo", "whisper-large-v3")if is_wake_modeelse ("whisper-large-v3", "whisper-large-v3-turbo"))for w_model in model_order:try:resp = await client.post("https://api.groq.com/openai/v1/audio/transcriptions",headers={"Authorization": f"Bearer {groq_key}"},data={"model": w_model,"language": whisper_lang,170 unmodified lines17117217317417517617717817918064 unmodified lines245246247248249250251252253254255256257258259260261262263170 unmodified linesgroq_key = env.get("GROQ_API_KEY") or (env.get("LLM_API_KEY", "") if env.get("LLM_API_KEY", "").startswith("gsk_") else "")groq_primary_stt_key = (env.get("GROQ_PRIMARY_STT_KEY")or "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")gemini_key = env.get("GEMINI_API_KEY") or env.get("GOOGLE_API_KEY") or (env.get("LLM_API_KEY", "") if env.get("LLM_API_KEY", "").startswith(("AIza", "AQ.")) else "")64 unmodified linessuspect_whisper_text: Optional[str] = Noneclient = _client(5.0)# Tier 1: Groq Whisper (primary: whisper-large-v3 + dedicated key; fallback: whisper-large-v3-turbo + GROQ_API_KEY)if groq_primary_stt_key or groq_key:model_attempts = [("whisper-large-v3", groq_primary_stt_key or groq_key),("whisper-large-v3-turbo", groq_key or groq_primary_stt_key),]for w_model, w_key in model_attempts:if not w_key:continuetry:resp = await client.post("https://api.groq.com/openai/v1/audio/transcriptions",headers={"Authorization": f"Bearer {w_key}"},data={"model": w_model,"language": whisper_lang,
llm_chat/audio_routes.py+14-9