title: Long audio files to text real quick in Python
body: <p>I want to have audio files converted in text. For this purpose I am using <strong>speechrecognition</strong> library and then use <strong>google cloud speech to text AP</strong>I to convert it. I tried doing so by splitting audio in chunks. However, it takes much time than expected. For longer audio files <strong>example of 60 minutes, I want to achieve results in maximum 5 minute</strong>. Is there any way to do so. Please help me out.
  Here is my code :</p>
  
  <pre><code>import speech_recognition as sr
  from pydub import AudioSegment
  from pydub.utils import make_chunks
  
  myaudio = AudioSegment.from_file("testaudio.wav" , "wav") 
  chunk_length_ms = 4000 # pydub calculates in millisec
  chunks = make_chunks(myaudio, chunk_length_ms) #Make chunks of one sec
  
  #Export all of the individual chunks as wav files
  
  for i, chunk in enumerate(chunks):
      chunk_name = "chunk{0}.wav".format(i)
      print ("exporting", chunk_name)
      chunk.export(chunk_name, format="wav")
  
  i=0
  for chunk in chunks:
      print ("in chunks")
      chunk_silent = AudioSegment.silent(duration = 10)
      audio_chunk = chunk_silent + chunk + chunk_silent
      audio_chunk.export("./chunk{0}.wav".format(i), bitrate ='192k', format ="wav")
      filename = 'chunk'+str(i)+'.wav'
      print("Processing chunk "+str(i))
      file = filename
      r = sr.Recognizer()
      with sr.AudioFile(file) as source:
          #r.adjust_for_ambient_noise(source)
          audio_listened = r.listen(source)
      try:
          rec = r.recognize_google_cloud(audio_listened)
          print (rec)
      except:
          rec = r.recognize_google_cloud(audio_listened,show_all=True)
          print(rec,type(rec))
  
      i += 1
  </code></pre>