diff --git a/README.rst b/README.rst index 522777b7..da70104d 100644 --- a/README.rst +++ b/README.rst @@ -155,9 +155,13 @@ Google Cloud Speech Library for Python (for Google Cloud Speech-to-Text API user ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The library `google-cloud-speech `__ is **required if and only if you want to use Google Cloud Speech-to-Text API** (``recognizer_instance.recognize_google_cloud``). - You can install it with :command:`python3 -m pip install SpeechRecognition[google-cloud]`. -(ref: `official installation instructions `__) +(ref: `official installation instructions `__) + +**Prerequisite**: Create local authentication credentials for your Google account + +* `Before you begin (Transcribe speech to text by using client libraries) `__ +* Detail: `User credentials (Set up ADC for a local development environment) `__ Currently only `V1 `__ is supported. (`V2 `__ is not supported) diff --git a/speech_recognition/recognizers/google_cloud.py b/speech_recognition/recognizers/google_cloud.py index 122104fa..56489ea7 100644 --- a/speech_recognition/recognizers/google_cloud.py +++ b/speech_recognition/recognizers/google_cloud.py @@ -1,6 +1,5 @@ from __future__ import annotations -import os from urllib.error import URLError from speech_recognition.audio import AudioData @@ -42,8 +41,6 @@ def recognize( assert isinstance( audio_data, AudioData ), "``audio_data`` must be audio data" - if credentials_json_path is None: - assert os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") is not None assert isinstance(language, str), "``language`` must be a string" assert preferred_phrases is None or all( isinstance(preferred_phrases, (type(""), type(""))) diff --git a/tests/recognizers/test_google_cloud.py b/tests/recognizers/test_google_cloud.py index 340bda94..bd22961b 100644 --- a/tests/recognizers/test_google_cloud.py +++ b/tests/recognizers/test_google_cloud.py @@ -15,11 +15,7 @@ @patch("google.cloud.speech.SpeechClient") -def test_transcribe_with_google_cloud_speech(SpeechClient, monkeypatch): - monkeypatch.setenv( - "GOOGLE_APPLICATION_CREDENTIALS", "path/to/credentials.json" - ) - +def test_transcribe_with_google_cloud_speech(SpeechClient): client = SpeechClient.return_value # ref: https://cloud.google.com/speech-to-text/docs/transcribe-gcloud?hl=ja#make_an_audio_transcription_request client.recognize.return_value = RecognizeResponse( @@ -84,11 +80,7 @@ def test_transcribe_with_specified_credentials(SpeechClient): @patch("google.cloud.speech.SpeechClient") -def test_transcribe_show_all(SpeechClient, monkeypatch): - monkeypatch.setenv( - "GOOGLE_APPLICATION_CREDENTIALS", "path/to/credentials.json" - ) - +def test_transcribe_show_all(SpeechClient): client = SpeechClient.return_value client.recognize.return_value = RecognizeResponse( results=[ @@ -151,11 +143,7 @@ def test_transcribe_show_all(SpeechClient, monkeypatch): @patch("google.cloud.speech.SpeechClient") -def test_transcribe_with_specified_api_parameters(SpeechClient, monkeypatch): - monkeypatch.setenv( - "GOOGLE_APPLICATION_CREDENTIALS", "path/to/credentials.json" - ) - +def test_transcribe_with_specified_api_parameters(SpeechClient): client = SpeechClient.return_value client.recognize.return_value = RecognizeResponse( results=[