Using Google’s Speech-to-Text API with Python

Photo by Volodymyr Hryshchenko on Unsplash

Set up Google Cloud services

1. Create Speech-to-Text service

import os
json_path = {your_path}
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]=json_path

2. Verify API setup

3. Create storage

Prepare/Transcribe File

pip install --upgrade google-cloud-speech
pip install --upgrade google-cloud-storage
from google.cloud import speech
from google.cloud import storage

1. Meet file requirements

2. Upload file to storage bucket

3. Transcribe

4. Write transcript to file

5. Delete file from bucket

6. Put it all together

# remove audio file from bucket
delete_blob(bucket, audio_file)

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store