This section demonstrates how to transcribe streaming audio, like the input from a microphone, to text.
Streaming speech recognition allows you to stream audio to Cloud Speech-to-Text and receive a stream speech recognition results in real time as the audio is processed. See also the audio limits for streaming speech recognition requests. Streaming speech recognition is available via gRPC only.
Perform streaming speech recognition on a local file
Below is an example of performing streaming speech recognition on a local audio
file. There is a 10 MB limit on all streaming requests sent to the API. This
limit applies to to both the initial StreamingRecognize request
and the size of each individual message in the stream. Exceeding this limit will
throw an error.
Go
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Go API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Java API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Node.js API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Python API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the Cloud STT reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the Cloud STT reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the Cloud STT reference documentation for Ruby.
While you can stream a local audio file to the Cloud Speech-to-Text API, it is recommended that you perform synchronous or asynchronous audio recognition for batch mode results.
Perform streaming speech recognition on an audio stream
Cloud STT can also perform recognition on streaming, real-time audio.
Here is an example of performing streaming speech recognition on an audio stream received from a microphone:
Go
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Go API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Python API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Java API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
This samples requires you to install SoX and it must be available in your $PATH.
- For Mac OS:
brew install sox. - For most Linux distributions:
sudo apt-get install sox libsox-fmt-all. - For Windows: Download the binaries.
For more on installing and creating a Cloud STT client, refer to Cloud STT Client Libraries.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the Cloud STT reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the Cloud STT reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the Cloud STT reference documentation for Ruby.
Perform endless streaming speech recognition
Here is an example of performing streaming speech recognition on an endless audio stream received from a microphone:
Python
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Python API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Cloud STT, see Cloud STT client libraries. For more information, see the Cloud STT Java API reference documentation.
To authenticate to Cloud STT, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
This sample requires you to install SoX, and it must be available in your $PATH.
- For Mac OS:
brew install sox. - For most Linux distributions:
sudo apt-get install sox libsox-fmt-all. - For Windows: Download the binaries.
For more on installing and creating a Cloud STT client, refer to Cloud STT Client Libraries.
What's next
- Learn how to measure and improve accuracy
Try it for yourself
If you're new to Google Cloud, create an account to evaluate how Cloud STT performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
Try Cloud STT free