feat(transcription): add language parameter for Groq Whisper STT

This commit is contained in:
flobo3 authored and Xubin Ren committed 2026-04-22 12:41:32 +08:00
1 parent f5b8ee9f78
commit 1826ab44fa
4 files changed
+8 -1

No files matched your search

+4 -1
View File
@@ -48,9 +48,10 @@ class GroqTranscriptionProvider:
Groq offers extremely fast transcription with a generous free tier.
"""
def __init__(self, api_key: str | None = None, api_base: str | None = None):
def __init__(self, api_key: str | None = None, api_base: str | None = None, language: str | None = None):
self.api_key = api_key or os.environ.get("GROQ_API_KEY")
self.api_url = api_base or os.environ.get("GROQ_BASE_URL") or "https://api.groq.com/openai/v1/audio/transcriptions"
self.language = language
async def transcribe(self, file_path: str | Path) -> str:
"""
@@ -78,6 +79,8 @@ class GroqTranscriptionProvider:
"file": (path.name, f),
"model": (None, "whisper-large-v3"),
}
if self.language:
files["language"] = (None, self.language)
headers = {
"Authorization": f"Bearer {self.api_key}",
}