Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittests.yml: Refactor testing #791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,50 @@ 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
- name: Set up Python ${{ matrix.python-version }}
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/
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def run(self):
],
python_requires=">=3.9",
install_requires=[
"typing-extensions",
"setuptools; python_version>='3.13'",
"standard-aifc; python_version>='3.13'",
"audioop-lts; python_version>='3.13'",
"typing-extensions",
],
)
1 change: 1 addition & 0 deletions tests/test_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions tests/test_special_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading