Skip to content

Commit 765e2cf

Browse files
authored
Merge pull request Uberi#746 from ftnext/test-on-windows
Run unittests on Windows in CI
2 parents eb3cf1e + 654c471 commit 765e2cf

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

.github/workflows/unittests.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,40 @@ on:
1010

1111
jobs:
1212
build:
13-
runs-on: ubuntu-latest
14-
1513
strategy:
1614
fail-fast: true
1715
matrix:
18-
python-version: ["3.8", "3.9", "3.10", "3.11"]
19-
16+
include:
17+
- os: ubuntu-latest
18+
python-version: "3.8"
19+
- os: ubuntu-latest
20+
python-version: "3.9"
21+
- os: ubuntu-latest
22+
python-version: "3.10"
23+
- os: ubuntu-latest
24+
python-version: "3.11"
25+
- os: windows-latest
26+
python-version: "3.11"
27+
runs-on: ${{ matrix.os }}
2028
steps:
2129
- uses: actions/checkout@v3
2230
- name: Set up Python ${{ matrix.python-version }}
2331
uses: actions/setup-python@v4
2432
with:
2533
python-version: ${{ matrix.python-version }}
2634
- name: Install build dependencies
35+
if: matrix.os == 'ubuntu-latest'
2736
run: |
2837
sudo apt-get update
2938
sudo apt-get install --no-install-recommends -y libpulse-dev libasound2-dev
30-
sudo apt-get install --no-install-recommends -y ffmpeg
31-
- name: Install Python dependencies
39+
- name: Install ffmpeg (for Whisper)
40+
uses: FedericoCarboni/setup-ffmpeg@v3
41+
- name: Install Python dependencies (Ubuntu only)
42+
if: matrix.os == 'ubuntu-latest'
3243
run: |
3344
python -m pip install 'pocketsphinx<5'
45+
- name: Install Python dependencies
46+
run: |
3447
python -m pip install .[whisper-local,whisper-api]
3548
- name: Test with unittest
3649
run: |

tests/test_recognition.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
import os
5+
import sys
56
import unittest
67

78
import speech_recognition as sr
@@ -15,6 +16,7 @@ def setUp(self):
1516

1617
def test_recognizer_attributes(self):
1718
r = sr.Recognizer()
19+
attributes = set(dir(r))
1820

1921
self.assertEqual(r.energy_threshold, 300)
2022
self.assertTrue(r.dynamic_energy_threshold)
@@ -24,7 +26,10 @@ def test_recognizer_attributes(self):
2426
self.assertIsNone(r.operation_timeout)
2527
self.assertEqual(r.phrase_threshold, 0.3)
2628
self.assertEqual(r.non_speaking_duration, 0.5)
29+
# https://github.com/Uberi/speech_recognition/issues/743
30+
self.assertTrue("recognize_google" in attributes)
2731

32+
@unittest.skipIf(sys.platform.startswith("win"), "skip on Windows")
2833
def test_sphinx_english(self):
2934
r = sr.Recognizer()
3035
with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)

tests/test_special_features.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
import os
5+
import sys
56
import unittest
67

78
import speech_recognition as sr
@@ -12,6 +13,7 @@ def setUp(self):
1213
self.AUDIO_FILE_EN = os.path.join(os.path.dirname(os.path.realpath(__file__)), "english.wav")
1314
self.addTypeEqualityFunc(str, self.assertSameWords)
1415

16+
@unittest.skipIf(sys.platform.startswith("win"), "skip on Windows")
1517
def test_sphinx_keywords(self):
1618
r = sr.Recognizer()
1719
with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)

0 commit comments

Comments
 (0)