Skip to content

Commit c898560

Browse files
authored
Merge pull request Uberi#418 from native-api/fix_build
Fix Travis build
2 parents 350397d + 7e7902b commit c898560

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ addons:
1414
packages:
1515
- swig
1616
- libpulse-dev
17+
- libasound2-dev
1718
install:
19+
- trap 'sleep 3' ERR
1820
- pip install pocketsphinx monotonic
1921
- pip install flake8 rstcheck
2022
- pip install -e .
2123
script:
22-
- flake8 --ignore=E501,E701 speech_recognition tests examples setup.py # ignore errors for long lines and multi-statement lines
24+
- flake8 --ignore=E501,E701,W504 speech_recognition tests examples setup.py # ignore errors for long lines and multi-statement lines
2325
- rstcheck README.rst reference/*.rst # ensure RST is well-formed
2426
- python -m unittest discover --verbose # run unit tests
2527
sudo: false # this allows TravisCI to use the fast Docker build environment rather than the slower VMs

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Note that the versions available in most package repositories are outdated and w
130130
See `Notes on using PocketSphinx <https://github.com/Uberi/speech_recognition/blob/master/reference/pocketsphinx.rst>`__ for information about installing languages, compiling PocketSphinx, and building language packs from online resources. This document is also included under ``reference/pocketsphinx.rst``.
131131

132132
Google Cloud Speech Library for Python (for Google Cloud Speech API users)
133-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134134

135135
`Google Cloud Speech library for Python <https://cloud.google.com/speech-to-text/docs/quickstart>`__ is required if and only if you want to use the Google Cloud Speech API (``recognizer_instance.recognize_google_cloud``).
136136

reference/library-reference.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Returns the most likely transcription if ``show_all`` is false (the default). Ot
211211
Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if there are any issues with the Sphinx installation.
212212

213213
``recognizer_instance.recognize_google(audio_data: AudioData, key: Union[str, None] = None, language: str = "en-US", , pfilter: Union[0, 1], show_all: bool = False) -> Union[str, Dict[str, Any]]``
214-
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
214+
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
215215

216216
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Speech Recognition API.
217217

speech_recognition/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def recognize_sphinx(self, audio_data, language="en-US", keyword_entries=None, g
831831
fsg = FsgModel(fsg_path, decoder.get_logmath(), 7.5)
832832
decoder.set_fsg(grammar_name, fsg)
833833
decoder.set_search(grammar_name)
834-
834+
835835
decoder.start_utt() # begin utterance processing
836836
decoder.process_raw(raw_data, False, True) # process audio data with recognition enabled (no_search = False), as a full utterance (full_utt = True)
837837
decoder.end_utt() # stop utterance processing
@@ -957,7 +957,7 @@ def recognize_google_cloud(self, audio_data, credentials_json=None, language="en
957957
phrases=preferred_phrases
958958
)]
959959
if show_all:
960-
config['enableWordTimeOffsets'] = True # some useful extra options for when we want all the output
960+
config['enableWordTimeOffsets'] = True # some useful extra options for when we want all the output
961961

962962
opts = {}
963963
if self.operation_timeout and socket.getdefaulttimeout() is None:

tests/test_recognition.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def setUp(self):
1616
def test_sphinx_english(self):
1717
r = sr.Recognizer()
1818
with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)
19-
self.assertEqual(r.recognize_sphinx(audio), "wanted to three")
19+
self.assertEqual(r.recognize_sphinx(audio), "one two three")
2020

2121
def test_google_english(self):
2222
r = sr.Recognizer()

tests/test_special_features.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@
1010
class TestSpecialFeatures(unittest.TestCase):
1111
def setUp(self):
1212
self.AUDIO_FILE_EN = os.path.join(os.path.dirname(os.path.realpath(__file__)), "english.wav")
13+
self.addTypeEqualityFunc(str, self.assertSameWords)
1314

1415
def test_sphinx_keywords(self):
1516
r = sr.Recognizer()
1617
with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)
17-
self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("one", 1.0), ("two", 1.0), ("three", 1.0)]), "three two two one ")
18-
self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("wan", 0.95), ("too", 1.0), ("tree", 1.0)]), "tree too wan too wan ")
19-
self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("un", 0.95), ("to", 1.0), ("tee", 1.0)]), "tee to un to un un un ")
18+
self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("one", 1.0), ("two", 1.0), ("three", 1.0)]), "three two one")
19+
self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("wan", 0.95), ("too", 1.0), ("tree", 1.0)]), "tree too wan")
20+
self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("un", 0.95), ("to", 1.0), ("tee", 1.0)]), "tee to un")
21+
22+
def assertSameWords(self, tested, reference, msg=None):
23+
set_tested = set(tested.split())
24+
set_reference = set(reference.split())
25+
if set_tested != set_reference:
26+
raise self.failureException(msg if msg is not None else "%r doesn't consist of the same words as %r" % (tested, reference))
2027

2128

2229
if __name__ == "__main__":

0 commit comments

Comments
 (0)