撰寫: 2022/1/28

發佈: 2022/5/1

Raspberry Pi使用SpeechRecognition library

根據SpeechRecognition GitHub README.rst要在Raspberry Pi中使用SpeechRecognition library,首先必須確認你具備以下所基本要求:

  • Python 2.6, 2.7, or 3.3以上的版本:此為必要的項目。
  • PyAudio 0.2.11以上的版本:此為選項,取決於你的系統中是否需要使用Microphone作為聲音輸入的音源,在此我們要運用Microphone接收聲音,所以必須安裝此library
  • PocketSphinx:此為選項,取決於你的系統中是否需要使用Sphinx recognizer,在此我們會呼叫``recognizer_instance.recognize_sphinx``功能,所以必須安裝此library
  • Google API Client Library for Python:此為選項,取決於你的系統中是否需要使用Google Cloud Speech API,在此我們不會運用此雲端語音功能,所以不須安裝API
  • FLAC encoder:此為選項,若你本身是x86-based CPU系統就已經涵蓋了,但若你的系統並不是x86-basedWindows/Linux/OS X作業系統,就必須安裝此encoder;目前Raspberry PiARM-basedLinux作業系統,所以必須安裝此FLAC encoder

 

PyAudio安裝

在此SpeechRecognition需要安裝PyAudio 0.2.11以上的版本,不然從麥克風錄音會有已知的記憶體管理的bug瑕疵。

當然就算沒有安裝PyAudio狀況下SpeechRecognition仍然可以正常運作,只是當SpeechRecognition企圖實體化Microphone物件時就會出現”AttributeError”的例外錯誤(exception)

所以在此我們Raspberry Pi要運用Microphone接收聲音,所以必須安裝PyAudio libraryPyAudio網址如下:

https://people.csail.mit.edu/hubert/pyaudio/

安裝網址在下方如下:

http://people.csail.mit.edu/hubert/pyaudio/#downloads

04-01.png

 

 

 

 

 

 

PyAudio website網址所敘述的安裝簡介相當好而且方便,但因為在此Raspberry Pi使用的是Raspbian作業系統,所以可以忽略有關WindowsOS X作業系統部分,整體來說整理如下:

  • Debian-derived Linux distributions 類的作業系統,如Ubuntu and Mint這類的系統,要安裝PyAudio可在terminal終端機輸入以下命令:

sudo apt-get install python-pyaudio python3-pyaudio

  • repositories 版本太舊,可以使用Pip來安裝最後版本,可執行以下命令:

sudo apt-get install portaudio19-dev python-all-dev python3-all-dev

sudo pip3 install pyaudio

  • POSIX-based類的作業系統,就如同上面所類似方法,使用安裝包管理程式來選擇安裝`portaudio19-dev`` and ``python3-all-dev`,然後在用以下命令安裝PyAudio

sudo pip3 install pyaudio

 

總結來說,在Raspberry Pi安裝PyAudio底層須要先有Portaudio,而Portaudio安裝多數從原始碼編碼來安裝,但也可以方便以apt-get install portaudio19-dev方式來裝;在此我們採用後者方式來安裝如下:

sudo apt-get install portaudio19-dev python3-all-dev && sudo pip3 install pyaudio

安裝過程訊息如下:

正在讀取套件清單... 完成

正在重建相依關係         

正在讀取狀態資料... 完成

下列的額外套件將被安裝:

  libasound2-dev libjack-dev libjack0 libportaudiocpp0 libpython3-all-dev

  python3-all uuid-dev

建議套件:

  libasound2-doc jackd1 portaudio19-doc

下列套件將會被【移除】:

  libjack-jackd2-0

下列【新】套件將會被安裝:

  libasound2-dev libjack-dev libjack0 libportaudiocpp0 libpython3-all-dev

  portaudio19-dev python3-all python3-all-dev uuid-dev

升級 0 個,新安裝 9 個,移除 1 個,有 0 個未被升級。

需要下載 663 kB 的套件檔。

此操作完成之後,會多佔用 2,732 kB 的磁碟空間。

是否繼續進行 [Y/n] [Y/n] y

下載:1 http://archive.raspberrypi.org/debian buster/main armhf libasound2-dev armhf 1.1.8-1+rpt2 [145 kB]

下載:2 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libjack0 armhf 1:0.125.0-3 [93.1 kB]

下載:3 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf uuid-dev armhf 2.33.1-0.1 [92.4 kB]

下載:4 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libjack-dev armhf 1:0.125.0-3 [214 kB]

下載:5 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libportaudiocpp0 armhf 19.6.0-1+deb10u1 [16.7 kB]

下載:6 http://raspbian.raspberrypi.org/raspbian buster/main armhf libpython3-all-dev armhf 3.7.3-1 [1,068 B]

下載:7 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf portaudio19-dev armhf 19.6.0-1+deb10u1 [98.5 kB]

下載:8 http://raspbian.raspberrypi.org/raspbian buster/main armhf python3-all armhf 3.7.3-1 [1,068 B]

下載:9 http://raspbian.raspberrypi.org/raspbian buster/main armhf python3-all-dev armhf 3.7.3-1 [1,064 B]

取得 663 kB 用了 8s (83.3 kB/s)                                               

