diff --git a/README.rst b/README.rst index 965bd46a..8cc893c6 100644 --- a/README.rst +++ b/README.rst @@ -118,11 +118,11 @@ If not installed, everything in the library will still work, except attempting t The installation instructions on the PyAudio website are quite good - for convenience, they are summarized below: -* On Windows, install PyAudio using `Pip `__: execute ``pip install pyaudio`` in a terminal. +* On Windows, install with PyAudio using `Pip `__: execute ``pip install SpeechRecognition[audio]`` in a terminal. * On Debian-derived Linux distributions (like Ubuntu and Mint), install PyAudio using `APT `__: execute ``sudo apt-get install python-pyaudio python3-pyaudio`` in a terminal. - * If the version in the repositories is too old, install the latest release using Pip: execute ``sudo apt-get install portaudio19-dev python-all-dev python3-all-dev && sudo pip install pyaudio`` (replace ``pip`` with ``pip3`` if using Python 3). -* On OS X, install PortAudio using `Homebrew `__: ``brew install portaudio``. Then, install PyAudio using `Pip `__: ``pip install pyaudio``. -* On other POSIX-based systems, install the ``portaudio19-dev`` and ``python-all-dev`` (or ``python3-all-dev`` if using Python 3) packages (or their closest equivalents) using a package manager of your choice, and then install PyAudio using `Pip `__: ``pip install pyaudio`` (replace ``pip`` with ``pip3`` if using Python 3). + * If the version in the repositories is too old, install the latest release using Pip: execute ``sudo apt-get install portaudio19-dev python-all-dev python3-all-dev && sudo pip install SpeechRecognition[audio]`` (replace ``pip`` with ``pip3`` if using Python 3). +* On OS X, install PortAudio using `Homebrew `__: ``brew install portaudio``. Then, install with PyAudio using `Pip `__: ``pip install SpeechRecognition[audio]``. +* On other POSIX-based systems, install the ``portaudio19-dev`` and ``python-all-dev`` (or ``python3-all-dev`` if using Python 3) packages (or their closest equivalents) using a package manager of your choice, and then install with PyAudio using `Pip `__: ``pip install SpeechRecognition[audio]`` (replace ``pip`` with ``pip3`` if using Python 3). PyAudio `wheel packages `__ for common 64-bit Python versions on Windows and Linux are included for convenience, under the ``third-party/`` `directory `__ in the repository root. To install, simply run ``pip install wheel`` followed by ``pip install ./third-party/WHEEL_FILENAME`` (replace ``pip`` with ``pip3`` if using Python 3) in the repository `root directory `__. diff --git a/reference/library-reference.rst b/reference/library-reference.rst index 0aa7a8ce..e8b6c7e0 100644 --- a/reference/library-reference.rst +++ b/reference/library-reference.rst @@ -6,7 +6,7 @@ Speech Recognition Library Reference Creates a new ``Microphone`` instance, which represents a physical microphone on the computer. Subclass of ``AudioSource``. -This will throw an ``AttributeError`` if you don't have PyAudio 0.2.11 or later installed. +This will throw an ``AttributeError`` if you don't have PyAudio (0.2.11 or later) installed. If ``device_index`` is unspecified or ``None``, the default microphone is used as the audio source. Otherwise, ``device_index`` should be the index of the device to use for audio input. diff --git a/setup.cfg b/setup.cfg index c5c47909..659471f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,6 +7,8 @@ universal=1 dev = flake8 rstcheck +audio = + PyAudio >= 0.2.11 whisper-local = openai-whisper soundfile diff --git a/speech_recognition/__init__.py b/speech_recognition/__init__.py index dc1bce5c..8261c274 100644 --- a/speech_recognition/__init__.py +++ b/speech_recognition/__init__.py @@ -59,7 +59,7 @@ class Microphone(AudioSource): """ Creates a new ``Microphone`` instance, which represents a physical microphone on the computer. Subclass of ``AudioSource``. - This will throw an ``AttributeError`` if you don't have PyAudio 0.2.11 or later installed. + This will throw an ``AttributeError`` if you don't have PyAudio (0.2.11 or later) installed. If ``device_index`` is unspecified or ``None``, the default microphone is used as the audio source. Otherwise, ``device_index`` should be the index of the device to use for audio input. @@ -108,9 +108,6 @@ def get_pyaudio(): import pyaudio except ImportError: raise AttributeError("Could not find PyAudio; check installation") - from distutils.version import LooseVersion - if LooseVersion(pyaudio.__version__) < LooseVersion("0.2.11"): - raise AttributeError("PyAudio 0.2.11 or later is required (found version {})".format(pyaudio.__version__)) return pyaudio @staticmethod