PyAudio IOError:没有可用的默认输入设备
我在 Ubuntu 10.10 x64 中的 Enthought Python Distribution (Python 2.6.6) 下使用 PyAudio。
>>> import pyaudio
>>> pa = pyaudio.PyAudio()
>>> pa.get_default_input_device_info()
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
pa.get_default_input_device_info()
File "/usr/lib/python_epd/lib/python2.6/site-packages/pyaudio.py", line 936, in get_default_input_device_info
device_index = pa.get_default_input_device()
IOError: No Default Input Device Available
如果我尝试打开输入流,这与我得到的错误相同。有相应的错误“IOError:没有可用的默认输出设备”
I'm using PyAudio under the Enthought Python Distribution (Python 2.6.6) in Ubuntu 10.10 x64.
>>> import pyaudio
>>> pa = pyaudio.PyAudio()
>>> pa.get_default_input_device_info()
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
pa.get_default_input_device_info()
File "/usr/lib/python_epd/lib/python2.6/site-packages/pyaudio.py", line 936, in get_default_input_device_info
device_index = pa.get_default_input_device()
IOError: No Default Input Device Available
This is the same error I get if I try to open an input stream. There is the corresponding error "IOError: No Default Output Device Available"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
好的,这是一个不太漂亮但对我有用的解决方案。
根据我对 ulidtko 的回答的评论, pyaudio 不是问题,而是 pyaudio 应该绑定到的底层 PortAudio 。
在 ubuntu 上,portaudio 驱动程序是用这个包安装的:
你必须已经有了这个,因为你说你的 ubuntu 可以很好地运行你的代码(尽管有一些可以忽略的调试消息)
如果你查询 portaudio 模块的位置,你会发现当您运行 enthought 的 python 时,会出现以下情况:
以及在 ubuntu 上运行以下情况:
我将 enthought _portaudio.so 移开,并用系统 _portaudio.so 的链接替换它,现在包括 chaco 中可爱的频谱分析仪在内的所有内容demo/advanced 目录的工作原理:
OK, here is a solution that isn't pretty but works for me.
As per my comment to ulidtko's answer, pyaudio is not the problem but rather the underlying PortAudio that pyaudio is supposed to bind to.
On ubuntu the portaudio drivers are installed with this package:
You must have this already, since you said your stock ubuntu runs your code fine (albeit with some debug messages that can be ignored)
If you query the location of your portaudio module you will find the following when you are running enthought's python:
and the following on stock ubuntu:
I moved the enthought _portaudio.so out of the way and replaced it with a link to the system _portaudio.so and now everything including the lovely spectrum analyzer in the chaco demo/advanced directory works:
我会推荐 PYO 进行音频 I/O 和合成,我发现它非常容易上手。
这里有一些代码来说明我如何让 PYO 在处理音频输入以改变其音调后获取并输出它:
PYO 还可以让您动态更改合成、生成器或任何其他内容的频率和参数,这对我来说是最大的吸引力因为我主要用它来编程现场合成器乐器。
它还有一个很棒的手册...
I would recommend PYO for audio I/O and synthesis, I found it really easy to pick up.
Here's some code to illustrate how I would get PYO to get and output an audio input after processing it to change it's pitch:
PYO also lets you change frequencies and parameters of synthesis, generators or anything on the fly, which was the biggest draw for me because I use it mostly for programming live synthesiser instruments.
It also has a great manual...
最后这对我有用:
Build and install portaudio from soure code and install the latest version of pyaudio.
Then renamed libportaudio.so.2.0.0 to oldlibportaudio.so.2.0.0 in /usr/local/lib
and created a new soft link to the one in /usr/lib/x86_64-linux-gnu
在 Ubuntu 20.04 x64 上测试
Finally this work for me:
Build and install portaudio from soure code and install the latest version of pyaudio.
Then renamed libportaudio.so.2.0.0 to oldlibportaudio.so.2.0.0 in /usr/local/lib
and created a new soft link to the one in /usr/lib/x86_64-linux-gnu
tested on Ubuntu 20.04 x64
http://people.csail.mit.edu/hubert/pyaudio/
你有吗安装PortAudio软件?
pyaudio
需要它才能工作。http://people.csail.mit.edu/hubert/pyaudio/
Did you install the PortAudio software? It is required fot the
pyaudio
to work.检查这个
https://github.com/shichao-an/soundmeter/issues/7
你所要做的就是
安装 ALSA :
sudo apt-get install libasound-dev
然后构建 portaudio(此版本
pa_stable_v190600_20161030.tgz
)http://www.portaudio.com/download.html
然后获取 root 权限 (
sudo su root
在 Ubuntu 下,普通su root
不起作用。)将 portaudio 存档放在
/usr/src
中并使用tar 解压xvfz pa_snapshot.tgz
这将生成目录/usr/src/portaudio
。进入该目录并执行以下命令:
成功安装 portaudio 后,必须运行
linrad
配置脚本,以使 Linrad 知道 portaudio 可用。确保您在
./configure
文件中将 ALSA 设置为 yes安装最新版本的
pyaudio
(
PyAudio-0.2.11.tar.gz
)Check this
https://github.com/shichao-an/soundmeter/issues/7
All you have to do is
install ALSA :
sudo apt-get install libasound-dev
then build portaudio (this version
pa_stable_v190600_20161030.tgz
)http://www.portaudio.com/download.html
then Get root privileges (
sudo su root
under Ubuntu where plainsu root
does not work.)Place the portaudio archive in
/usr/src
and unpack it withtar xvfz pa_snapshot.tgz
This will generate the directory/usr/src/portaudio
.Descend into this directory and execute these commands:
The
linrad
configure script has to be run after the successful installation of portaudio to make Linrad aware of the fact that portaudio is available.Make sure you get ALSA as yes in the
./configure
fileInstall the latest version of
pyaudio
(
PyAudio-0.2.11.tar.gz
)从以下来源安装 pyaudio 对我有用
:Answer of Mamun Or Rashid for Question...
操作系统错误:没有可用的默认输入设备
Installing pyaudio from following source worked for me
reference : Answer of Mamun Or Rashid for question...
OSError: No Default Input Device Available