agouil / podcast-transcriber

A simple audio file transcriber that uses the Google Cloud Speech API for transcription.
MIT License
26 stars 8 forks source link

AttributeError: 'Resource' object has no attribute 'syncrecognize' #3

Closed Jorlejeu closed 5 years ago

Jorlejeu commented 6 years ago

Hello,

First of all, thank you for the work !

I have an issue : when I run "example.py", the script is downloading the .mp3 file, converting it in .raw and placing it in the /temp directory. But then, it's not uploading to Google's Speech Recognition. I have this error :

File "/Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/transcriber.py", line 35, in transcribe service_request = service.speech().syncrecognize( AttributeError: 'Resource' object has no attribute 'syncrecognize'

I don't know where it comes from. Do you have any solution ?

Thank you a lot !

agouil commented 6 years ago

@Jorlejeu, apologies for the very belated reply to your issue. Are you still getting the error?

Jorlejeu commented 5 years ago

@agouil Hey ! Also a bit late, I moved to another project. Just tested this one again, and got the same issue. Here's the full output in terminal : Apple-System-Inc:podcast-transcriber-master jordanl$ python example.py https://archive.org/download/testmp3testfile/mpthreetest.mp3 Created tmp dir at /Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/tmp/tmpgTsJVN Downloading: mpthreetest.mp3 Progress: 198658 / 198658 [100.00%] File downloaded to: /Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/tmp/tmpgTsJVN/mpthreetest.mp3 Converting to raw audio format... sox WARN trim: End position is after expected end of audio. sox WARN trim: Last 1 position(s) not reached (audio shorter than expected). Transcribing [ 1 / 1 ] /Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/tmp/tmpgTsJVN/mpthreetest001.raw ... Traceback (most recent call last): File "example.py", line 9, in <module> podcast_transcriber.transcribe(args.input_file) File "/Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/podcast_transcriber.py", line 78, in transcribe transcript = transcriber.transcribe_many(chunks) File "/Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/transcriber.py", line 62, in transcribe_many response = self.transcribe(f) File "/Users/jordanl/Documents/podcast-transcriber-master/podcast_transcriber/transcriber.py", line 35, in transcribe service_request = service.speech().syncrecognize( AttributeError: 'Resource' object has no attribute 'syncrecognize' Can't figure where the issue come from. I'm not familiar with this API.

Thank you again for your time !

agouil commented 5 years ago

The issue above has to do with the Google API version I'm using. I'm using V1 which is the stable version of the API since a few months ago. syncrecognize doesn't exist in V1.

Check the docs here: https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize

Just need to update syncrecognize to just recognize. If you update it and send a merge request, I'll accept the change.

Jorlejeu commented 5 years ago

Thank you for your answer. I had another issue with the sampleRate but I corrected it and now it's working like a charm. I'm sending the merge request right now.

agouil commented 5 years ago

4