Google Cloud Speech-to-Text API using Client Libraries


Figure 0:\colon Official Quickstart for Google Cloud Speech-to-Text Service

Figur 0呈現Google官方針對使用「Client Libraries方式」呼叫「Speech-to-Text API」的基本操作。

安裝Google speech-to-text (使用python語言)

  1. Setup a GCP Console Project
    • Create or select project
    • Enable Google Speech-to-Text API for that project
    • Create a service account
    • Download a private key as JSON
  2. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file
    export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
    
  3. Install and initialize the Cloud SDK
    • install :\colon ./google-cloud-sdk/install.sh
    • initialize :\colon ./google-cloud-sdk/bin/gcloud init
      1. set/select configuration
      2. authenticate user account
      3. set GCP console project connection
  4. Install the client library
    pip install --upgrade google-cloud-speech

  5. Make a simple audio transcription request [1] by from google.cloud import speech

※ Note: 在anaconda的環境下,執行完第3步後,GOOGLE_APPLICATION_CREDENTIALS的值會被重新設定,所以在Realization時,第二步會跟第三步交換。也就是先Install and initialize Cloud SDK (步驟三)後再export GOOGLE_APPLICATION_CREDENTIALS(步驟二)。

[0]
https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries#client-libraries-install-python

[1]
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/quickstart.py

results matching ""

    No results matching ""