dpkg: libjack-jackd2-0:armhf:發生相依上的問題,但還是應您要求強制移除:

 libportaudio2:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libfluidsynth1:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libavdevice58:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libasound2-plugins:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 gstreamer1.0-plugins-good:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libportaudio2:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libfluidsynth1:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libavdevice58:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 libasound2-plugins:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 gstreamer1.0-plugins-good:armhf 相依於 libjack-jackd2-0 (>= 1.9.10+20150825) | libjack-0.125﹔然而:

  即將移除套件 libjack-jackd2-0:armhf

  套件 libjack-0.125 未安裝。

  提供了 libjack-0.125 的套件 libjack-jackd2-0:armhf 即將被移除。

 

(讀取資料庫 ... 目前共安裝了 99415 個檔案和目錄。)

正在移除 libjack-jackd2-0:armhf (1.9.12~dfsg-2)……

選取了原先未選的套件 libjack0:armhf

(讀取資料庫 ... 目前共安裝了 99403 個檔案和目錄。)

正在準備解包 .../0-libjack0_1%3a0.125.0-3_armhf.deb……

Unpacking libjack0:armhf (1:0.125.0-3) ...

選取了原先未選的套件 libasound2-dev:armhf

正在準備解包 .../1-libasound2-dev_1.1.8-1+rpt2_armhf.deb……

Unpacking libasound2-dev:armhf (1.1.8-1+rpt2) ...

選取了原先未選的套件 uuid-dev:armhf

正在準備解包 .../2-uuid-dev_2.33.1-0.1_armhf.deb……

Unpacking uuid-dev:armhf (2.33.1-0.1) ...

選取了原先未選的套件 libjack-dev

正在準備解包 .../3-libjack-dev_1%3a0.125.0-3_armhf.deb……

Unpacking libjack-dev (1:0.125.0-3) ...

選取了原先未選的套件 libportaudiocpp0:armhf

正在準備解包 .../4-libportaudiocpp0_19.6.0-1+deb10u1_armhf.deb……

Unpacking libportaudiocpp0:armhf (19.6.0-1+deb10u1) ...

選取了原先未選的套件 libpython3-all-dev:armhf

正在準備解包 .../5-libpython3-all-dev_3.7.3-1_armhf.deb……

Unpacking libpython3-all-dev:armhf (3.7.3-1) ...

選取了原先未選的套件 portaudio19-dev:armhf

正在準備解包 .../6-portaudio19-dev_19.6.0-1+deb10u1_armhf.deb……

Unpacking portaudio19-dev:armhf (19.6.0-1+deb10u1) ...

選取了原先未選的套件 python3-all

正在準備解包 .../7-python3-all_3.7.3-1_armhf.deb……

Unpacking python3-all (3.7.3-1) ...

選取了原先未選的套件 python3-all-dev

正在準備解包 .../8-python3-all-dev_3.7.3-1_armhf.deb……

Unpacking python3-all-dev (3.7.3-1) ...

設定 python3-all (3.7.3-1) ...

設定 libportaudiocpp0:armhf (19.6.0-1+deb10u1) ...

設定 libpython3-all-dev:armhf (3.7.3-1) ...

設定 libjack0:armhf (1:0.125.0-3) ...

設定 uuid-dev:armhf (2.33.1-0.1) ...

設定 libjack-dev (1:0.125.0-3) ...

設定 libasound2-dev:armhf (1.1.8-1+rpt2) ...

設定 python3-all-dev (3.7.3-1) ...

設定 portaudio19-dev:armhf (19.6.0-1+deb10u1) ...

執行 man-db (2.8.5-2) 的觸發程式……

執行 libc-bin (2.28-10+rpt2+rpi1) 的觸發程式……

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple

Collecting pyaudio

  Downloading https://www.piwheels.org/simple/pyaudio/PyAudio-0.2.11-cp37-cp37m-linux_armv6l.whl (53kB)

    100% |████████████████████████████████| 61kB 81kB/s

Installing collected packages: pyaudio

^COperation cancelled by user

pi@raspberrypi:~ $

其中libjack-jackd2-0:armhf的警訊可以忽略。

 

PocketSphinx-Python安裝

在此系統中需要使用Sphinx recognizer,所以必須安裝PocketSphinx-PythonlibraryPocketSphinx-Python網址如下:

https://github.com/bambocher/pocketsphinx-python

04-02.png

 

