Skip to content

[Speech] transcribe_async fails with sample_rate_hertz (16000) in RecognitionConfig #1570

@kmonsoor

Description

@kmonsoor

In which file did you encounter the issue?

/home/ubuntu/python-docs-samples/speech/cloud-client/transcribe_async.py

Did you change the file? If so, how?

No

Describe the issue

Execution environment

$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2

$ pip freeze | grep google
gapic-google-cloud-speech-v1==0.15.3
google-api-python-client==1.6.4
google-auth==1.1.1
google-auth-httplib2==0.0.2
google-cloud-core==0.27.1
google-cloud-speech==0.29.0
google-gax==0.15.15
googleapis-common-protos==1.5.2
proto-google-cloud-speech-v1==0.15.3

Command

$ python transcribe_async.py gs://12345-aud-transcription/5951794679150403267.mp4.flac

Output

Traceback (most recent call last):
  File "transcribe_async.py", line 100, in <module>
    transcribe_gcs(args.path)
  File "transcribe_async.py", line 78, in transcribe_gcs
    operation = client.long_running_recognize(config, audio)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/gapic/speech/v1/speech_client.py", line 250, in long_running_recognize
    options), self.operations_client,
  File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 452, in inner
    return api_caller(api_call, this_settings, request)
  File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 438, in base_caller
    return api_call(*args)
  File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 380, in inner
    gax.errors.create_error('RPC failed', cause=exception))
  File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 376, in inner
    return a_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/gax/retry.py", line 68, in inner
    return a_func(*updated_args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py", line 507, in __call__
    return _end_unary_response_blocking(state, call, False, deadline)
  File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py", line 455, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
google.gax.errors.InvalidArgumentError: InvalidArgumentError(RPC failed, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, sample_rate_hertz (16000) in RecognitionConfig must either be unspecified or match the value in the FLAC header (8000).)>)

Quickfix

Changing the value to 8000, or commenting out the line: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/transcribe_async.py#L44

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions