Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Add Speech Streaming usage documentation.#2483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -97,6 +97,7 @@ Great Britian. | ||
| transcript: Hello, this is one test | ||
| confidence: 0 | ||
| Example of using the profanity filter. | ||
| .. code-block:: python | ||
| @@ -141,5 +142,69 @@ words to the vocabulary of the recognizer. | ||
| confidence: 0.81 | ||
| Streaming Recognition | ||
| --------------------- | ||
| The :meth:`~google.cloud.speech.Client.stream_recognize` method converts speech | ||
| data to possible text alternatives on the fly. | ||
| .. note:: | ||
| Streaming recognition requests are limited to 1 minute of audio. | ||
| See: https://cloud.google.com/speech/limits#content | ||
| >>> from google.cloud import speech | ||
| >>> from google.cloud.speech.encoding import Encoding | ||
| >>> client = speech.Client() | ||
| >>> with open('hello.flac', 'rb') as content: | ||
| >>> sample = client.sample(content=content.read(), | ||
| ... encoding=Encoding.FLAC, | ||
| ... sample_rate=44100) | ||
| >>> results = client.stream_recognize(sample) | ||
| >>> results[0].is_final | ||
| False | ||
| >>> results[2].is_final | ||
| True | ||
| >>> results[2].alternatives[0].transcript | ||
| hello | ||
| >>> results[2].alternatives[0].confidence | ||
| 0.96976006031 | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| For continuous speech containing more than one word, the ``single_utterance`` | ||
| option should be disabled. | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| See: `Single Utterance`_ | ||
| .. code-block:: python | ||
| >>> sample = client.sample(source_uri='gs://my-bucket/recording.flac', | ||
| ... encoding=Encoding.FLAC, | ||
| ... sample_rate=44100) | ||
| >>> results = client.stream_recognize(sample, single_utterance=False) | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| If you would like interim results to be returned as well as the final results, | ||
| you can set the ``interim_results`` option to ``True``. | ||
| .. code-block:: python | ||
| >>> sample = client.sample(source_uri='gs://my-bucket/recording.flac', | ||
| ... encoding=Encoding.FLAC, | ||
| ... sample_rate=44100) | ||
| >>> results = client.stream_recognize(sample, interim_results=True) | ||
| >>> print results[0].alternatives.transcript | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| 'how' | ||
| >>> print results[0].stability | ||
| 0.00999999977648 | ||
| >>> print results[2].alternatives.transcript | ||
| 'hello' | ||
| >>> print results[2].alternatives.confidence | ||
| 0.96976006031 | ||
| >>> print results[2].is_final | ||
| True | ||
| .. _Single Utterance: https://cloud.google.com/speech/reference/rpc/google.cloud.speech.v1beta1#streamingrecognitionconfig | ||
| .. _sync_recognize: https://cloud.google.com/speech/reference/rest/v1beta1/speech/syncrecognize | ||
| .. _Speech Asynchronous Recognize: https://cloud.google.com/speech/reference/rest/v1beta1/speech/asyncrecognize | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.