在官網上有關各個不同OS安裝重點,在此Raspberry Pi使用的是Raspbian作業系統,所以可以忽略有關Windows作業系統部分,整體來說整理如下:

  • Linux 和其他POSIX 作業系統(OS X):安裝說明請參考以下PocketSphinx網址註解中有關原始碼創建PocketSphinx-Python ("Building PocketSphinx-Python from source")下面的說明。https://github.com/Uberi/speech_recognition/blob/master/reference/pocketsphinx.rst
  • 另外在該網址下還有有關安裝各國語言、編譯PocketSphinx以及線上資源建立各國語言包相關資訊,這些文件都包括在`reference/pocketsphinx.rst``的註解。

 

總結來說,在官網右邊About區就有 Python interface to CMU Sphinxbase and Pocketsphinx libraries,所以Raspberry Pi安裝PocketSphinx-Python,可以直接使用Pip安裝,命令如下:

pi@raspberrypi:~ $ sudo pip3 install PocketSphinx

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple

Collecting PocketSphinx

  Downloading https://www.piwheels.org/simple/pocketsphinx/pocketsphinx-0.1.15-cp39-cp39-linux_armv7l.whl (30.3 MB)

    |████████████████████████████████| 30.3 MB 4.5 kB/s

Installing collected packages: PocketSphinx

Successfully installed PocketSphinx-0.1.15

pi@raspberrypi:~ $

 

但是在Raspberry Pi zero w安裝PocketSphinx-Python會有以下的問題:

pi@raspberrypi:~ $ sudo pip3 install PocketSphinx

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple

Collecting PocketSphinx

  Downloading https://files.pythonhosted.org/packages/cd/4a/adea55f189a81aed88efa0b0e1d25628e5ed22622ab9174bf696dd4f9474/pocketsphinx-0.1.15.tar.gz (29.1MB)

    100% |████████████████████████████████| 29.1MB 2.4kB/s

Building wheels for collected packages: PocketSphinx

  Running setup.py bdist_wheel for PocketSphinx ... error

  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cna7hu5p/PocketSphinx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-x27ublnm --python-tag cp37:

  running bdist_wheel

  running build_ext

  building 'sphinxbase._sphinxbase' extension

  swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c

  swig -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c deps/sphinxbase/swig/sphinxbase.i

  unable to execute 'swig': No such file or directory

  error: command 'swig' failed with exit status 1

 

  ----------------------------------------

  Failed building wheel for PocketSphinx

  Running setup.py clean for PocketSphinx

Failed to build PocketSphinx

Installing collected packages: PocketSphinx

  Running setup.py install for PocketSphinx ... error

    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cna7hu5p/PocketSphinx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-rikq9wjk/install-record.txt --single-version-externally-managed --compile:

    running install

    running build_ext

    building 'sphinxbase._sphinxbase' extension

    swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c

    swig -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c deps/sphinxbase/swig/sphinxbase.i

    unable to execute 'swig': No such file or directory

    error: command 'swig' failed with exit status 1

   

    ----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cna7hu5p/PocketSphinx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-rikq9wjk/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-cna7hu5p/PocketSphinx/

 

檢查發現Raspberry Pi zero w安裝PocketSphinx-Python必須要先裝swig,命令如下:

pi@raspberrypi:~ $ sudo apt-get install swig

正在讀取套件清單... 完成

正在重建相依關係         

正在讀取狀態資料... 完成

下列的額外套件將被安裝:

  swig3.0

建議套件:

  swig-doc swig-examples swig3.0-examples swig3.0-doc

下列【新】套件將會被安裝:

  swig swig3.0

升級 0 個,新安裝 2 個,移除 0 個,有 0 個未被升級。

需要下載 1,530 kB 的套件檔。

此操作完成之後,會多佔用 5,745 kB 的磁碟空間。

是否繼續進行 [Y/n] [Y/n] y

下載:1 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf swig3.0 armhf 3.0.12-2 [1,221 kB]

下載:2 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf swig armhf 3.0.12-2 [310 kB]

取得 1,530 kB 用了 3s (550 kB/s)

選取了原先未選的套件 swig3.0

(讀取資料庫 ... 目前共安裝了 99674 個檔案和目錄。)

正在準備解包 .../swig3.0_3.0.12-2_armhf.deb……

Unpacking swig3.0 (3.0.12-2) ...

選取了原先未選的套件 swig

正在準備解包 .../swig_3.0.12-2_armhf.deb……

Unpacking swig (3.0.12-2) ...

設定 swig3.0 (3.0.12-2) ...

設定 swig (3.0.12-2) ...

執行 man-db (2.8.5-2) 的觸發程式……

 

另外Raspberry Pi zero w安裝PocketSphinx-Python還需要先裝libpulse-dev,命令如下:

pi@raspberrypi:~ $ sudo apt-get install git libpulse-dev

正在讀取套件清單... 完成

正在重建相依關係         

正在讀取狀態資料... 完成

git is already the newest version (1:2.20.1-2+deb10u3).

下列的額外套件將被安裝:

  libblkid-dev libffi-dev libglib2.0-dev libglib2.0-dev-bin libmount-dev libpcre16-3

  libpcre3-dev libpcre32-3 libpcrecpp0v5 libpulse-mainloop-glib0 libselinux1-dev libsepol1-dev

建議套件:

  libglib2.0-doc libgdk-pixbuf2.0-bin | libgdk-pixbuf2.0-dev libxml2-utils

下列【新】套件將會被安裝:

  libblkid-dev libffi-dev libglib2.0-dev libglib2.0-dev-bin libmount-dev libpcre16-3

  libpcre3-dev libpcre32-3 libpcrecpp0v5 libpulse-dev libpulse-mainloop-glib0 libselinux1-dev

  libsepol1-dev

升級 0 個,新安裝 13 個,移除 0 個,有 0 個未被升級。

需要下載 3,880 kB 的套件檔。

此操作完成之後,會多佔用 15.3 MB 的磁碟空間。

是否繼續進行 [Y/n] [Y/n] y

下載:1 http://archive.raspberrypi.org/debian buster/main armhf libpulse-mainloop-glib0 armhf 12.2-4+deb10u1+rpi3 [37.0 kB]

下載:3 http://archive.raspberrypi.org/debian buster/main armhf libpulse-dev armhf 12.2-4+deb10u1+rpi3 [97.5 kB]

下載:2 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libblkid-dev armhf 2.33.1-0.1 [210 kB]

下載:4 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libffi-dev armhf 3.2.1-9 [159 kB]

下載:5 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libglib2.0-dev-bin armhf 2.58.3-2+deb10u2 [155 kB]

下載:6 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libmount-dev armhf 2.33.1-0.1 [209 kB]

下載:7 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libpcre16-3 armhf 2:8.39-12 [234 kB]

下載:8 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libpcre32-3 armhf 2:8.39-12 [227 kB]

下載:9 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libpcrecpp0v5 armhf 2:8.39-12 [150 kB]

下載:10 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libpcre3-dev armhf 2:8.39-12 [564 kB]

下載:11 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libsepol1-dev armhf 2.8-1 [309 kB]

下載:12 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libselinux1-dev armhf 2.8-1+b1 [156 kB]

下載:13 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf libglib2.0-dev armhf 2.58.3-2+deb10u2 [1,372 kB]

取得 3,880 kB 用了 14s (285 kB/s)                                                               

選取了原先未選的套件 libblkid-dev:armhf

(讀取資料庫 ... 目前共安裝了 100467 個檔案和目錄。)

正在準備解包 .../00-libblkid-dev_2.33.1-0.1_armhf.deb……

Unpacking libblkid-dev:armhf (2.33.1-0.1) ...

選取了原先未選的套件 libffi-dev:armhf

正在準備解包 .../01-libffi-dev_3.2.1-9_armhf.deb……

Unpacking libffi-dev:armhf (3.2.1-9) ...

選取了原先未選的套件 libglib2.0-dev-bin

正在準備解包 .../02-libglib2.0-dev-bin_2.58.3-2+deb10u2_armhf.deb……

Unpacking libglib2.0-dev-bin (2.58.3-2+deb10u2) ...

選取了原先未選的套件 libmount-dev:armhf

正在準備解包 .../03-libmount-dev_2.33.1-0.1_armhf.deb……

Unpacking libmount-dev:armhf (2.33.1-0.1) ...

選取了原先未選的套件 libpcre16-3:armhf

正在準備解包 .../04-libpcre16-3_2%3a8.39-12_armhf.deb……

Unpacking libpcre16-3:armhf (2:8.39-12) ...

選取了原先未選的套件 libpcre32-3:armhf

正在準備解包 .../05-libpcre32-3_2%3a8.39-12_armhf.deb……

Unpacking libpcre32-3:armhf (2:8.39-12) ...

選取了原先未選的套件 libpcrecpp0v5:armhf

正在準備解包 .../06-libpcrecpp0v5_2%3a8.39-12_armhf.deb……

Unpacking libpcrecpp0v5:armhf (2:8.39-12) ...

選取了原先未選的套件 libpcre3-dev:armhf

正在準備解包 .../07-libpcre3-dev_2%3a8.39-12_armhf.deb……

Unpacking libpcre3-dev:armhf (2:8.39-12) ...

選取了原先未選的套件 libsepol1-dev:armhf

正在準備解包 .../08-libsepol1-dev_2.8-1_armhf.deb……

Unpacking libsepol1-dev:armhf (2.8-1) ...

選取了原先未選的套件 libselinux1-dev:armhf

正在準備解包 .../09-libselinux1-dev_2.8-1+b1_armhf.deb……

Unpacking libselinux1-dev:armhf (2.8-1+b1) ...

選取了原先未選的套件 libglib2.0-dev:armhf

正在準備解包 .../10-libglib2.0-dev_2.58.3-2+deb10u2_armhf.deb……

Unpacking libglib2.0-dev:armhf (2.58.3-2+deb10u2) ...

選取了原先未選的套件 libpulse-mainloop-glib0:armhf

正在準備解包 .../11-libpulse-mainloop-glib0_12.2-4+deb10u1+rpi3_armhf.deb……

Unpacking libpulse-mainloop-glib0:armhf (12.2-4+deb10u1+rpi3) ...

選取了原先未選的套件 libpulse-dev:armhf

正在準備解包 .../12-libpulse-dev_12.2-4+deb10u1+rpi3_armhf.deb……

Unpacking libpulse-dev:armhf (12.2-4+deb10u1+rpi3) ...

設定 libpcrecpp0v5:armhf (2:8.39-12) ...

設定 libglib2.0-dev-bin (2.58.3-2+deb10u2) ...

設定 libblkid-dev:armhf (2.33.1-0.1) ...

設定 libpcre16-3:armhf (2:8.39-12) ...

設定 libsepol1-dev:armhf (2.8-1) ...

設定 libffi-dev:armhf (3.2.1-9) ...

設定 libpulse-mainloop-glib0:armhf (12.2-4+deb10u1+rpi3) ...

設定 libpcre32-3:armhf (2:8.39-12) ...

設定 libmount-dev:armhf (2.33.1-0.1) ...

設定 libpcre3-dev:armhf (2:8.39-12) ...

設定 libselinux1-dev:armhf (2.8-1+b1) ...

設定 libglib2.0-dev:armhf (2.58.3-2+deb10u2) ...

執行 install-info (6.5.0.dfsg.1-4+b1) 的觸發程式……

執行 libglib2.0-0:armhf (2.58.3-2+deb10u2) 的觸發程式……

執行 libc-bin (2.28-10+rpt2+rpi1) 的觸發程式……

執行 man-db (2.8.5-2) 的觸發程式……

設定 libpulse-dev:armhf (12.2-4+deb10u1+rpi3) ...

W: Operation was interrupted before it could finish

 

之後安裝PocketSphinx-Python就會正常如下:

pi@raspberrypi:~ $ sudo pip3 install PocketSphinx

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple

Collecting PocketSphinx

  Using cached https://files.pythonhosted.org/packages/cd/4a/adea55f189a81aed88efa0b0e1d25628e5ed22622ab9174bf696dd4f9474/pocketsphinx-0.1.15.tar.gz

Building wheels for collected packages: PocketSphinx

  Running setup.py bdist_wheel for PocketSphinx ... done

  Stored in directory: /root/.cache/pip/wheels/52/fd/52/2f62c9a0036940cc0c89e58ee0b9d00fcf78243aeaf416265f

Successfully built PocketSphinx

Installing collected packages: PocketSphinx

Successfully installed PocketSphinx-0.1.15

整體安裝PocketSphinx會花約20mins

 

 

FLAC安裝

目前Raspberry PiARM-basedLinux作業系統,所以必須安裝此FLAC encoder,才能將聲音資料送給FLAC encoder API;若要確認系統安裝包管理程式是否已經有FLAC encoder,可以在terminal終端機輸入以下命令:

flac -h

 

FLAC encoder官網如下:

https://xiph.org/flac/

04-03.png

 

Raspberry Pi安裝FLAC encoder,可以直接使用apt-get安裝,命令如下:

> sudo apt-get install flac

正在讀取套件清單... 完成

正在重建相依關係... 完成 

正在讀取狀態資料... 完成 

The following package was automatically installed and is no longer required:

  libfuse2

Use 'sudo apt autoremove' to remove it.

下列【新】套件將會被安裝:

  flac

升級 0 個,新安裝 1 個,移除 0 個,有 118 個未被升級。

需要下載 121 kB 的套件檔。

此操作完成之後,會多佔用 342 kB 的磁碟空間。

下載:1 http://mirror.ossplanet.net/raspbian/raspbian bullseye/main armhf flac armhf 1.3.3-2 [121 kB]

取得 121 kB 用了 2s (53.5 kB/s)

選取了原先未選的套件 flac

(讀取資料庫 ... 目前共安裝了 99508 個檔案和目錄。)

正在準備解包 .../flac_1.3.3-2_armhf.deb……

Unpacking flac (1.3.3-2) ...

設定 flac (1.3.3-2) ...

執行 man-db (2.9.4-2) 的觸發程式……

 

正在讀取套件清單... 完成

正在重建相依關係          

正在讀取狀態資料... 完成

下列【新】套件將會被安裝:

  flac

升級 0 個,新安裝 1 個,移除 0 個,有 0 個未被升級。

需要下載 143 kB 的套件檔。

此操作完成之後,會多佔用 398 kB 的磁碟空間。

下載:1 http://mirror.ossplanet.net/raspbian/raspbian buster/main armhf flac armhf 1.3.2-3 [143 kB]

取得 143 kB 用了 2s (60.6 kB/s)

選取了原先未選的套件 flac

(讀取資料庫 ... 目前共安裝了 99666 個檔案和目錄。)

正在準備解包 .../flac_1.3.2-3_armhf.deb……

Unpacking flac (1.3.2-3) ...

設定 flac (1.3.2-3) ...

執行 man-db (2.8.5-2) 的觸發程式……

 

 

SpeechRecognition安裝

SpeechRecognition安裝如同官網所列的方式,只要採用PIP來安裝就可,SpeechRecognition官網如下:

https://pypi.org/project/SpeechRecognition/

 

04-04.png

 

 

安裝命令與資訊如下:

pi@raspberrypi:~ $ sudo pip3 install SpeechRecognition

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple

Collecting SpeechRecognition

  Downloading https://files.pythonhosted.org/packages/26/e1/7f5678cd94ec1234269d23756dbdaa4c8cfaed973412f88ae8adf7893a50/SpeechRecognition-3.8.1-py2.py3-none-any.whl (32.8MB)

    100% |████████████████████████████████| 32.8MB 2.2kB/s

Installing collected packages: SpeechRecognition

Successfully installed SpeechRecognition-3.8.1

 

SpeechRecognition測試

在此用二個簡易的Python files來測試SpeechRecognition安裝的完成與否,檔案與測試內容如下各節:

01-SpeechRecognition Test File

檔案01-SpeechRecognition Test File.py,此測試程式用來測試最基礎的SpeechRecognition功能,只要連上網路,就可以將語音檔en-0523.wavrecognize_google辨識成文字。

在此以Thonny執行,透過recognize_google(),就可以將en-0523.wav英文語音檔辨識成:

here's some pics that Mark took of his house

 

執行過程如下:

04-05.png

 

02-SpeechRecognition Test

檔案02-SpeechRecognition Test.py,此測試程式用來測試麥克風輸入的功能,假若安裝PyAudio沒有完整,就會在SpeechRecognition企圖實體化Microphone物件時就會出現”AttributeError”的例外錯誤(exception)。有關PyAudio安裝問題可以參考後續有關問題除錯部分的方法。

如果是出先ALSA lib pcm…Unknown PCM cards等警訊如下列訊息例子,可以先忽略仍然可以進行語音辨識的測試,要解決ALSA lib pcm的問題可以可以參考後續有關此問題除錯部分的方法。

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port

ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port

ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

 

在這兒可以測試recognize_google()英文或中文辨識,在此default設定先以中文進行測試,所以出現請講中文,應為使用recognize_google(audio_input, language="zh-TW")

04-06.png

 

至於Sphinx測試可以remark以下這行程式碼

# text_output = store.recognize_google(audio_input, language="zh-TW")

解除以下這行程式碼進行測試

text_output = store.recognize_sphinx(audio_input)

假如可以有回饋語音辨識答案無倫對錯就表示sphinx安裝成功,倘若無法辨識就有可能sphinx安裝有問題,請查sphinx安裝流程。

04-07.png

 

Speak...

Recording time: 05:35:03

Couldn't process the audio input.?

SpeechRecognition問題除錯

FLAC encoder錯誤: raise OSError("FLAC conversion utility not available…)

未安裝FLAC或沒安裝FLAC完整,在一開始執行01-SpeechRecognition Test File.py就應該會出現類似以下的錯誤訊息:

packages/speech_recognition/__init__.py", line 445, in get_flac_data

    flac_converter = get_flac_converter()

  File "/usr/local/lib/python3.4/dist-packages/speech_recognition/__init__.py", line 1196, in get_flac_converter

    raise OSError("FLAC conversion utility not available - consider installing the FLAC command line application by running `apt-get install flac` or your operating system's equivalent")

OSError: FLAC conversion utility not available - consider installing the FLAC command line application by running `apt-get install flac` or your operating system's equivalent

請參考前面FLAC安裝的步驟重新安裝。

 

實體化Microphone物件時就會出現”AttributeError”的例外錯誤(exception)

可能是未安裝或沒完整安裝pyaudio,或也有可能已經安裝好pyaudio但是並未安裝或沒完整安裝好下層Portaudio;這時實體化Microphone物件時就會出現”AttributeError”的例外錯誤(exception)。例如執行02-SpeechRecognition Test.py就會出現類似以下的錯誤訊息:

packages/speech_recognition/__init__.py", line 108, in get_pyaudio

    import pyaudio

ModuleNotFoundError: No module named 'pyaudio'

 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/pi/_Python/_AppNote/Speech Recognition/_Python Code/SpeechRecognition Test1.py", line 10, in <module>

    with SRG.Microphone() as s:

  File "/usr/local/lib/python3.9/dist-packages/speech_recognition/__init__.py", line 79, in __init__

    self.pyaudio_module = self.get_pyaudio()

  File "/usr/local/lib/python3.9/dist-packages/speech_recognition/__init__.py", line 110, in get_pyaudio

    raise AttributeError("Could not find PyAudio; check installation")

AttributeError: Could not find PyAudio; check installation

解決方法就是參考PyAudio安裝章節重新安裝。

 

執行卡在”recognizer_instance.listen”訊息上

特別是在呼叫Microphone.MicrophoneStream.read功能時發生,這種情況通常發生在Raspberry Pi裝置當他並沒有語音輸入能力的時候。這時執行會卡在此訊息是因為PyAudio不會檢查有沒有語音輸入裝置,他只是簡單的鎖定住初始設定的麥克風(default microphone)並從中讀回語音資料,Raspberry Pi原始裝置並沒有麥克風的能力,所以造成這種問題;因此在Raspberry Pi需要自行插入USB sound card 或是USB microphone

除此之外,還需要修改MICROPHONE_INDEX對應到插入USB sound card 或是USB microphone;作法就是需要將所有Microphone()呼叫改為Microphone(device_index=MICROPHONE_INDEX)呼叫;其中MICROPHONE_INDEX就是硬體指派的index of the microphone

要找出硬體指派的MICROPHONE_INDEX的值,可以執行以下的Python程式碼:

 

import speech_recognition as sr

for index, name in enumerate(sr.Microphone.list_microphone_names()):

print("Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name))

 

一般該程式會印出以下的資訊:

:

Microphone with name "HDA Intel HDMI: 0 (hw:0,3)" found for `Microphone(device_index=0)`

Microphone with name "HDA Intel HDMI: 1 (hw:0,7)" found for `Microphone(device_index=1)`

Microphone with name "HDA Intel HDMI: 2 (hw:0,8)" found for `Microphone(device_index=2)`

Microphone with name "Blue Snowball: USB Audio (hw:1,0)" found for `Microphone(device_index=3)`

Microphone with name "hdmi" found for `Microphone(device_index=4)`

Microphone with name "pulse" found for `Microphone(device_index=5)`

Microphone with name "default" found for `Microphone(device_index=6)`

 

Now, to use the Snowball microphone, you would change ``Microphone()`` to ``Microphone(device_index=3)``.

 

 

當我已經停止或完成說話後,Recognizer試著辨認對話但出不來

Try increasing the ``recognizer_instance.energy_threshold`` property. This is basically how sensitive the recognizer is to when recognition should start. Higher values mean that it will be less sensitive, which is useful if you are in a loud room.

嘗試增加"recognizer_instance.energy_threshold"屬性。這基本上是識別器對識別何時開始的敏感程度。較高的值意味著它的靈敏度會降低,如果您在嘈雜的房間里,這將非常有用。

 

This value depends entirely on your microphone or audio data. There is no one-size-fits-all value, but good values typically range from 50 to 4000.

此值完全取決於您的麥克風或音訊數據。沒有放之四海而皆準的值,但良好的值通常在 50 4000 之間。

 

Also, check on your microphone volume settings. If it is too sensitive, the microphone may be picking up a lot of ambient noise. If it is too insensitive, the microphone may be rejecting speech as just noise.

另外,請檢查麥克風音量設置。如果太敏感,麥克風可能會拾取很多環境雜訊。如果它太不敏感,麥克風可能會拒絕語音,因為它只是噪音。

 

從一開始Recognizer聆聽接收就無法辨認對話

The ``recognizer_instance.energy_threshold`` property is probably set to a value that is too high to start off with, and then being adjusted lower automatically by dynamic energy threshold adjustment. Before it is at a good level, the energy threshold is so high that speech is just considered ambient noise.

"recognizer_instance.energy_threshold"屬性可能設置為一個太高而無法開始使用的值,然後通過動態能量閾值調整自動調整為較低值。在達到良好水準之前,能量閾值是如此之高,以至於語音只被認為是環境雜訊。

 

The solution is to decrease this threshold, or call ``recognizer_instance.adjust_for_ambient_noise`` beforehand, which will set the threshold to a good value automatically.

解決方案是降低此閾值,或事先調用"recognizer_instance.adjust_for_ambient_noise",這將自動將閾值設置為一個良好的值。

 

Recognizer 無法了解我指定的翻譯語言

Try setting the recognition language to your language/dialect. To do this, see the documentation for

嘗試將識別語言設置為您的語言/方言。若要執行此操作,請參閱文檔 ``recognizer_instance.recognize_sphinx``, ``recognizer_instance.recognize_google``, ``recognizer_instance.recognize_wit``, ``recognizer_instance.recognize_bing``, ``recognizer_instance.recognize_api``, ``recognizer_instance.recognize_houndify``, and ``recognizer_instance.recognize_ibm``.

 

For example, if your language/dialect is British English, it is better to use ``"en-GB"`` as the language rather than ``"en-US"``.

例如,如果您的語言/方言是英國英語,則最好使用"en-GB""作為語言,而不是"en-US""

 

 

Ubuntu/Debian作業系統下,我在終端機terminal介面上得到一堆煩人的輸出 “bt_audio_service_open: [...] Connection refused”警訊

The "bt_audio_service_open" error means that you have a Bluetooth audio device, but as a physical device is not currently connected, we can't actually use it - if you're not using a Bluetooth microphone, then this can be safely ignored. If you are, and audio isn't working, then double check to make sure your microphone is actually connected. There does not seem to be a simple way to disable these messages.

"bt_audio_service_open"錯誤意味著您擁有藍牙音訊設備,但由於物理設備當前未連接,我們實際上無法使用它 - 如果您沒有使用藍牙麥克風,則可以安全地忽略它。如果是,並且音訊無法正常工作,請仔細檢查以確保您的麥克風已實際連接。似乎沒有一種簡單的方法來禁用這些消息。

 

For "jack server is not running or cannot be started" or "connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)" or "attempt to connect to server failed", these are caused by ALSA trying to connect to JACK, and can be safely ignored. I'm not aware of any simple way to turn those messages off at this time, besides `entirely disabling printing while starting the microphone

