Skip to content

[test] Add tests for recognize_whisper_api #776

@diota-dev

Description

@diota-dev

Steps to reproduce

  1. To reproduce this issue, add the test cases to the speech_recognition module specifically for error handling in the recognize_whisper_api function.
  2. Run the tests with cases for missing API key, invalid audio data, and missing openai module. Code examples of each scenario are included above.
  3. If necessary, also include an audio file that simulates invalid or unexpected audio data.

Expected behaviour

I expected the recognize_whisper_api function to:

  • Raise a SetupError when the API key is missing.
  • Raise a ValueError when invalid audio data is provided.
  • Raise a SetupError with a specific error message when the openai module is not found.

Actual behaviour

Instead of the expected behavior, the function did not handle one or more of these exceptions correctly (e.g., it failed to detect the missing API key, invalid audio data, or missing openai module). Please refer to the specific test cases for details.

(If any exceptions are thrown during testing, paste the full stack trace here for each case.)

System information

My system is MacOS.
My Python version is 3.12.3.
My Pip version is 24.2.
My SpeechRecognition library version is 3.8.1.
My PyAudio library version is not installed.
My microphones are: ['Microphone 1', 'Microphone 2'].
My working microphones are: ['Microphone 1'].

I installed PocketSphinx from Homebrew.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions