Skip to content

Commit

Permalink
feat: Add support for custom Whisper API endpoints with robust key ha…
Browse files Browse the repository at this point in the history
…ndling
  • Loading branch information
mbailey committed Dec 19, 2024
1 parent 9e23254 commit 7891e92
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/basic/test_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ def test_record_and_transcribe_no_api_key():

def test_record_and_transcribe_custom_base_no_key():
with patch("aider.voice.sf", MagicMock()):
voice = Voice()
with patch.dict(os.environ, {"WHISPER_API_BASE": "http://custom.api"}, clear=True):
with pytest.raises(Exception) as exc:
voice.record_and_transcribe()
assert "When using a custom WHISPER_API_BASE" in str(exc.value)
assert "via --api whisper=<key>" in str(exc.value)
with patch("aider.voice.Voice.raw_record_and_transcribe") as mock_record:
voice = Voice()
with patch.dict(os.environ, {"WHISPER_API_BASE": "http://custom.api"}, clear=True):
with pytest.raises(Exception) as exc:
voice.record_and_transcribe()
assert "When using a custom WHISPER_API_BASE" in str(exc.value)
assert "via --api whisper=<key>" in str(exc.value)

def test_record_and_transcribe_custom_base_with_key():
with patch("aider.voice.sf", MagicMock()):
Expand Down

0 comments on commit 7891e92

Please sign in to comment.