可以參考以下編號182 issue

https://github.com/Uberi/speech_recognition/issues/182#issuecomment-266256337

對於「插孔伺服器未運行或無法啟動」或「連接(2)調用/dev/shm/jack-1000/default/jack_0失敗(err=沒有這樣的檔或目錄)」或"嘗試連接到伺服器失敗",這些都是由ALSA嘗試連接到JACK引起的,可以安全地忽略。我不知道此時有任何簡單的方法來關閉這些消息,除了"在啟動麥克風時完全禁用列印"

可以參考以下編號182 issue

 

終端機terminal介面上得到一堆煩人的輸出 ALSA lib pcm…Unknown PCM警訊

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port

ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port

ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

 

有關"ALSA lib [...] Unknown PCM"的錯誤,可以參考以下StackOverflow的回答

http://stackoverflow.com/questions/7088672/pyaudio-working-but-spits-out-error-messages-each-time

有關"ALSA lib [...] Unknown PCM"的錯誤,可以參考以下StackOverflow的回答

  • Method 1

Basically, to get rid of an error of the form "Unknown PCM cards.pcm.rear", simply comment out ``pcm.rear cards.pcm.rear`` in ``/usr/share/alsa/alsa.conf``, ``~/.asoundrc``, and ``/etc/asound.conf``.

