All Speech-to-Text code samples
This page contains code samples for Speech-to-Text. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Transcribe a local file with auto punctuation
Transcribe a local audio file, including auto punctuation.
- Speech-to-Text
- Google Cloud
- Go
- Node JS
- Ruby
- JavaScript
- PHP
- Python
- Java
Asynchronously transcribe an audio file with time offsets
Perform asynchronous transcription including time offsets on an audio file stored in Cloud Storage.
- Google Cloud
- Speech-to-Text
- Node JS
- JavaScript
- Go
- Java
- PHP
- Ruby
- Python
Transcribe audio with profanity filter
This sample demonstrates how to transcribe audio with profanity filter enabled.
- Google Cloud
- Speech-to-Text
- Python
Transcribe a local file using an enhanced speech recognition (beta)
Transcribe a local audio file, where you specify an enhanced model.
- Google Cloud
- Speech-to-Text
- Python
Transcribe streaming audio from a microphone
Transcribe streaming audio from a microphone.
- Google Cloud
- Speech-to-Text
- Go
- Node JS
- Python
- Java
- JavaScript
Transcribe a multi-channel file in Cloud Storage
Transcribe an audio file stored in Cloud Storage that includes more than one channel.
- Speech-to-Text
- Google Cloud
- Ruby
- JavaScript
- Java
- Node JS
- Python
Transcribe audio with model selection (v2)
Transcribe an audio file using the Speech-to-Text API with model selection.
- Speech-to-Text
- Google Cloud
- Python
Transcription of a file in Cloud Storage with diarization
Recognize multiple speakers in an audio file stored in Cloud Storage.
- Speech-to-Text
- Google Cloud
- Java
Transcribe a streaming feed on a local file
Transcribe a streaming audio feed from a microphone on a local file.
- Google Cloud
- Speech-to-Text
- Ruby
- Node JS
- PHP
- Python
- JavaScript
- Java
- Go
Transcription of a local file with diarization
Recognize multiple speakers in a local audio file.
- Google Cloud
- Speech-to-Text
- Java
- Node JS
- Python
- Go
- JavaScript
Transcribe a local file using a transcription model
Transcribe a local audio file using a trained transcription model.
- Google Cloud
- Speech-to-Text
- Python
- JavaScript
- Ruby
- PHP
- Java
- Go
- Node JS
Transcribe a file in Cloud Storage with word-level confidence (beta)
Transcribe an audio file stored in Cloud Storage, returning the confidence level for each word.
- Speech-to-Text
- Google Cloud
- Java
- Python
- JavaScript
- Node JS
Synchronously recognizes punctuation
Performs transcription with automatic punctuation on raw PCM audio data.
- Speech-to-Text
- Google Cloud
- Java
Asynchronously transcribe a local audio file
Perform asynchronous transcription on a local audio file.
- Google Cloud
- Speech-to-Text
- JavaScript
- Ruby
- PHP
- Java
- Go
- Node JS
- Python
Transcribe Word Time Offsets
This sample demonstrates how to transcribe audio with word time offsets using the Speech-to-Text API.
- Google Cloud
- Speech-to-Text
- Python
Transcribe a file with word-level confidence (beta)
Transcribe an audio file, returning the confidence level for each word.
- Speech-to-Text
- Google Cloud
- Java
- Python
- Node JS
- JavaScript
Transcribe a local multi-channel file
Transcribe a local audio file that includes more than one channel.
- Google Cloud
- Speech-to-Text
- JavaScript
- Ruby
- Java
- Python
- Node JS
Transcribe a local multi-channel file (beta)
Transcribe a local audio file that includes more than one channel.
- Google Cloud
- Speech-to-Text
- Node JS
- Python
- JavaScript
- Go
- Java
Transcription with diarization
Identify the different speakers in the audio sample.
- Speech-to-Text
- Google Cloud
- JavaScript
- Java
- Node JS
Make an audio transcription request (beta)
Transcribe a local audio file synchronously.
- Google Cloud
- Speech-to-Text
- Python
Speech-to-Text with spoken punctuation and emojis
This sample demonstrates how to use the Speech-to-Text API to transcribe audio with spoken punctuation and emojis.
- Speech-to-Text
- Google Cloud
- Python
Synchronously transcribe a Cloud Storage file
Perform a synchronous transcription on an audio file stored in Cloud Storage
- Google Cloud
- Speech-to-Text
- Node JS
- JavaScript
- Ruby
- PHP
- Go
- Java
- Python
Streaming speech recognition with punctuation
Performs streaming speech recognition on raw PCM audio data.
- Google Cloud
- Speech-to-Text
- Java
Migrating to the Python client library v0.27: Migration client
Part of the guide for migrating to the Python client library v0.27.
- Google Cloud
- Speech-to-Text
- Python
Asynchronously transcribe an audio file in Cloud Storage
Perform asynchronous transcription on an audio file stored in Cloud Storage.
- Google Cloud
- Speech-to-Text
- Node JS
- JavaScript
- Python
- Ruby
- Go
- Java
- PHP
Transcribe a streaming audio feed
Transcribe a streaming audio feed from a microphone.
- Google Cloud
- Speech-to-Text
- JavaScript
- Java
- Python
- Node JS
Use a custom endpoint with the Speech-to-Text API
This sample shows you how to use a custom endpoint with the Speech-to-Text API. This can be useful if you want to use a Speech-to-Text API endpoint that is located in a different region than your application.
- Google Cloud
- Speech-to-Text
- Python
Transcribe a local file with recognition metadata (beta)
Transcribe a local audio file, including recognition metadata in the response.
- Speech-to-Text
- Google Cloud
- Java
- Python
- Node JS
- JavaScript
Synchronously recognize words
Detects speech in the audio file.
- Google Cloud
- Speech-to-Text
- JavaScript
- Node JS
- Ruby
Transcribe a multi-lingual file in Cloud Storage (beta)
Transcribe an audio file stored in Cloud Storage that includes more than one language.
- Google Cloud
- Speech-to-Text
- JavaScript
- Python
- Java
- Node JS
Synchronously transcribe a local file
Perform synchronous transcription on a local audio file.
- Google Cloud
- Speech-to-Text
- Java
- JavaScript
- Node JS
- Python
- Go
- Ruby
- PHP
Transcription of a file in Cloud Storage with diarization (beta)
Recognize multiple speakers in an audio file stored in Cloud Storage.
- Google Cloud
- Speech-to-Text
- Python
- JavaScript
- Node JS
- Java
- Go
Transcribe a local file with auto punctuation (beta)
Transcribe a local audio file, including auto punctuation.
- Speech-to-Text
- Google Cloud
- Python
Transcribe a local multi-lingual file (beta)
Transcribe a local audio file that includes more than one language.
- Speech-to-Text
- Google Cloud
- Java
- Node JS
- JavaScript
- Python
Transcribe Word-Level Confidence
This sample demonstrates how to transcribe audio with word-level confidence using the Speech-to-Text API.
- Google Cloud
- Speech-to-Text
- Python
Recognize a synchronization request
Loads the audio file from the disk into the request.
- Speech-to-Text
- Google Cloud
- C++
Transcribe a file in Cloud Storage using a transcription model
Transcribe an audio file in Cloud Storage using a trained transcription model.
- Speech-to-Text
- Google Cloud
- Go
- JavaScript
- Node JS
- Java
- Python
Transcribe a multi-channel file in Cloud Storage (beta)
Transcribe an audio file stored in Cloud Storage that includes more than one channel.
- Google Cloud
- Speech-to-Text
- JavaScript
- Node JS
- Java
Transcribe audio with voice activity timeouts
This sample demonstrates how to transcribe audio from a file with voice activity timeouts. It uses the Speech-to-Text API to transcribe the audio and prints the transcript to the console. The sample also prints out speech activity events, such as when speech starts and ends.
- Speech-to-Text
- Google Cloud
- Python
Make an audio transcription request
Transcribe a local audio file synchronously.
- Google Cloud
- Speech-to-Text
- Python
- Go
- Java
- JavaScript
- Node JS
- PHP
Transcribe audio with voice activity events
This sample demonstrates how to transcribe audio from a file into text, and detect speech activity events such as when someone starts or stops speaking.
- Speech-to-Text
- Google Cloud
- Python
Synchronously recognize Cloud Storage
Creates a stub connected to the Speech-to-Text service.
- Speech-to-Text
- Google Cloud
- C++
Transcribe a local file using an enhanced speech recognition model
Transcribe a local audio file, where you specify an enhanced model.
- Speech-to-Text
- Google Cloud
- Ruby
- Java
- Python
- Node JS
- Go
- JavaScript
- PHP
Export Speech-to-Text transcript to Cloud Storage (Beta)
This sample demonstrates how to export a speech-to-text transcript to a Cloud Storage bucket.
- Google Cloud
- Speech-to-Text
- Python