You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Google Cloud Speech-to-Text服务账户密钥查找与环境变量设置

How to Get Your Google Cloud Service Account Key & Set the GOOGLE_APPLICATION_CREDENTIALS Variable

Hey Carol, totally get where you're coming from—Google Cloud's setup can feel a bit opaque when you're not deep in code, but let's break this down step by step, no jargon required.

Step 1: Download the Service Account Key JSON File

Here's how to grab that crucial JSON file from the Google Cloud Console:

  • Open the Google Cloud Console and select the project you already created.
  • Use the top search bar to find IAM & Admin, then click into the Service Accounts page.
  • Click the Create Service Account button at the top. Give it a simple name (like speech-to-text-service) and a quick description so you remember its purpose, then hit Create and Continue.
  • Next, grant this service account permission to use the Speech-to-Text API. In the "Select a role" dropdown, search for and select either Cloud Speech-to-Text Client (basic access) or Cloud Speech-to-Text Admin (full access). Click Continue.
  • Skip the third step (adding users to the service account) and click Done to return to the service accounts list.
  • Find the service account you just created, click its name to open the details page.
  • Switch to the Keys tab, then click Add Key > Create new key.
  • Make sure the key type is set to JSON, then click Create. Your browser will automatically download the JSON file—save it somewhere easy to find, like your Documents folder.

Step 2: Set the GOOGLE_APPLICATION_CREDENTIALS Environment Variable

This tells Google's tools where to find your key file. The steps vary a bit by operating system:

Windows

  • Press Win + R, type sysdm.cpl, and hit Enter to open the System Properties window.
  • Go to the Advanced tab, then click Environment Variables.
  • Under either "User variables" (only applies to your account) or "System variables" (applies to all users), click New.
  • For Variable name, enter GOOGLE_APPLICATION_CREDENTIALS.
  • For Variable value, paste the full path to your downloaded JSON file (e.g., C:\Users\YourName\Documents\my-speech-key.json).
  • Click OK on all open windows to save changes. Restart any command prompts or apps you're using for the variable to take effect.

Mac/Linux

  • Open your terminal app.

  • If you use Bash (most Linux systems or older Macs), edit your profile file with:

    nano ~/.bash_profile
    

    Add this line (replace the path with your actual JSON file location):

    export GOOGLE_APPLICATION_CREDENTIALS="/Users/YourName/Documents/my-speech-key.json"
    

    Save the file (Ctrl+O, then Enter) and exit (Ctrl+X), then run source ~/.bash_profile to apply changes immediately.

  • If you use Zsh (default on new Macs), edit your Zsh config instead:

    nano ~/.zshrc
    

    Add the same export line as above, save, exit, then run source ~/.zshrc.

Quick Tip

Double-check the file path you enter—if there are spaces in the path, wrap it in quotes (like the examples above) to avoid errors.

内容的提问来源于stack exchange,提问作者Carol Leigh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:32:29