title: How to specify which recording device to use with python sounddevice
body: <p>I want to use the following function twice.</p>
  
  <p>This function converts live audio input into a wav file.</p>
  
  <p>For the first time, I use my pc built-in microphone and for the second run, I use my headphone's microphone that I plugged in before I run the code.</p>
  
  <p>But when I tried my function it used only my headphone's microphone:</p>
  
  <pre><code>import sounddevice as sd
  from scipy.io.wavfile import write
  from playsound import playsound
  def audio_to_wav(dst, device):
      """
      converts live audio to wav file
      :param dst: destination wav file
      """
      # Sample rate:
      fs = 4410
      # Duration of recording:
      seconds = 5
  
      myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2, device=device)
      # Wait until recording is finished:
      sd.wait()
      # Save as WAV file:
      write(dst, fs, myrecording)
  </code></pre>
  
  <p>In my main I called this function twice:</p>
  
  <pre><code>def main():
      # transfer mic1 audio to wav:
      audio_to_wav("file1.wav", 0)
      # transfer mic2 audio to wav:
      audio_to_wav("file2.wav", 1)
      # play the wav files audio:
      playsound("file1.wav")
      playsound("file2.wav")
  </code></pre>
  
  <p>But when i ran this code the function used only the headphone's microphone.</p>
  
  <p>How can I use both my pc built-in microphone and my headphone's microphone at the same time?</p>