基本上,要擺脫"Unknown PCM cards.pcm.rear"形式的錯誤,只需在"/usr/share/alsa/alsa.conf""'~/.asoundrc''(option)''/etc/asound.conf''中註釋掉''pcm.rear'''

pcm.rear cards.pcm.rear

pcm.center_lfe cards.pcm.center_lfe

pcm.side cards.pcm.side

:

pcm.hdmi cards.pcm.hdmi

pcm.modem cards.pcm.modem

pcm.phoneline cards.pcm.phoneline

 

Once you comment out these lines, those error message will be gone. You may also want to check ~/.asoundrc and /etc/asound.conf.

  • Method 2

That's said, some of those messages are telling something is wrong in your configuration, though they do not cause any real problem. I do not recommend you clean up the alsa.conf, because it's from ALSA originally, it may be overwritten when you update alsa-lib.

也就是說,其中一些消息告訴您的配置中存在問題,儘管它們不會導致任何實際問題。我不建議你清理alsa.conf,因為它最初來自ALSA,當你更新alsa-lib時,它可能會被覆蓋。

There is a way to suppress the message in Python, here is a sample code:

#!/usr/bin/env python

from ctypes import *

import pyaudio

 

# From alsa-lib Git 3fd4ab9be0db7c7430ebd258f2717a976381715d

