Я пытаюсь сделать Google Cloud Recognition для персонального помощника, построенного на python.У меня есть служебная учетная запись, а также настроены GOOGLE_ACCOUNT_CREDENTIALS, а также включен API.Но это не работает.Это пример кода с официальной страницы.
from google.cloud import speech
client = speech.SpeechClient()
results = client.recognize(
audio=speech.types.RecognitionAudio(
uri='gs://my-bucket/recording.flac',
),
config=speech.types.RecognitionConfig(
encoding='LINEAR16',
language_code='en-US',
sample_rate_hertz=44100,
),
)
for result in results:
for alternative in result.alternatives:
print('=' * 20)
print('transcript: ' + alternative.transcript)
print('confidence: ' + str(alternative.confidence))
Ошибка:
(base) C:\Users\mnauf>C:/Users/mnauf/Anaconda3/python.exe d:/Programming/python/mic.py
Traceback (most recent call last):
File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\Users\mnauf\Anaconda3\lib\site-packages\grpc\_channel.py", line 533, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Users\mnauf\Anaconda3\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 = "The caller does not have permission"
debug_error_string = "{"created":"@1543062997.122000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"The caller
does not have permission","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "d:/Programming/python/mic.py", line 10, in <module>
sample_rate_hertz=44100,
File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\cloud\speech_v1\gapic\speech_client.py", line 227, in recognize
request, retry=retry, timeout=timeout, metadata=metadata)
File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__
return wrapped_func(*args, **kwargs)
File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func
on_error=on_error,
File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\retry.py", line 177, in retry_target
return target()
File "C:\Users\mnauf\Anaconda3\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout
return func(*args, **kwargs)
File "C:\Users\mnauf\Anaconda3\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 The caller does not have permission