title: Add recording duration with pyaudio in Python
body: <p>I am writing a program in Python, to create and record audio file by using pyaudio. Audio file creation is done successfully but in recording, i am facing trouble because it is capturing nothing.</p>
  
  <pre><code>import pyaudio
  import wave
  import time
  import sys
  from datetime import datetime
  
  CHUNK = 1024
  FORMAT = pyaudio.paInt16
  CHANNELS = 1
  RATE = 44100
  RECORD_SECONDS = 5
  
  WAVE_OUTPUT_FILENAME = 'Audio.wav'
  
  p = pyaudio.PyAudio()
  stream = p.open(format=FORMAT,
                  channels=CHANNELS,
                  rate=RATE,
                  input=True,
                  frames_per_buffer=CHUNK)
  
  
  frames = []
  print('* done recording')
  
  stream.stop_stream()
  stream.close()
  p.terminate()
  
  wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
  wf.setnchannels(CHANNELS)
  wf.setsampwidth(p.get_sample_size(FORMAT))
  wf.setframerate(RATE)
  wf.writeframes(b''.join(frames))
  wf.close()
  </code></pre>
  
  <p>How can I add duration in audio recording?</p>