9

I went on Google Cloud and enabled a project, billing, and the Cloud Speech to Text API. Then I downloaded a .json file. Then I tried to execute this basic code in PyCharm.

    import os
    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] ="instant-medium-282.json"
    
    from google.cloud import speech_v1
    from google.cloud.speech_v1 import enums
    
    client = speech_v1.SpeechClient()
    
    encoding = enums.RecognitionConfig.AudioEncoding.FLAC
    sample_rate_hertz = 44100
    language_code = 'en-US'
    config = {'encoding': encoding, 'sample_rate_hertz': sample_rate_hertz, 'language_code': language_code}
    uri = 'gs://bucket_name/file_name.flac'
    audio = {'uri': uri}
    
    response = client.recognize(config, audio)

However, I keep getting this error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 826, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.PERMISSION_DENIED
    details = "The billing account for the owning project is disabled in state absent"
    debug_error_string = "{"created":"@1593884707.640503000","description":"Error received from peer ipv6:[2607:f8b0:4009:813::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"The billing account for the owning project is disabled in state absent","grpc_status":7}"
>

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

Traceback (most recent call last):
  File "/Users/sal.py", line 16, in <module>
    response = client.recognize(config, audio)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 255, in recognize
    return self._inner_api_calls["recognize"](
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
    return retry_target(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 184, in retry_target
    return target()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 59, 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 The billing account for the owning project is disabled in state absent

I also confirmed with Google Cloud customer support that billing is enabled as it should be. Any suggestions on how to fix this error?

Ismail
  • 1,068
  • 1
  • 6
  • 11
fa21212
  • 91
  • 1
  • 1
  • 3
  • Does this answer your question? [AccessDeniedException: 403 The project to be billed is associated with a closed billing account](https://stackoverflow.com/questions/55433145/accessdeniedexception-403-the-project-to-be-billed-is-associated-with-a-closed) – Martin Zeitler Jul 05 '20 at 07:36

4 Answers4

20

I ran into an issue while uploading a file using the CLI where I was trying to copy into a bucket that did not actually exist. It threw this same error "AccessDeniedException: 403 The billing account for the owning project is disabled in state closed".

If all was well with billing, perhaps the bucket you were pointing to did not exist?

Just wanted to flag that there seem to be non-billing reasons for such an error could be thrown..

Shruthi
  • 243
  • 3
  • 9
  • This fixed the problem for me as well - for me the error was "The billing account for the owning project is disabled in state absent". Making sure the bucket exists fixed the issue. – Jeremy Hon Dec 12 '22 at 03:20
2

The "The billing account for the owning project is disabled in state absent" error message,may happen when the API has just been enabled recently. So it is recommended to try again.

1

In my case,

"AccessDeniedException: 403 The billing account for the owning project is disabled in state closed"

happen, because I didn't added 'Billing Account' to the project I've created. You can link your project to a Billing Account in Billing Projects tab. Once you did so, wait some time and the error should gone.

Artem Zaika
  • 1,130
  • 13
  • 13
0

In my case I sent wrong url 'gs://undefined/undefined' and I got an error "The billing account for the owning project is disabled in state closed". Correct url solved my problem.