title: Speech to text directly from audio data stream without saving into (.wav) file
body: <p>I am converting the audio into text using Pyaudio and speech_recognition modules. my question is can i convert the audio being recorded using pyaudio into text without creating the audio.wav file? because apparently speech recognition module works with audio file when i open it using <code>with sr.AudioFile(chunk_name) as source:</code></p>
  <p>Code for Recording:</p>
  <pre><code>def start_recording(duration,chunk_th):
      '''
      This function takes the duration in seconds and chunks threashold then records the sound from the microphone 
      and displays the text in realtime after saving the recordings into the folder using multithreading.
      '''
      audio_format = pyaudio.paInt16
      rate = 44100
  
      p = pyaudio.PyAudio()
      r = sr.Recognizer()
  
      stream = p.open(format=audio_format,
                      channels=1,
                      rate=rate,
                      input=True,
                      frames_per_buffer=1024)
  
      print(&quot;*** Recording Started ***&quot;)
  
      frames = []
  
      chunk_no = 1
      for i in range(1, int(rate / 1024 * duration)+1):
          data = stream.read(1024)
          frames.append(data)
          if i % chunk_th == 0 or i == int(rate / 1024 * duration):
              # start a thread with frames
              fm_copy = frames.copy()
              t = threading.Thread(target=save_chunk,args=(fm_copy,chunk_no,rate,p,r))
              t.start()
              chunk_no += 1
              frames.clear()
  #     print(len(frames))
      print(&quot;* done recording&quot;)
  
      stream.stop_stream()
      stream.close()
      p.terminate()
  </code></pre>
  <p>This is the code for recording and i am passing the frames after an interval into my thread so that i can do the recording and process the audio in realtime.<br>
  Function which i am calling in thread:</p>
  <pre><code>def save_chunk(fr,chunk_no,rate,p,r):
      '''
      This function will take the frames for the each chunk and saves the file in the folder
      then extract the spoken text from the file and displays the text.
      Question : Can i extract the audio from frames directly using same methodology without having to 
      create audio files in the folder?
      '''
  #     print(&quot;this has recived {} frames&quot;.format(len(fr)))
      try:
           
          chunk_name = &quot;Chunks/chunk_{}.wav&quot;.format(chunk_no)
          wf = wave.open(chunk_name, 'wb')
          wf.setnchannels(1)
          wf.setsampwidth(p.get_sample_size(pyaudio.paInt16))
          wf.setframerate(rate)
          wf.writeframes(b''.join(fr))
          wf.close()
          
          
          with sr.AudioFile(chunk_name) as source:
              audio = r.listen(source)
              text = r.recognize_google(audio)
              print(text)
              
      except Exception as e:
          print(&quot;No Audio Detected&quot;,e)
  </code></pre>