Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.41k stars 2.4k forks source link

[test] Add tests for recognize_whisper_api #776

Open amjadnattouf opened 2 days ago

amjadnattouf commented 2 days ago

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:

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.

amjadnattouf commented 1 day ago

@ftnext could you please check this when you have time?