realpython / python-speech-recognition

Speech Recognition with Python examples
https://realpython.com/python-speech-recognition/
MIT License
242 stars 186 forks source link

speech file can't be longer than 30 seconds #3

Open jzoudavy opened 6 years ago

jzoudavy commented 6 years ago

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.

somacdivad commented 6 years ago

@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:

1) Break them up into chunks, either manually with audio editing software, or using the offset and duration keyword arguments for the .record() method. 2) 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. 3) 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!