Skip to content

Commit

Permalink
Merge pull request #746 from ftnext/test-on-windows
Browse files Browse the repository at this point in the history
Run unittests on Windows in CI
  • Loading branch information
ftnext committed Apr 16, 2024
2 parents eb3cf1e + 654c471 commit 765e2cf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,40 @@ 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 }}
uses: actions/setup-python@v4
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: |
Expand Down
5 changes: 5 additions & 0 deletions tests/test_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

import os
import sys
import unittest

import speech_recognition as sr
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_special_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

import os
import sys
import unittest

import speech_recognition as sr
Expand All @@ -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)
Expand Down

0 comments on commit 765e2cf

Please sign in to comment.