errno -9996无效输出设备(无默认输出设备)COLAB中的错误
我每次都试图运行此代码并面对此错误。
import numpy as np
import pyaudio as pa
import struct
import matplotlib.pyplot as plt
CHUNK = 1024 * 2
FORMAT = pa.paInt16
CHANNELS = 1
RATE = 44100 #Hz
p = pa.PyAudio()
stream = p.open(
format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
output = True,
frames_per_buffer = CHUNK
)
data = stream.read(CHUNK)
print(data)
错误是:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-11-164f54eaf929> in <module>()
18 input = True,
19 output = True,
---> 20 frames_per_buffer = CHUNK
21 )
22
1 frames
/usr/local/lib/python3.7/dist-packages/pyaudio.py in __init__(self, PA_manager, rate, channels, format, input, output, input_device_index, output_device_index, frames_per_buffer, start, input_host_api_specific_stream_info, output_host_api_specific_stream_info, stream_callback)
439
440 # calling pa.open returns a stream object
--> 441 self._stream = pa.open(**arguments)
442
443 self._input_latency = self._stream.inputLatency
OSError: [Errno -9996] Invalid output device (no default output device)
此行通过相同类型的错误
p.get_default_input_device_info()
错误消息是
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-14-5040bbe021ac> in <module>()
----> 1 p.get_default_input_device_info()
/usr/local/lib/python3.7/dist-packages/pyaudio.py in get_default_input_device_info(self)
947 """
948
--> 949 device_index = pa.get_default_input_device()
950 return self.get_device_info_by_index(device_index)
951
OSError: No Default Input Device Available
在此命令之后完美安装的
!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg
!pip install PyAudio
,但无论如何Portaudio都无法安装。
!apt-get install python-gnuradio-audio-portaudio
此行显示:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-gnuradio-audio-portaudio
和!PIP install portaudio
这显示了
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
ERROR: Could not find a version that satisfies the requirement PortAudio (from versions: none)
ERROR: No matching distribution found for PortAudio
I am trying to run this code and facing this error everytime.
import numpy as np
import pyaudio as pa
import struct
import matplotlib.pyplot as plt
CHUNK = 1024 * 2
FORMAT = pa.paInt16
CHANNELS = 1
RATE = 44100 #Hz
p = pa.PyAudio()
stream = p.open(
format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
output = True,
frames_per_buffer = CHUNK
)
data = stream.read(CHUNK)
print(data)
The error is:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-11-164f54eaf929> in <module>()
18 input = True,
19 output = True,
---> 20 frames_per_buffer = CHUNK
21 )
22
1 frames
/usr/local/lib/python3.7/dist-packages/pyaudio.py in __init__(self, PA_manager, rate, channels, format, input, output, input_device_index, output_device_index, frames_per_buffer, start, input_host_api_specific_stream_info, output_host_api_specific_stream_info, stream_callback)
439
440 # calling pa.open returns a stream object
--> 441 self._stream = pa.open(**arguments)
442
443 self._input_latency = self._stream.inputLatency
OSError: [Errno -9996] Invalid output device (no default output device)
Also this line throughs the same kind of error
p.get_default_input_device_info()
Error Message is
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-14-5040bbe021ac> in <module>()
----> 1 p.get_default_input_device_info()
/usr/local/lib/python3.7/dist-packages/pyaudio.py in get_default_input_device_info(self)
947 """
948
--> 949 device_index = pa.get_default_input_device()
950 return self.get_device_info_by_index(device_index)
951
OSError: No Default Input Device Available
PyAudio installed perfectly after this command
!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg
!pip install PyAudio
But portaudio doesn't install anyhow.
!apt-get install python-gnuradio-audio-portaudio
This line shows:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-gnuradio-audio-portaudio
And !pip install PortAudio
this shows
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
ERROR: Could not find a version that satisfies the requirement PortAudio (from versions: none)
ERROR: No matching distribution found for PortAudio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论