将Python脚本从Win10移植到Ubuntu(音频、网络)

vuktfyat  于 2022-12-20  发布在  Python
关注(0)|答案(1)|浏览(360)

我编写了一小段Python,用于捕获麦克风输入并将其发送到同一专用网络上的另一台计算机,然后将其Map到第二台计算机的扬声器。https://github.com/Bencosterton/BCAN-AoIP该应用程序分两部分运行,客户端和接收器。
这是在Windos 10中编写的,在Windows机器之间工作得很好。
我决定在Linux上测试它(发射机部分),并得到了很多ALSA和杰克相关的错误。
操作系统:Ubuntu 22.04LTS + Ubuntu Studio extras -运行在Virtualbox上,桥接网络适配器。Virtualbox已被授予访问主机音频输入/输出的权限。
安装Ubuntu Studio ALSA和JACK驱动程序后,没有任何变化。有什么建议要首先解决什么以及如何解决吗?
python脚本启动时的输出;

ALSA lib pcm_dmix.c:1032:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib setup.c:547:(add_elem) Cannot obtain info for CTL elem (MIXER,'IEC958 Playback Default',0,0,0): No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib pcm_dmix.c:1032:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
/home/ben/Desktop/reciever.py:42: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
  udpThread .setDaemon(True)
/home/ben/Desktop/reciever.py:43: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
  AudioThread.setDaemon(True)
^[[1;2D^CTraceback (most recent call last):
  File "/home/ben/Desktop/reciever.py", line 46, in <module>
    udpThread .join()
  File "/usr/lib/python3.10/threading.py", line 1096, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.10/threading.py", line 1116, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
KeyboardInterrupt

任何帮助都将不胜感激。

icnyk63a

icnyk63a1#

脚本现在可以在UbutuStudio 22.04上运行;

sudo apt install build-essential portaudio19-dev python3.10-dev

pip install pyaudio

在运行pyaudio之前需要Portaudio。
它仍然抛出ALSA错误,但应用程序运行。

相关问题