# $ grep -rn snd_lib_error_handler_t

# include/error.h:59:typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */;

# Define our error handler type

ERROR_HANDLER_FUNC = CFUNCTYPE(None, c_char_p, c_int, c_char_p, c_int, c_char_p)

def py_error_handler(filename, line, function, err, fmt):

  print 'messages are yummy'

c_error_handler = ERROR_HANDLER_FUNC(py_error_handler)

 

asound = cdll.LoadLibrary('libasound.so')

# Set error handler

asound.snd_lib_error_set_handler(c_error_handler)

# Initialize PyAudio

p = pyaudio.PyAudio()

p.terminate()

 

print '-'*40

# Reset to default error handler

asound.snd_lib_error_set_handler(None)

# Re-initialize

p = pyaudio.PyAudio()

p.terminate()

An output from my computer:

messages are yummy

messages are yummy

messages are yummy

messages are yummy

messages are yummy

messages are yummy

----------------------------------------

ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side

ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream

ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave

 

Those messages are printed out by alsa-lib, not PyAudio or PortAudio. The code directly uses alsa-lib snd_lib_error_set_handler function to set an error handler py_error_handler, which you can use it to drop any message.

I have checked other Python ALSA bindings, pyalsa and PyAlsaAudio, they do not support setting error handler. However, there is an issue on PortAudio, all ALSA error messages seemed to be suppressed before.

