From eded4a63d78e30aaa610e189318fdc05956478e2 Mon Sep 17 00:00:00 2001 From: nikkie Date: Thu, 17 Oct 2024 23:46:55 +0000 Subject: [PATCH 1/4] maint: Remove deprecated disutils --- speech_recognition/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/speech_recognition/__init__.py b/speech_recognition/__init__.py index dc1bce5c..99602cef 100644 --- a/speech_recognition/__init__.py +++ b/speech_recognition/__init__.py @@ -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 From a4d74d214f931cf059b9ef5870a49ed791105d17 Mon Sep 17 00:00:00 2001 From: nikkie Date: Thu, 17 Oct 2024 23:47:51 +0000 Subject: [PATCH 2/4] chore] Add extra 'audio' to install PyAudio >= 0.2.11 --- .github/workflows/unittests.yml | 2 +- setup.cfg | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 00625686..a43d93d4 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -44,7 +44,7 @@ jobs: python -m pip install 'pocketsphinx<5' - name: Install Python dependencies run: | - python -m pip install .[whisper-local,whisper-api] + python -m pip install .[audio,whisper-local,whisper-api] - name: Test with unittest run: | python -m doctest speech_recognition/recognizers/google.py -v 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 From 43129c0f91de14f638589b9b6194f4e4430b135b Mon Sep 17 00:00:00 2001 From: nikkie Date: Fri, 18 Oct 2024 11:39:11 +0000 Subject: [PATCH 3/4] bugfix: Revert installation of [audio] extra * Microphone is not tested currently * cope with at other opportunity --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index a43d93d4..00625686 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -44,7 +44,7 @@ jobs: python -m pip install 'pocketsphinx<5' - name: Install Python dependencies run: | - python -m pip install .[audio,whisper-local,whisper-api] + python -m pip install .[whisper-local,whisper-api] - name: Test with unittest run: | python -m doctest speech_recognition/recognizers/google.py -v From 0d5f7daae721efd43f7804083713c4b6312c0dc7 Mon Sep 17 00:00:00 2001 From: nikkie Date: Fri, 18 Oct 2024 17:40:25 +0000 Subject: [PATCH 4/4] docs: Instructions to specify [audio] extra --- README.rst | 8 ++++---- reference/library-reference.rst | 2 +- speech_recognition/__init__.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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/speech_recognition/__init__.py b/speech_recognition/__init__.py index 99602cef..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.