From aa48859e0e0e767fe5a4d47833d7680fb92a6002 Mon Sep 17 00:00:00 2001 From: Jerjou Cheng Date: Fri, 8 Apr 2016 17:47:26 -0700 Subject: [PATCH 1/2] Add undersscore to speechrest.py for consistency --- speech/api/README.md | 8 ++++---- ...ements-speechrest.txt => requirements-speech_rest.txt} | 0 speech/api/{speechrest.py => speech_rest.py} | 0 speech/api/{speechrest_test.py => speech_rest_test.py} | 2 +- speech/api/speech_streaming_test.py | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) rename speech/api/{requirements-speechrest.txt => requirements-speech_rest.txt} (100%) rename speech/api/{speechrest.py => speech_rest.py} (100%) rename speech/api/{speechrest_test.py => speech_rest_test.py} (96%) diff --git a/speech/api/README.md b/speech/api/README.md index e0c31dab2877..5b381b0c5bd5 100644 --- a/speech/api/README.md +++ b/speech/api/README.md @@ -39,10 +39,10 @@ for more information. ### Install the dependencies -* If you're running the `speechrest.py` sample: +* If you're running the `speech_rest.py` sample: ```sh - $ pip install requirements-speechrest.txt + $ pip install requirements-speech_rest.txt ``` * If you're running the `speech_streaming.py` sample: @@ -53,10 +53,10 @@ for more information. ## Run the example -* To run the `speechrest.py` sample: +* To run the `speech_rest.py` sample: ```sh - $ python speechrest.py resources/audio.raw + $ python speech_rest.py resources/audio.raw ``` You should see a response with the transcription result. diff --git a/speech/api/requirements-speechrest.txt b/speech/api/requirements-speech_rest.txt similarity index 100% rename from speech/api/requirements-speechrest.txt rename to speech/api/requirements-speech_rest.txt diff --git a/speech/api/speechrest.py b/speech/api/speech_rest.py similarity index 100% rename from speech/api/speechrest.py rename to speech/api/speech_rest.py diff --git a/speech/api/speechrest_test.py b/speech/api/speech_rest_test.py similarity index 96% rename from speech/api/speechrest_test.py rename to speech/api/speech_rest_test.py index 8f1d2851bfa5..0204e565ab81 100644 --- a/speech/api/speechrest_test.py +++ b/speech/api/speech_rest_test.py @@ -13,7 +13,7 @@ import re -from speechrest import main +from speech_rest import main def test_main(resource, capsys): diff --git a/speech/api/speech_streaming_test.py b/speech/api/speech_streaming_test.py index e44e613ea437..b5fd89c06897 100644 --- a/speech/api/speech_streaming_test.py +++ b/speech/api/speech_streaming_test.py @@ -53,6 +53,7 @@ def mock_audio_stream(channels, rate, chunk): return mock_audio_stream +# grpc doesn't yet support python3 https://github.com/grpc/grpc/issues/282 @pytest.mark.skipif( sys.version_info >= (3, 0), reason="can't get grpc lib to work in python3") def test_main(resource, monkeypatch, capsys): From 079d5f195d1d6abc1b924d4aad2530add1f3395e Mon Sep 17 00:00:00 2001 From: Jerjou Cheng Date: Fri, 8 Apr 2016 17:48:02 -0700 Subject: [PATCH 2/2] Update README to also explain speech_streaming.py --- speech/api/README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/speech/api/README.md b/speech/api/README.md index 5b381b0c5bd5..bbca28d79b3e 100644 --- a/speech/api/README.md +++ b/speech/api/README.md @@ -1,8 +1,9 @@ -# Google Cloud Speech API Sample (REST API) +# Google Cloud Speech API Samples -This example demos accessing the [Google Cloud Speech API](http://cloud.google.com/speech) -via its REST API. +These examples demo accessing the [Google Cloud Speech API](http://cloud.google.com/speech) +in streaming mode (via its gRPC API) and in non-streaming mode (via its REST +API). ## Prerequisites @@ -30,9 +31,9 @@ downloaded service account credentials before running this example: export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json -If you do not do this, you will see an error that looks something like this when -you run the example script: -`...`. +If you do not do this, the REST api will return a 403. The streaming sample will +just sort of hang silently. + See the [Cloud Platform Auth Guide](https://cloud.google.com/docs/authentication#developer_workflow) for more information. @@ -70,3 +71,7 @@ for more information. The sample will run in a continuous loop, printing the data and metadata it receives from the Speech API, which includes alternative transcriptions of what it hears, and a confidence score. Say "exit" to exit the loop. + + Note that the `speech_streaming.py` sample does not yet support python 3, as + the upstream `grpcio` library's support is [not yet + complete](https://github.com/grpc/grpc/issues/282).