這些消息是由alsa-lib列印出來的,而不是PyAudioPortAudio。該代碼直接使用 alsa-lib snd_lib_error_set_handler 函數來設置錯誤處理程式py_error_handler,您可以使用它來刪除任何消息。

我已經檢查了其他Python ALSA綁定,pyalsaPyAlsaAudio,它們不支援設置錯誤處理程式。但是,PortAudio上有一個問題,所有ALSA錯誤消息似乎都被抑制了。

 

 

  • Method 3

checked which modules where loaded

pi@raspberrypi:~ $ lsmod | grep '^snd' | column -t

snd_usb_audio    233472  3

snd_hwdep        16384   1   snd_usb_audio

snd_usbmidi_lib  32768   1   snd_usb_audio

snd_rawmidi      32768   1   snd_usbmidi_lib

snd_seq_device   16384   1   snd_rawmidi

snd_bcm2835      24576   2

snd_pcm          110592  2   snd_usb_audio,snd_bcm2835

snd_timer        32768   1   snd_pcm

snd              77824   18  snd_hwdep,snd_usb_audio,snd_timer,snd_rawmidi,snd_usbmidi_lib,snd_seq_device,snd_bcm2835,snd_pcm

 

pi@raspberrypi:~ $ ls -l /dev/snd

total 0

