From 4f92962302a33c891832d350cbdaa1b7d950bf30 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 11 Nov 2024 18:52:37 +0100 Subject: [PATCH] unittests.yml: Add macOS to the testing --- .github/workflows/unittests.yml | 45 +++++++++++++++++---------------- setup.py | 5 ++-- tests/test_recognition.py | 1 + tests/test_special_features.py | 1 + 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 8b2a6daa..1bc06ca3 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -11,21 +11,15 @@ on: jobs: build: strategy: - fail-fast: true + fail-fast: false matrix: + os: [ubuntu-latest] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] include: - - os: ubuntu-latest - python-version: "3.9" - - os: ubuntu-latest - python-version: "3.10" - - os: ubuntu-latest - python-version: "3.11" - - os: ubuntu-latest - python-version: "3.12" - - os: ubuntu-latest + - os: macos-latest python-version: "3.13" - os: windows-latest - python-version: "3.11" + python-version: "3.12" # Windows fails on Python >= 3.13 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -33,27 +27,34 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install build dependencies - if: matrix.os == 'ubuntu-latest' + - run: | + python -m pip install --upgrade pip + python -m pip install "setuptools; python_version>='3.13'" "standard-aifc; python_version>='3.13'" + - name: Install build dependencies (Linux) + if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install --no-install-recommends -y libpulse-dev libasound2-dev - sudo apt-get install --no-install-recommends -y portaudio19-dev + sudo apt-get install --no-install-recommends -y libpulse-dev libasound2-dev portaudio19-dev - name: Install ffmpeg (for Whisper) + if: runner.os != 'macOS' uses: FedericoCarboni/setup-ffmpeg@v3 - - name: Install Python dependencies (Ubuntu, <=3.12) - if: matrix.os == 'ubuntu-latest' && matrix.python-version != '3.13' + - name: Install ffmpeg and portaudio on macOS + if: runner.os == 'macOS' + run: | + brew install ffmpeg portaudio + python -m pip install --no-build-isolation .[dev,audio,openai,groq] + - name: Install Python dependencies (Ubuntu, Python <= 3.12) + if: runner.os == 'Linux' && matrix.python-version != '3.13' run: | python -m pip install .[dev,audio,pocketsphinx,whisper-local,openai,groq] - - name: Install Python dependencies (Ubuntu, 3.13) - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' + - name: Install Python dependencies (Linux, Python 3.13) + if: runner.os == 'Linux' && matrix.python-version == '3.13' run: | - python -m pip install standard-aifc setuptools python -m pip install --no-build-isolation .[dev,audio,pocketsphinx,openai,groq] - name: Install Python dependencies (Windows) - if: matrix.os == 'windows-latest' + if: runner.os == 'Windows' run: | python -m pip install .[dev,whisper-local,openai,groq] - name: Test with unittest run: | - pytest --doctest-modules -v speech_recognition/recognizers/ tests/ + pytest --doctest-modules --strict -v -W="ignore: aifc" speech_recognition/recognizers/ tests/ diff --git a/setup.py b/setup.py index efd463ea..f55a7bca 100644 --- a/setup.py +++ b/setup.py @@ -71,8 +71,9 @@ def run(self): ], python_requires=">=3.9", install_requires=[ - "typing-extensions", - "standard-aifc; python_version>='3.13'", "audioop-lts; python_version>='3.13'", + "setuptools; python_version>='3.13'", + "standard-aifc; python_version>='3.13'", + "typing-extensions", ], ) diff --git a/tests/test_recognition.py b/tests/test_recognition.py index 90c17521..5a252527 100644 --- a/tests/test_recognition.py +++ b/tests/test_recognition.py @@ -29,6 +29,7 @@ def test_recognizer_attributes(self): # https://github.com/Uberi/speech_recognition/issues/743 self.assertTrue("recognize_google" in attributes) + @unittest.skipIf(sys.platform == "darwin", "skip on macOS") @unittest.skipIf(sys.platform.startswith("win"), "skip on Windows") def test_sphinx_english(self): r = sr.Recognizer() diff --git a/tests/test_special_features.py b/tests/test_special_features.py index 9dd2574e..054ebb26 100644 --- a/tests/test_special_features.py +++ b/tests/test_special_features.py @@ -13,6 +13,7 @@ def setUp(self): self.AUDIO_FILE_EN = os.path.join(os.path.dirname(os.path.realpath(__file__)), "english.wav") self.addTypeEqualityFunc(str, self.assertSameWords) + @unittest.skipIf(sys.platform == "darwin", "skip on macOS") @unittest.skipIf(sys.platform.startswith("win"), "skip on Windows") def test_sphinx_keywords(self): r = sr.Recognizer()