I am trying to read mp3/wav data from google cloud and trying to implement audio diarization technique. Issue is that I am not able to read the result which has passed by google api in variable response.
below is my python code
speech_file = r'gs://pp003231/a4a.wav'
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
language_code='en-US',
enable_speaker_diarization=True,
diarization_speaker_count=2)
audio = speech.types.RecognitionAudio(uri=speech_file)
response = client.long_running_recognize(config, audio)
print response
result = response.results[-1]
print result
Output displayed on console is Traceback (most recent call last): File "a1.py", line 131, in print response.results AttributeError: 'Operation' object has no attribute 'results'
Can you please share your expert advice about what I am doing wrong? Thanks for your help.
Its too late for the author of this thread. However, posting the solution for someone in future as I too had similar issue. Change result = response.results[-1] to result = response.result().results[-1] and it will work fine