无法在Google Colab中导入声音设备

时间:2020-09-13 19:06:55

标签: python google-colaboratory python-sounddevice

我正在尝试使用以下代码将声音设备库导入Google Colab:

pip install sounddevice
import sounddevice as sd

但是出现以下错误。

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

    OSError                                   Traceback (most recent call last)
    
    <ipython-input-8-fba28aeb5c71> in <module>()
          7 import numpy as np
          8 import requests
    ----> 9 import sounddevice as sd
         10 import tensorflow as tf
         11 import keras
    
    /usr/local/lib/python3.6/dist-packages/sounddevice.py in <module>()
         69             break
         70     else:
    ---> 71         raise OSError('PortAudio library not found')
         72     _lib = _ffi.dlopen(_libname)
         73 except OSError:
    
    OSError: PortAudio library not found

有没有办法在Colab中使用该库?

1 个答案:

答案 0 :(得分:1)

我通过安装portaudio库来解决此问题。

!sudo apt-get install libportaudio2
!pip install sounddevice

然后导入sounddevice

enter image description here