TTS python脚本上的gcloud身份验证问题

TTS python脚本上的gcloud身份验证问题,python,authentication,google-cloud-platform,cloud,google-authentication,Python,Authentication,Google Cloud Platform,Cloud,Google Authentication,我遵循这份文件: 我已经按照指示做了。我在运行提供的Python代码(“创建音频数据”部分)时出错 第一次尝试: 问题似乎在于身份验证。我使用gcloudinit进行了身份验证 C:\webDev\pycharm\TTS-Nov-\Scripts\python.exe C:/webDev/pycharm/TTS-Nov-/TTS-Main.py C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\auth\_default.py:66: Use

我遵循这份文件:

我已经按照指示做了。我在运行提供的Python代码(“创建音频数据”部分)时出错

第一次尝试:

问题似乎在于身份验证。我使用gcloudinit进行了身份验证

C:\webDev\pycharm\TTS-Nov-\Scripts\python.exe C:/webDev/pycharm/TTS-Nov-/TTS-Main.py
C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\auth\_default.py:66: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/
  warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
Traceback (most recent call last):
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\grpc\_channel.py", line 533, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\grpc\_channel.py", line 467, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
    status = StatusCode.PERMISSION_DENIED
    details = "Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the texttospeech.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/."
    debug_error_string = "{"created":"@1541901610.961000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the texttospeech.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.","grpc_status":7}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:/webDev/pycharm/TTS-Nov-/TTS-Main.py", line 26, in <module>
    response = client.synthesize_speech(synthesis_input, voice, audio_config)
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\cloud\texttospeech_v1\gapic\text_to_speech_client.py", line 257, in synthesize_speech
    request, retry=retry, timeout=timeout, metadata=metadata)
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__
    return wrapped_func(*args, **kwargs)
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func
    on_error=on_error,
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\retry.py", line 177, in retry_target
    return target()
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout
    return func(*args, **kwargs)
  File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\grpc_helpers.py", line 61, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the texttospeech.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.
