From 60a454bb003ad65d309eb40a67e59317f85f96c2 Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:15:11 +0000 Subject: [PATCH 1/7] chore: Run tests on Python 3.13 (excluding whisper-local) * PyTorch does not support 3.13 yet --- .github/workflows/unittests.yml | 10 ++++++++-- tests/test_whisper_recognition.py | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index b6b4c542..bb38433f 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -22,6 +22,8 @@ jobs: python-version: "3.11" - os: ubuntu-latest python-version: "3.12" + - os: ubuntu-latest + python-version: "3.13" - os: windows-latest python-version: "3.11" runs-on: ${{ matrix.os }} @@ -43,10 +45,14 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | python -m pip install 'pocketsphinx<5' - - name: Install Python dependencies (Ubuntu) - if: matrix.os == 'ubuntu-latest' + - name: Install Python dependencies (Ubuntu, <=3.12) + if: matrix.os == 'ubuntu-latest' and matrix.python-version != '3.13' run: | python -m pip install .[dev,audio,whisper-local,whisper-api] + - name: Install Python dependencies (Ubuntu, 3.13) + if: matrix.os == 'ubuntu-latest' and matrix.python-version == '3.13' + run: | + python -m pip install .[dev,audio,whisper-api] - name: Install Python dependencies (Windows) if: matrix.os == 'windows-latest' run: | diff --git a/tests/test_whisper_recognition.py b/tests/test_whisper_recognition.py index a0054961..a1ba28b9 100644 --- a/tests/test_whisper_recognition.py +++ b/tests/test_whisper_recognition.py @@ -1,4 +1,5 @@ -from unittest import TestCase +import sys +from unittest import TestCase, skipif from unittest.mock import MagicMock, patch import numpy as np @@ -6,6 +7,7 @@ from speech_recognition import AudioData, Recognizer +@skipif(sys.version_info >= (3, 13), "skip on Python 3.13") @patch("speech_recognition.io.BytesIO") @patch("soundfile.read") @patch("torch.cuda.is_available") From f6964768159b76f175ef102a1dbcf3f851482afe Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:19:33 +0000 Subject: [PATCH 2/7] bugfix: Action stntax error --- .github/workflows/unittests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index bb38433f..da81019a 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -46,11 +46,11 @@ jobs: run: | python -m pip install 'pocketsphinx<5' - name: Install Python dependencies (Ubuntu, <=3.12) - if: matrix.os == 'ubuntu-latest' and matrix.python-version != '3.13' + if: matrix.os == 'ubuntu-latest' && matrix.python-version != '3.13' run: | python -m pip install .[dev,audio,whisper-local,whisper-api] - name: Install Python dependencies (Ubuntu, 3.13) - if: matrix.os == 'ubuntu-latest' and matrix.python-version == '3.13' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: | python -m pip install .[dev,audio,whisper-api] - name: Install Python dependencies (Windows) From 4ce2121e1607f40bf6aeee8e78b6e1d834f3172d Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:24:37 +0000 Subject: [PATCH 3/7] bugfix: Install deadlib's aifc in advance. Needed on editable install --- .github/workflows/unittests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index da81019a..c1d34393 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -52,6 +52,7 @@ jobs: - name: Install Python dependencies (Ubuntu, 3.13) if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: | + python -m pip install standard-aifc python -m pip install .[dev,audio,whisper-api] - name: Install Python dependencies (Windows) if: matrix.os == 'windows-latest' From 72e72906e81732f40589a53968cb1b6c88f56f13 Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:28:40 +0000 Subject: [PATCH 4/7] bugfix: Pip install in aifc installed environment --- .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 c1d34393..96f6ff0e 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -53,7 +53,7 @@ jobs: if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: | python -m pip install standard-aifc - python -m pip install .[dev,audio,whisper-api] + python -m pip install --no-build-isolation .[dev,audio,whisper-api] - name: Install Python dependencies (Windows) if: matrix.os == 'windows-latest' run: | From 2428c8072d2aecea01cb5b5de2c71598740bdba2 Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:32:17 +0000 Subject: [PATCH 5/7] bugfix: setuptools is needed at no build isolation install --- .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 96f6ff0e..f41d181c 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -52,7 +52,7 @@ jobs: - name: Install Python dependencies (Ubuntu, 3.13) if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: | - python -m pip install standard-aifc + python -m pip install standard-aifc setuptools python -m pip install --no-build-isolation .[dev,audio,whisper-api] - name: Install Python dependencies (Windows) if: matrix.os == 'windows-latest' From a24dd0daa9fe5a334d9ffd87c5dd5895280341b5 Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:56:02 +0000 Subject: [PATCH 6/7] bugfix: Fix typo --- tests/test_whisper_recognition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_whisper_recognition.py b/tests/test_whisper_recognition.py index a1ba28b9..c4665e27 100644 --- a/tests/test_whisper_recognition.py +++ b/tests/test_whisper_recognition.py @@ -1,5 +1,5 @@ import sys -from unittest import TestCase, skipif +from unittest import TestCase, skipIf from unittest.mock import MagicMock, patch import numpy as np @@ -7,7 +7,7 @@ from speech_recognition import AudioData, Recognizer -@skipif(sys.version_info >= (3, 13), "skip on Python 3.13") +@skipIf(sys.version_info >= (3, 13), "skip on Python 3.13") @patch("speech_recognition.io.BytesIO") @patch("soundfile.read") @patch("torch.cuda.is_available") From aadaec733fd70835353ce6b937069a37efba91a4 Mon Sep 17 00:00:00 2001 From: nikkie Date: Sun, 3 Nov 2024 15:59:36 +0000 Subject: [PATCH 7/7] bugfix: import in test case --- tests/test_whisper_recognition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_whisper_recognition.py b/tests/test_whisper_recognition.py index c4665e27..4e7d76f0 100644 --- a/tests/test_whisper_recognition.py +++ b/tests/test_whisper_recognition.py @@ -2,8 +2,6 @@ from unittest import TestCase, skipIf from unittest.mock import MagicMock, patch -import numpy as np - from speech_recognition import AudioData, Recognizer @@ -16,6 +14,8 @@ class RecognizeWhisperTestCase(TestCase): def test_default_parameters( self, load_model, is_available, sf_read, BytesIO ): + import numpy as np + whisper_model = load_model.return_value transcript = whisper_model.transcribe.return_value audio_array = MagicMock()