diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 01ede18f..00625686 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -10,13 +10,21 @@ on: jobs: build: - runs-on: ubuntu-latest - strategy: fail-fast: true matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - + include: + - os: ubuntu-latest + python-version: "3.8" + - os: ubuntu-latest + python-version: "3.9" + - os: ubuntu-latest + python-version: "3.10" + - os: ubuntu-latest + python-version: "3.11" + - os: windows-latest + python-version: "3.11" + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -24,13 +32,18 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install build dependencies + if: matrix.os == 'ubuntu-latest' 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 ffmpeg - - name: Install Python dependencies + - name: Install ffmpeg (for Whisper) + uses: FedericoCarboni/setup-ffmpeg@v3 + - name: Install Python dependencies (Ubuntu only) + if: matrix.os == 'ubuntu-latest' run: | python -m pip install 'pocketsphinx<5' + - name: Install Python dependencies + run: | python -m pip install .[whisper-local,whisper-api] - name: Test with unittest run: | diff --git a/tests/test_recognition.py b/tests/test_recognition.py index bb0ce3a9..90c17521 100644 --- a/tests/test_recognition.py +++ b/tests/test_recognition.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import os +import sys import unittest import speech_recognition as sr @@ -15,6 +16,7 @@ def setUp(self): def test_recognizer_attributes(self): r = sr.Recognizer() + attributes = set(dir(r)) self.assertEqual(r.energy_threshold, 300) self.assertTrue(r.dynamic_energy_threshold) @@ -24,7 +26,10 @@ def test_recognizer_attributes(self): self.assertIsNone(r.operation_timeout) self.assertEqual(r.phrase_threshold, 0.3) self.assertEqual(r.non_speaking_duration, 0.5) + # https://github.com/Uberi/speech_recognition/issues/743 + self.assertTrue("recognize_google" in attributes) + @unittest.skipIf(sys.platform.startswith("win"), "skip on Windows") def test_sphinx_english(self): r = sr.Recognizer() with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source) diff --git a/tests/test_special_features.py b/tests/test_special_features.py index f249356e..9dd2574e 100644 --- a/tests/test_special_features.py +++ b/tests/test_special_features.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import os +import sys import unittest import speech_recognition as sr @@ -12,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.startswith("win"), "skip on Windows") def test_sphinx_keywords(self): r = sr.Recognizer() with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)