Transcribe a local file with auto punctuation (beta)

Stay organized with collections Save and categorize content based on your preferences.

Transcribe a local audio file, including auto punctuation.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample


from import speech_v1p1beta1 as speech

client = speech.SpeechClient()

speech_file = "resources/commercial_mono.wav"

with, "rb") as audio_file:
    content =

audio = speech.RecognitionAudio(content=content)
config = speech.RecognitionConfig(
    # Enable automatic punctuation

response = client.recognize(config=config, audio=audio)

for i, result in enumerate(response.results):
    alternative = result.alternatives[0]
    print("-" * 20)
    print(u"First alternative of result {}".format(i))
    print(u"Transcript: {}".format(alternative.transcript))

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.