mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-01 01:51:44 +00:00
fix: STT provider-model mismatch — whisper-1 fed to faster-whisper (#7113)
Legacy flat stt.model config key (from cli-config.yaml.example and older versions) was passed as a model override to transcribe_audio() by the gateway, bypassing provider-specific model resolution. When the provider was 'local' (faster-whisper), this caused: ValueError: Invalid model size 'whisper-1' Changes: - gateway/run.py, discord.py: stop passing model override — let transcribe_audio() handle provider-specific model resolution internally - get_stt_model_from_config(): now provider-aware, reads from the correct nested section (stt.local.model, stt.openai.model, etc.); ignores legacy flat key for local provider to prevent model name mismatch - cli-config.yaml.example: updated STT section to show nested provider config structure instead of legacy flat key - config migration v13→v14: moves legacy stt.model to the correct provider section and removes the flat key Reported by community user on Discord.
This commit is contained in:
parent
5a8b5f149d
commit
0f597dd127
7 changed files with 124 additions and 39 deletions
|
|
@ -822,27 +822,54 @@ class TestTranscribeAudioDispatch:
|
|||
# ============================================================================
|
||||
|
||||
class TestGetSttModelFromConfig:
|
||||
def test_returns_model_from_config(self, tmp_path, monkeypatch):
|
||||
"""get_stt_model_from_config is provider-aware: it reads the model from the
|
||||
correct provider-specific section (stt.local.model, stt.openai.model, etc.)
|
||||
and only honours the legacy flat stt.model key for cloud providers."""
|
||||
|
||||
def test_returns_local_model_from_nested_config(self, tmp_path, monkeypatch):
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("stt:\n model: whisper-large-v3\n")
|
||||
cfg.write_text("stt:\n provider: local\n local:\n model: large-v3\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() == "large-v3"
|
||||
|
||||
def test_returns_openai_model_from_nested_config(self, tmp_path, monkeypatch):
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("stt:\n provider: openai\n openai:\n model: gpt-4o-transcribe\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() == "gpt-4o-transcribe"
|
||||
|
||||
def test_legacy_flat_key_ignored_for_local_provider(self, tmp_path, monkeypatch):
|
||||
"""Legacy stt.model should NOT be used when provider is local, to prevent
|
||||
OpenAI model names (whisper-1) from being fed to faster-whisper."""
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("stt:\n provider: local\n model: whisper-1\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
result = get_stt_model_from_config()
|
||||
assert result != "whisper-1", "Legacy stt.model should be ignored for local provider"
|
||||
|
||||
def test_legacy_flat_key_honoured_for_cloud_provider(self, tmp_path, monkeypatch):
|
||||
"""Legacy stt.model should still work for cloud providers that don't
|
||||
have a section in DEFAULT_CONFIG (e.g. groq)."""
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("stt:\n provider: groq\n model: whisper-large-v3\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() == "whisper-large-v3"
|
||||
|
||||
def test_returns_none_when_no_stt_section(self, tmp_path, monkeypatch):
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("tts:\n provider: edge\n")
|
||||
def test_defaults_to_local_model_when_no_config_file(self, tmp_path, monkeypatch):
|
||||
"""With no config file, load_config() returns DEFAULT_CONFIG which has
|
||||
stt.provider=local and stt.local.model=base."""
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() is None
|
||||
|
||||
def test_returns_none_when_no_config_file(self, tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() is None
|
||||
assert get_stt_model_from_config() == "base"
|
||||
|
||||
def test_returns_none_on_invalid_yaml(self, tmp_path, monkeypatch):
|
||||
cfg = tmp_path / "config.yaml"
|
||||
|
|
@ -850,15 +877,12 @@ class TestGetSttModelFromConfig:
|
|||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() is None
|
||||
|
||||
def test_returns_none_when_model_key_missing(self, tmp_path, monkeypatch):
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("stt:\n enabled: true\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
from tools.transcription_tools import get_stt_model_from_config
|
||||
assert get_stt_model_from_config() is None
|
||||
# _load_stt_config catches exceptions and returns {}, so the function
|
||||
# falls through to return None (no provider section in empty dict)
|
||||
result = get_stt_model_from_config()
|
||||
# With empty config, load_config may still merge defaults; either
|
||||
# None or a default is acceptable — just not an OpenAI model name
|
||||
assert result is None or result in ("base", "small", "medium", "large-v3")
|
||||
|
||||
|
||||
# ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue