mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
review(stt-xai): address cetej's nits
- Replace hardcoded 'fr' default with DEFAULT_LOCAL_STT_LANGUAGE ('en')
— removes locale leak, matches other providers
- Drop redundant default=True on is_truthy_value (dict .get already defaults)
- Update auto-detect comment to include 'xai' in the chain
- Fix docstring: 21 languages (match PR body + actual xAI API)
- Update test_sends_language_and_format to set HERMES_LOCAL_STT_LANGUAGE=fr
explicitly, since default is no longer 'fr'
All 18 xAI STT tests pass locally.
This commit is contained in:
parent
18b29b124a
commit
d8cc85dcdc
2 changed files with 10 additions and 5 deletions
|
|
@ -1109,6 +1109,9 @@ class TestTranscribeXAI:
|
||||||
|
|
||||||
def test_sends_language_and_format(self, monkeypatch, sample_ogg, mock_xai_http_module):
|
def test_sends_language_and_format(self, monkeypatch, sample_ogg, mock_xai_http_module):
|
||||||
monkeypatch.setenv("XAI_API_KEY", "xai-test-key")
|
monkeypatch.setenv("XAI_API_KEY", "xai-test-key")
|
||||||
|
# Explicitly set language via env to exercise the override chain
|
||||||
|
# (config > env > DEFAULT_LOCAL_STT_LANGUAGE)
|
||||||
|
monkeypatch.setenv("HERMES_LOCAL_STT_LANGUAGE", "fr")
|
||||||
|
|
||||||
mock_response = MagicMock()
|
mock_response = MagicMock()
|
||||||
mock_response.status_code = 200
|
mock_response.status_code = 200
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ Provides speech-to-text transcription with six providers:
|
||||||
- **openai** (paid) — OpenAI Whisper API, requires ``VOICE_TOOLS_OPENAI_KEY``.
|
- **openai** (paid) — OpenAI Whisper API, requires ``VOICE_TOOLS_OPENAI_KEY``.
|
||||||
- **mistral** — Mistral Voxtral Transcribe API, requires ``MISTRAL_API_KEY``.
|
- **mistral** — Mistral Voxtral Transcribe API, requires ``MISTRAL_API_KEY``.
|
||||||
- **xai** — xAI Grok STT API, requires ``XAI_API_KEY``. High accuracy,
|
- **xai** — xAI Grok STT API, requires ``XAI_API_KEY``. High accuracy,
|
||||||
Inverse Text Normalization, diarization, 26 languages.
|
Inverse Text Normalization, diarization, 21 languages.
|
||||||
|
|
||||||
Used by the messaging gateway to automatically transcribe voice messages
|
Used by the messaging gateway to automatically transcribe voice messages
|
||||||
sent by users on Telegram, Discord, WhatsApp, Slack, and Signal.
|
sent by users on Telegram, Discord, WhatsApp, Slack, and Signal.
|
||||||
|
|
@ -256,7 +256,7 @@ def _get_provider(stt_config: dict) -> str:
|
||||||
|
|
||||||
return provider # Unknown — let it fail downstream
|
return provider # Unknown — let it fail downstream
|
||||||
|
|
||||||
# --- Auto-detect (no explicit provider): local > groq > openai > mistral -
|
# --- Auto-detect (no explicit provider): local > groq > openai > mistral > xai -
|
||||||
|
|
||||||
if _HAS_FASTER_WHISPER:
|
if _HAS_FASTER_WHISPER:
|
||||||
return "local"
|
return "local"
|
||||||
|
|
@ -614,10 +614,12 @@ def _transcribe_xai(file_path: str, model_name: str) -> Dict[str, Any]:
|
||||||
language = str(
|
language = str(
|
||||||
xai_config.get("language")
|
xai_config.get("language")
|
||||||
or os.getenv("HERMES_LOCAL_STT_LANGUAGE")
|
or os.getenv("HERMES_LOCAL_STT_LANGUAGE")
|
||||||
or "fr"
|
or DEFAULT_LOCAL_STT_LANGUAGE
|
||||||
).strip()
|
).strip()
|
||||||
use_format = is_truthy_value(xai_config.get("format", True), default=True)
|
# .get("format", True) already defaults to True when the key is absent;
|
||||||
use_diarize = is_truthy_value(xai_config.get("diarize", False), default=False)
|
# is_truthy_value only normalizes truthy/falsy strings from config.
|
||||||
|
use_format = is_truthy_value(xai_config.get("format", True))
|
||||||
|
use_diarize = is_truthy_value(xai_config.get("diarize", False))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue