'Pyaudio [Errno -9998] Invalid number of channels

I found this code on the internet and ran it, and I get this error How do I fix it?

(Link to the code I found: https://github.com/dennougorilla/GVC)

The part where the error occurs

    stream = p.open(
        format=pyaudio.paInt16,
        channels=1,
        rate=RATE,
        frames_per_buffer=CHUNK,
        input_device_index=INPUT,
        output_device_index=OUTPUT,
        input=True,
        output=True)

Error msg

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\ys911\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
    self.run()
  File "C:\Users\ys911\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\ys911\Desktop\test1\test\GVC-master\main.py", line 36, in stream_start
    stream = p.open(
  File "C:\Users\ys911\AppData\Local\Programs\Python\Python39\lib\site-packages\pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "C:\Users\ys911\AppData\Local\Programs\Python\Python39\lib\site-packages\pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9998] Invalid number of channels

Specifications

  • Windows 10
  • Python 3.9
  • PyAudio 0.2.11


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source