mac02: building i6h02ml0rin8dfnc3cy3k4d09zv991d1-python3.14-speechrecognition-3.17.0.drv Sourcing python-remove-tests-dir-hook Sourcing python-catch-conflicts-hook.sh Sourcing python-remove-bin-bytecode-hook.sh Sourcing pypa-build-hook Using pypaBuildPhase Sourcing python-runtime-deps-check-hook Using pythonRuntimeDepsCheckHook Sourcing pypa-install-hook Using pypaInstallPhase Sourcing python-imports-check-hook.sh Using pythonImportsCheckPhase Sourcing python-metadata-check-hook.sh Using pythonMetadataCheckPhase Sourcing python-namespaces-hook Sourcing python-catch-conflicts-hook.sh Sourcing pytest-check-hook Using pytestCheckPhase Running phase: unpackPhase unpacking source archive /nix/store/6pq7kyqwxqj7p4v46kh94y3lg07ajphq-source source root is source setting SOURCE_DATE_EPOCH to timestamp 315619200 of file "source/third-party/irstlm-master.zip" Running phase: patchPhase Running phase: updateAutotoolsGnuConfigScriptsPhase Running phase: configurePhase no configure script, doing nothing Running phase: buildPhase Executing pypaBuildPhase Creating a wheel... pypa build flags: --no-isolation --outdir dist/ --wheel * Getting build dependencies for wheel... running egg_info creating SpeechRecognition.egg-info writing SpeechRecognition.egg-info/PKG-INFO writing dependency_links to SpeechRecognition.egg-info/dependency_links.txt writing entry points to SpeechRecognition.egg-info/entry_points.txt writing requirements to SpeechRecognition.egg-info/requires.txt writing top-level names to SpeechRecognition.egg-info/top_level.txt writing manifest file 'SpeechRecognition.egg-info/SOURCES.txt' reading manifest file 'SpeechRecognition.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '*.pyc' found under directory 'speech_recognition' adding license file 'LICENSE.txt' adding license file 'LICENSE-FLAC.txt' writing manifest file 'SpeechRecognition.egg-info/SOURCES.txt' * Building wheel... running bdist_wheel running build running build_py creating build/lib/speech_recognition copying speech_recognition/__init__.py -> build/lib/speech_recognition copying speech_recognition/cli.py -> build/lib/speech_recognition copying speech_recognition/exceptions.py -> build/lib/speech_recognition copying speech_recognition/audio.py -> build/lib/speech_recognition copying speech_recognition/__main__.py -> build/lib/speech_recognition creating build/lib/speech_recognition/recognizers copying speech_recognition/recognizers/google_cloud.py -> build/lib/speech_recognition/recognizers copying speech_recognition/recognizers/pocketsphinx.py -> build/lib/speech_recognition/recognizers copying speech_recognition/recognizers/__init__.py -> build/lib/speech_recognition/recognizers copying speech_recognition/recognizers/google.py -> build/lib/speech_recognition/recognizers copying speech_recognition/recognizers/cohere_api.py -> build/lib/speech_recognition/recognizers copying speech_recognition/recognizers/vosk.py -> build/lib/speech_recognition/recognizers creating build/lib/speech_recognition/recognizers/whisper_local copying speech_recognition/recognizers/whisper_local/__init__.py -> build/lib/speech_recognition/recognizers/whisper_local copying speech_recognition/recognizers/whisper_local/whisper.py -> build/lib/speech_recognition/recognizers/whisper_local copying speech_recognition/recognizers/whisper_local/faster_whisper.py -> build/lib/speech_recognition/recognizers/whisper_local copying speech_recognition/recognizers/whisper_local/base.py -> build/lib/speech_recognition/recognizers/whisper_local creating build/lib/speech_recognition/recognizers/whisper_api copying speech_recognition/recognizers/whisper_api/__init__.py -> build/lib/speech_recognition/recognizers/whisper_api copying speech_recognition/recognizers/whisper_api/groq.py -> build/lib/speech_recognition/recognizers/whisper_api copying speech_recognition/recognizers/whisper_api/openai.py -> build/lib/speech_recognition/recognizers/whisper_api copying speech_recognition/recognizers/whisper_api/base.py -> build/lib/speech_recognition/recognizers/whisper_api copying speech_recognition/version.txt -> build/lib/speech_recognition creating build/lib/speech_recognition/pocketsphinx-data/en-US copying speech_recognition/pocketsphinx-data/en-US/pronounciation-dictionary.dict -> build/lib/speech_recognition/pocketsphinx-data/en-US copying speech_recognition/pocketsphinx-data/en-US/language-model.lm.bin -> build/lib/speech_recognition/pocketsphinx-data/en-US copying speech_recognition/pocketsphinx-data/en-US/LICENSE.txt -> build/lib/speech_recognition/pocketsphinx-data/en-US creating build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/sendump -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/noisedict -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/means -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/README -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/mdef -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/transition_matrices -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/feat.params -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying speech_recognition/pocketsphinx-data/en-US/acoustic-model/variances -> build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model installing to build/bdist.macosx-14.0-arm64/wheel running install running install_lib creating build/bdist.macosx-14.0-arm64/wheel creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition copying build/lib/speech_recognition/__init__.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition/pocketsphinx-data creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition/pocketsphinx-data/en-US copying build/lib/speech_recognition/pocketsphinx-data/en-US/pronounciation-dictionary.dict -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US copying build/lib/speech_recognition/pocketsphinx-data/en-US/language-model.lm.bin -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US copying build/lib/speech_recognition/pocketsphinx-data/en-US/LICENSE.txt -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/sendump -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/noisedict -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/means -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/README -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/mdef -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/transition_matrices -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/feat.params -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/pocketsphinx-data/en-US/acoustic-model/variances -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/pocketsphinx-data/en-US/acoustic-model copying build/lib/speech_recognition/cli.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition/recognizers copying build/lib/speech_recognition/recognizers/google_cloud.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers copying build/lib/speech_recognition/recognizers/pocketsphinx.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers copying build/lib/speech_recognition/recognizers/__init__.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers copying build/lib/speech_recognition/recognizers/google.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition/recognizers/whisper_local copying build/lib/speech_recognition/recognizers/whisper_local/__init__.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_local copying build/lib/speech_recognition/recognizers/whisper_local/whisper.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_local copying build/lib/speech_recognition/recognizers/whisper_local/faster_whisper.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_local copying build/lib/speech_recognition/recognizers/whisper_local/base.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_local creating build/bdist.macosx-14.0-arm64/wheel/speech_recognition/recognizers/whisper_api copying build/lib/speech_recognition/recognizers/whisper_api/__init__.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_api copying build/lib/speech_recognition/recognizers/whisper_api/groq.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_api copying build/lib/speech_recognition/recognizers/whisper_api/openai.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_api copying build/lib/speech_recognition/recognizers/whisper_api/base.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers/whisper_api copying build/lib/speech_recognition/recognizers/cohere_api.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers copying build/lib/speech_recognition/recognizers/vosk.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition/recognizers copying build/lib/speech_recognition/exceptions.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition copying build/lib/speech_recognition/audio.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition copying build/lib/speech_recognition/version.txt -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition copying build/lib/speech_recognition/__main__.py -> build/bdist.macosx-14.0-arm64/wheel/./speech_recognition running install_egg_info running egg_info writing SpeechRecognition.egg-info/PKG-INFO writing dependency_links to SpeechRecognition.egg-info/dependency_links.txt writing entry points to SpeechRecognition.egg-info/entry_points.txt writing requirements to SpeechRecognition.egg-info/requires.txt writing top-level names to SpeechRecognition.egg-info/top_level.txt reading manifest file 'SpeechRecognition.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '*.pyc' found under directory 'speech_recognition' adding license file 'LICENSE.txt' adding license file 'LICENSE-FLAC.txt' writing manifest file 'SpeechRecognition.egg-info/SOURCES.txt' Copying SpeechRecognition.egg-info to build/bdist.macosx-14.0-arm64/wheel/./SpeechRecognition-3.17.0-py3.14.egg-info running install_scripts creating build/bdist.macosx-14.0-arm64/wheel/speechrecognition-3.17.0.dist-info/WHEEL creating '/nix/var/nix/builds/nix-79878-2366018834/source/dist/.tmp-hvbijwtj/speechrecognition-3.17.0-py3-none-any.whl' and adding 'build/bdist.macosx-14.0-arm64/wheel' to it adding 'speech_recognition/__init__.py' adding 'speech_recognition/__main__.py' adding 'speech_recognition/audio.py' adding 'speech_recognition/cli.py' adding 'speech_recognition/exceptions.py' adding 'speech_recognition/version.txt' adding 'speech_recognition/pocketsphinx-data/en-US/LICENSE.txt' adding 'speech_recognition/pocketsphinx-data/en-US/language-model.lm.bin' adding 'speech_recognition/pocketsphinx-data/en-US/pronounciation-dictionary.dict' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/README' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/feat.params' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/mdef' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/means' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/noisedict' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/sendump' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/transition_matrices' adding 'speech_recognition/pocketsphinx-data/en-US/acoustic-model/variances' adding 'speech_recognition/recognizers/__init__.py' adding 'speech_recognition/recognizers/cohere_api.py' adding 'speech_recognition/recognizers/google.py' adding 'speech_recognition/recognizers/google_cloud.py' adding 'speech_recognition/recognizers/pocketsphinx.py' adding 'speech_recognition/recognizers/vosk.py' adding 'speech_recognition/recognizers/whisper_api/__init__.py' adding 'speech_recognition/recognizers/whisper_api/base.py' adding 'speech_recognition/recognizers/whisper_api/groq.py' adding 'speech_recognition/recognizers/whisper_api/openai.py' adding 'speech_recognition/recognizers/whisper_local/__init__.py' adding 'speech_recognition/recognizers/whisper_local/base.py' adding 'speech_recognition/recognizers/whisper_local/faster_whisper.py' adding 'speech_recognition/recognizers/whisper_local/whisper.py' adding 'speechrecognition-3.17.0.dist-info/licenses/LICENSE-FLAC.txt' adding 'speechrecognition-3.17.0.dist-info/licenses/LICENSE.txt' adding 'speechrecognition-3.17.0.dist-info/METADATA' adding 'speechrecognition-3.17.0.dist-info/WHEEL' adding 'speechrecognition-3.17.0.dist-info/entry_points.txt' adding 'speechrecognition-3.17.0.dist-info/top_level.txt' adding 'speechrecognition-3.17.0.dist-info/RECORD' removing build/bdist.macosx-14.0-arm64/wheel Successfully built speechrecognition-3.17.0-py3-none-any.whl Finished creating a wheel... Finished executing pypaBuildPhase Running phase: pythonRuntimeDepsCheckHook Executing pythonRuntimeDepsCheck Checking runtime dependencies for speechrecognition-3.17.0-py3-none-any.whl Finished executing pythonRuntimeDepsCheck Running phase: installPhase Executing pypaInstallPhase Successfully installed speechrecognition-3.17.0-py3-none-any.whl Finished executing pypaInstallPhase Running phase: pythonOutputDistPhase Executing pythonOutputDistPhase Finished executing pythonOutputDistPhase Running phase: fixupPhase checking for references to /nix/var/nix/builds/nix-79878-2366018834/ in /nix/store/z4kcg25498annhg459y9finvg0lcbphd-python3.14-speechrecognition-3.17.0-dist... patching script interpreter paths in /nix/store/z4kcg25498annhg459y9finvg0lcbphd-python3.14-speechrecognition-3.17.0-dist checking for references to /nix/var/nix/builds/nix-79878-2366018834/ in /nix/store/g0rjnafchwdglyfxl47n98wrm5whlq4x-python3.14-speechrecognition-3.17.0... patching script interpreter paths in /nix/store/g0rjnafchwdglyfxl47n98wrm5whlq4x-python3.14-speechrecognition-3.17.0 stripping (with command strip and flags -S) in /nix/store/g0rjnafchwdglyfxl47n98wrm5whlq4x-python3.14-speechrecognition-3.17.0/lib /nix/store/g0rjnafchwdglyfxl47n98wrm5whlq4x-python3.14-speechrecognition-3.17.0/bin Rewriting #!/nix/store/3j0hvszcqcb2vwm5dz0xxfb06cx49k86-python3-3.14.10/bin/python3.14 to #!/nix/store/3j0hvszcqcb2vwm5dz0xxfb06cx49k86-python3-3.14.10 wrapping `/nix/store/g0rjnafchwdglyfxl47n98wrm5whlq4x-python3.14-speechrecognition-3.17.0/bin/sprc'... Executing pythonRemoveTestsDir Finished executing pythonRemoveTestsDir Running phase: installCheckPhase no Makefile or custom installCheckPhase, doing nothing Running phase: pythonCatchConflictsPhase Running phase: pythonRemoveBinBytecodePhase Running phase: pythonImportsCheckPhase Executing pythonImportsCheckPhase Check whether the following modules can be imported: speech_recognition Running phase: pythonMetadataCheckPhase Executing pythonMetadataCheckPhase Running phase: pytestCheckPhase Executing pytestCheckPhase pytest flags: -m pytest --ignore-glob=tests/recognizers/test_vosk.py -k not\ \(test_sphinx_keywords\) ============================= test session starts ============================== platform darwin -- Python 3.14.10, pytest-9.1.1, pluggy-1.7.0 rootdir: /nix/var/nix/builds/nix-79878-2366018834/source configfile: pyproject.toml plugins: anyio-4.15.1, pytest_httpserver-1.1.5, respx-0.23.1 collected 66 items / 1 deselected / 65 selected tests/recognizers/test_cohere_api.py .. [ 3%] tests/recognizers/test_google.py ........ [ 15%] tests/recognizers/test_google_cloud.py .... [ 21%] tests/recognizers/whisper_api/test_groq.py . [ 23%] tests/recognizers/whisper_api/test_openai.py FFF [ 27%] tests/recognizers/whisper_api/test_openai_compatible.py . [ 29%] tests/recognizers/whisper_local/test_faster_whisper.py ssss [ 35%] tests/recognizers/whisper_local/test_whisper.py sss [ 40%] tests/test_audio.py ......................s.ssssssss [ 89%] tests/test_recognition.py ssss..s [100%] =================================== FAILURES =================================== _____________________ test_transcribe_with_openai_whisper ______________________ respx_mock = setenv_openai_api_key = None @respx.mock(assert_all_called=True, assert_all_mocked=True) def test_transcribe_with_openai_whisper(respx_mock, setenv_openai_api_key): respx_mock.post( "https://api.openai.com/v1/audio/transcriptions", headers__contains={"Authorization": "Bearer sk_openai_api_key"}, data__contains={"model": "whisper-1"}, ).mock( return_value=httpx.Response( 200, json={"text": "Transcription by OpenAI Whisper"}, ) ) audio_data = MagicMock(spec=AudioData) audio_data.get_wav_data.return_value = b"audio_data" > actual = openai.recognize(MagicMock(spec=Recognizer), audio_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/recognizers/whisper_api/test_openai.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ speech_recognition/recognizers/whisper_api/openai.py:58: in recognize return openai_recognizer.recognize(audio_data, model, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ speech_recognition/recognizers/whisper_api/base.py:25: in recognize transcript = self.client.audio.transcriptions.create( /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_utils/_utils.py:298: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/resources/audio/transcriptions.py:525: in create return self._post( # type: ignore[return-value] /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_base_client.py:1378: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/audio/transcriptions', params={}, headers={'Content-Type': 'multipart/form-da...{'bearer_auth': True}, synthesize_event_and_data=None, content=None, json_data={'model': 'whisper-1'}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.audio.transcription_text_segment_event.TranscriptionTextSegmentEvent | ope...ent.TranscriptionTextDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx2.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) self._validate_max_retries(max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} custom_auth = self._custom_auth(options.security) if custom_auth is not None: kwargs["auth"] = ( normalize_httpx2_auth(custom_auth) if is_httpx2_sync_client(self._client) else normalize_legacy_httpx_auth(custom_auth) ) if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s", get_http_method_for_logging(request.method)) response = None try: response = self._send_request( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except timeout_exceptions() as err: log.debug("Encountered a timeout exception: %s", type(err).__name__) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except OpenAIError as err: # Propagate OpenAIErrors as-is, without retrying or wrapping in APIConnectionError raise err except request_exceptions() as err: log.debug("Encountered exception: %s", type(err).__name__) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") raise APIConnectionError(request=request) from err log.debug( "HTTP Response: %s %i", get_http_method_for_logging(request.method), response.status_code, ) log.debug("request_id: %s", response.headers.get("x-request-id")) try: response.raise_for_status() except status_exceptions() as err: # thrown on 4xx and 5xx status code log.debug("Encountered an HTTP status error: %i", response.status_code) if remaining_retries > 0 and self._should_retry(err.response): err.response.close() self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=response, ) continue # If the response is streamed then we need to explicitly read the response # to completion before attempting to access the response text. if not err.response.is_closed: err.response.read() log.debug("Re-raising status error") > raise self._make_status_error_from_response(err.response) from None E openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk_opena*****_key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}} /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_base_client.py:1151: AuthenticationError ___________________ test_transcribe_with_specified_language ____________________ respx_mock = setenv_openai_api_key = None @respx.mock(assert_all_called=True, assert_all_mocked=True) def test_transcribe_with_specified_language(respx_mock, setenv_openai_api_key): # https://github.com/Uberi/speech_recognition/issues/681 respx_mock.post( "https://api.openai.com/v1/audio/transcriptions", data__contains={"language": "en"}, ).respond( 200, json={"text": "English transcription"}, ) audio_data = MagicMock(spec=AudioData) audio_data.get_wav_data.return_value = b"english_audio" > actual = openai.recognize( MagicMock(spec=Recognizer), audio_data, language="en" ) tests/recognizers/whisper_api/test_openai.py:54: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ speech_recognition/recognizers/whisper_api/openai.py:58: in recognize return openai_recognizer.recognize(audio_data, model, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ speech_recognition/recognizers/whisper_api/base.py:25: in recognize transcript = self.client.audio.transcriptions.create( /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_utils/_utils.py:298: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/resources/audio/transcriptions.py:525: in create return self._post( # type: ignore[return-value] /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_base_client.py:1378: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/audio/transcriptions', params={}, headers={'Content-Type': 'multipart/form-da...ue}, synthesize_event_and_data=None, content=None, json_data={'model': 'whisper-1', 'language': 'en'}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.audio.transcription_text_segment_event.TranscriptionTextSegmentEvent | ope...ent.TranscriptionTextDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx2.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) self._validate_max_retries(max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} custom_auth = self._custom_auth(options.security) if custom_auth is not None: kwargs["auth"] = ( normalize_httpx2_auth(custom_auth) if is_httpx2_sync_client(self._client) else normalize_legacy_httpx_auth(custom_auth) ) if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s", get_http_method_for_logging(request.method)) response = None try: response = self._send_request( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except timeout_exceptions() as err: log.debug("Encountered a timeout exception: %s", type(err).__name__) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except OpenAIError as err: # Propagate OpenAIErrors as-is, without retrying or wrapping in APIConnectionError raise err except request_exceptions() as err: log.debug("Encountered exception: %s", type(err).__name__) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") raise APIConnectionError(request=request) from err log.debug( "HTTP Response: %s %i", get_http_method_for_logging(request.method), response.status_code, ) log.debug("request_id: %s", response.headers.get("x-request-id")) try: response.raise_for_status() except status_exceptions() as err: # thrown on 4xx and 5xx status code log.debug("Encountered an HTTP status error: %i", response.status_code) if remaining_retries > 0 and self._should_retry(err.response): err.response.close() self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=response, ) continue # If the response is streamed then we need to explicitly read the response # to completion before attempting to access the response text. if not err.response.is_closed: err.response.read() log.debug("Re-raising status error") > raise self._make_status_error_from_response(err.response) from None E openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk_opena*****_key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}} /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_base_client.py:1151: AuthenticationError ____________________ test_transcribe_with_specified_prompt _____________________ respx_mock = setenv_openai_api_key = None @respx.mock(assert_all_called=True, assert_all_mocked=True) def test_transcribe_with_specified_prompt(respx_mock, setenv_openai_api_key): # https://github.com/Uberi/speech_recognition/pull/676 respx_mock.post( "https://api.openai.com/v1/audio/transcriptions", # ref: https://cookbook.openai.com/examples/whisper_prompting_guide data__contains={"prompt": "Glossary: Aimee, Shawn, BBQ"}, ).respond( 200, json={"text": "Prompted transcription"}, ) audio_data = MagicMock(spec=AudioData) audio_data.get_wav_data.return_value = b"audio_data" > actual = openai.recognize( MagicMock(spec=Recognizer), audio_data, prompt="Glossary: Aimee, Shawn, BBQ", ) tests/recognizers/whisper_api/test_openai.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ speech_recognition/recognizers/whisper_api/openai.py:58: in recognize return openai_recognizer.recognize(audio_data, model, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ speech_recognition/recognizers/whisper_api/base.py:25: in recognize transcript = self.client.audio.transcriptions.create( /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_utils/_utils.py:298: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/resources/audio/transcriptions.py:525: in create return self._post( # type: ignore[return-value] /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_base_client.py:1378: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/audio/transcriptions', params={}, headers={'Content-Type': 'multipart/form-da...nd_data=None, content=None, json_data={'model': 'whisper-1', 'prompt': 'Glossary: Aimee, Shawn, BBQ'}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.audio.transcription_text_segment_event.TranscriptionTextSegmentEvent | ope...ent.TranscriptionTextDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx2.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) self._validate_max_retries(max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} custom_auth = self._custom_auth(options.security) if custom_auth is not None: kwargs["auth"] = ( normalize_httpx2_auth(custom_auth) if is_httpx2_sync_client(self._client) else normalize_legacy_httpx_auth(custom_auth) ) if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s", get_http_method_for_logging(request.method)) response = None try: response = self._send_request( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except timeout_exceptions() as err: log.debug("Encountered a timeout exception: %s", type(err).__name__) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except OpenAIError as err: # Propagate OpenAIErrors as-is, without retrying or wrapping in APIConnectionError raise err except request_exceptions() as err: log.debug("Encountered exception: %s", type(err).__name__) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") raise APIConnectionError(request=request) from err log.debug( "HTTP Response: %s %i", get_http_method_for_logging(request.method), response.status_code, ) log.debug("request_id: %s", response.headers.get("x-request-id")) try: response.raise_for_status() except status_exceptions() as err: # thrown on 4xx and 5xx status code log.debug("Encountered an HTTP status error: %i", response.status_code) if remaining_retries > 0 and self._should_retry(err.response): err.response.close() self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=response, ) continue # If the response is streamed then we need to explicitly read the response # to completion before attempting to access the response text. if not err.response.is_closed: err.response.read() log.debug("Re-raising status error") > raise self._make_status_error_from_response(err.response) from None E openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk_opena*****_key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}} /nix/store/91jbfs44n7m7c2nmq5b3994925i5vm1k-python3.14-openai-3.14.1/lib/python3.14/site-packages/openai/_base_client.py:1151: AuthenticationError =============================== warnings summary =============================== speech_recognition/__init__.py:7 /nix/var/nix/builds/nix-79878-2366018834/source/speech_recognition/__init__.py:7: DeprecationWarning: aifc was removed in Python 3.13. Please be aware that you are currently NOT using standard 'aifc', but instead a separately installed 'standard-aifc'. import aifc -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ FAILED tests/recognizers/whisper_api/test_openai.py::test_transcribe_with_openai_whisper - openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorr... FAILED tests/recognizers/whisper_api/test_openai.py::test_transcribe_with_specified_language - openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorr... FAILED tests/recognizers/whisper_api/test_openai.py::test_transcribe_with_specified_prompt - openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorr... ====== 3 failed, 41 passed, 21 skipped, 1 deselected, 1 warning in 55.15s ======