python-speech-recognition
python-speech-recognition copied to clipboard
speech file can't be longer than 30 seconds
hi
i modifed your code a bit to read from sample file. My sample file is 55 seconds long and I noticed that it get's cut off.
I am using recognize_google.
I am guessing this is some sort of api limitation and that I should probably get my own key.
@jzoudavy Yes, this is a limitation of the Google Web Speech API. Unfortunately, I don't think you get any additional length by using your own key. For longer files, you have a couple of options:
- Break them up into chunks, either manually with audio editing software, or using the
offsetanddurationkeyword arguments for the.record()method. - Use the
.listen()method to capture speech until a pause is detected. This is not covered in the article. You can find information about this method in the Speech Recognition docs. - Use the Google Cloud Speech API. That is not a free API, although you can get an account with a free $300 credit for one year at https://cloud.google.com. I don't cover setting up an account and obtaining a key for the Google Cloud platform in the article. Here is a quick start on how to do that from the Google Cloud docs: https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries.
Hope that helps!