C:\webDev\pycharm\TTS Nov-\Scripts\python.exe C:/webDev/pycharm/TTS Nov-/TTS-Main.py
C:\webDev\pycharm\TTS Nov-\lib\site packages\google\auth\\默认值。py:66:UserWarning:您的应用程序已使用来自google Cloud SDK的最终用户凭据进行身份验证。我们建议大多数服务器应用程序改用服务帐户。如果您的应用程序继续使用云SDK中的最终用户凭据,您可能会收到“超出配额”或“API未启用”错误。有关服务帐户的详细信息,请参阅https://cloud.google.com/docs/authentication/
警告。警告(\u云\u SDK\u凭据\u警告)
回溯(最近一次呼叫最后一次):
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\grpc\u helpers.py”第59行出现错误\u重新映射\u可调用
返回可调用函数(*args,**kwargs)
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\grpc\\u channel.py”,第533行,在调用中__
返回\u结束\u一元\u响应\u阻塞(状态、调用、错误、无)
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\grpc\\u channel.py”,第467行,一元响应
提升集合点(状态,无,无,截止日期)
grpc._通道_会合点:
上述异常是以下异常的直接原因:
回溯(最近一次呼叫最后一次):
文件“C:/webDev/pycharm/TTS Nov-/TTS Main.py”,第26行,在
响应=客户端。合成语音(合成输入、语音、音频配置)
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\cloud\texttospeech\u v1\gapic\text\u to\u speech\u client.py”,第257行,在synthesis\u speech中
请求,重试=重试,超时=超时,元数据=元数据)
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\gapic\u v1\method.py”,第139行,在调用中__
返回包装函数(*args,**kwargs)
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\retry.py”,第260行,在retry\u wrapped\u func中
on_错误=on_错误,
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\retry.py”,第177行,在retry\u目标中
返回目标()
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\timeout.py”,第206行,在func\u中带有\u timeout
返回函数(*args,**kwargs)
文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\grpc\u helpers.py”第61行出现错误\u重新映射\u可调用
六、从(例外情况。从grpc错误(exc),exc)
文件“”,第3行,从
google.api_core.exceptions.PermissionDenied:403您的应用程序已使用来自google Cloud SDK或google Cloud Shell的最终用户凭据进行身份验证,texttospeech.GoogleAppis.com不支持这些凭据。我们建议大多数服务器应用程序改用服务帐户。有关服务帐户以及如何在应用程序中使用它们的更多信息,请参阅https://cloud.google.com/docs/authentication/.
  • 第二次尝试更新:
  • 这是我做的 gcloud身份验证激活服务帐户测试-2@tts-alphax-nov.iam.gserviceaccount.com--key file=“C:\webDev\keys\google cloud\tts-alphax-nov-b101c56c70b7.json”--project=tts alphax-nov

    这导致: 已激活:[测试]的服务帐户凭据-2@tts-alphax-nov.iam.gserviceaccount.com] 然后我再次运行python,这就是我得到的错误

    C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\auth\_default.py:66: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/
      warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
    Traceback (most recent call last):
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
        return callable_(*args, **kwargs)
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\grpc\_channel.py", line 533, in __call__
        return _end_unary_response_blocking(state, call, False, None)
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\grpc\_channel.py", line 467, in _end_unary_response_blocking
        raise _Rendezvous(state, None, None, deadline)
    grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
        status = StatusCode.PERMISSION_DENIED
        details = "Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the texttospeech.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/."
        debug_error_string = "{"created":"@1541903472.332000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the texttospeech.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.","grpc_status":7}"
    >
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "C:/webDev/pycharm/TTS-Nov-/TTS-Main.py", line 26, in <module>
        response = client.synthesize_speech(synthesis_input, voice, audio_config)
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\cloud\texttospeech_v1\gapic\text_to_speech_client.py", line 257, in synthesize_speech
        request, retry=retry, timeout=timeout, metadata=metadata)
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__
        return wrapped_func(*args, **kwargs)
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func
        on_error=on_error,
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\retry.py", line 177, in retry_target
        return target()
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout
        return func(*args, **kwargs)
      File "C:\webDev\pycharm\TTS-Nov-\lib\site-packages\google\api_core\grpc_helpers.py", line 61, in error_remapped_callable
        six.raise_from(exceptions.from_grpc_error(exc), exc)
      File "<string>", line 3, in raise_from
    google.api_core.exceptions.PermissionDenied: 403 Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the texttospeech.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.
    
    C:\webDev\pycharm\TTS Nov-\lib\site packages\google\auth\\u default.py:66:UserWarning:您的应用程序已使用来自google Cloud SDK的最终用户凭据进行身份验证。我们建议大多数服务器应用程序改用服务帐户。如果您的应用程序继续使用云SDK中的最终用户凭据,您可能会收到“超出配额”或“API未启用”错误。有关服务帐户的详细信息,请参阅https://cloud.google.com/docs/authentication/
    警告。警告(\u云\u SDK\u凭据\u警告)
    回溯(最近一次呼叫最后一次):
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\grpc\u helpers.py”第59行出现错误\u重新映射\u可调用
    返回可调用函数(*args,**kwargs)
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\grpc\\u channel.py”,第533行,在调用中__
    返回\u结束\u一元\u响应\u阻塞(状态、调用、错误、无)
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\grpc\\u channel.py”,第467行,一元响应
    提升集合点(状态,无,无,截止日期)
    grpc._通道_会合点:
    上述异常是以下异常的直接原因:
    回溯(最近一次呼叫最后一次):
    文件“C:/webDev/pycharm/TTS Nov-/TTS Main.py”,第26行,在
    响应=客户端。合成语音(合成输入、语音、音频配置)
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\cloud\texttospeech\u v1\gapic\text\u to\u speech\u client.py”,第257行,在synthesis\u speech中
    请求,重试=重试,超时=超时,元数据=元数据)
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\gapic\u v1\method.py”,第139行,在调用中__
    返回包装函数(*args,**kwargs)
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\retry.py”,第260行,在retry\u wrapped\u func中
    on_错误=on_错误,
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\retry.py”,第177行,在retry\u目标中
    返回目标()
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\timeout.py”,第206行,在func\u中带有\u timeout
    返回函数(*args,**kwargs)
    文件“C:\webDev\pycharm\TTS Nov-\lib\site packages\google\api\u core\grpc\u helpers.py”第61行出现错误\u重新映射\u可调用
    六、从(例外情况。从grpc错误(exc),exc)
    文件“”,第3行,从
    google.api_core.exceptions.PermissionDenied:403您的应用程序已使用来自google Cloud SDK或
    
    from google.oauth2 import service_account
    
    credentials = service_account.Credentials.from_service_account_file('<serviceAccountPath>.json')
    
    texttospeech.TextToSpeechClient(credentials=credentials)