drwxr-xr-x  2 root root       60  2  7 12:17 by-id

drwxr-xr-x  2 root root       80  2  7 12:17 by-path

crw-rw----+ 1 root audio 116,  0  2  7 12:17 controlC0

crw-rw----+ 1 root audio 116, 32  2  7 12:17 controlC1

crw-rw----+ 1 root audio 116, 16  2  7 12:17 pcmC0D0p

crw-rw----+ 1 root audio 116, 56  2  7 12:17 pcmC1D0c

crw-rw----+ 1 root audio 116, 48  2  7 13:19 pcmC1D0p

crw-rw----+ 1 root audio 116,  1  2  7 12:17 seq

crw-rw----+ 1 root audio 116, 33  2  7 12:17 timer

here are some additional information

pi@raspberrypi:~ $ aplay -l

**** List of PLAYBACK Hardware Devices ****

card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]

  Subdevices: 8/8

  Subdevice #0: subdevice #0

  Subdevice #1: subdevice #1

  Subdevice #2: subdevice #2

  Subdevice #3: subdevice #3

  Subdevice #4: subdevice #4

  Subdevice #5: subdevice #5

  Subdevice #6: subdevice #6

  Subdevice #7: subdevice #7

card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]

  Subdevices: 1/1

  Subdevice #0: subdevice #0

 

pi@raspberrypi:~ $ cat /proc/asound/cards

 0 [b1             ]: bcm2835_hdmi - bcm2835 HDMI 1

                      bcm2835 HDMI 1

 1 [Device         ]: USB-Audio - USB PnP Sound Device

                      C-Media Electronics Inc. USB PnP Sound Device at usb-20980000.usb-1, full speed

 

 

後記

本文為個人學習的經驗,後續有所改進將再發文分享;本人因工作因素發文後並不會經常檢視讀者問題,對於沒法及時回覆問題敬請見諒!

若覺本文對讀者有所幫助,可回覆感想及你的分享!謝謝!

arrow
arrow

    Philip4G 發表在 痞客邦 留言(0) 人氣()