Skip to content

Support pocketsphinx 5.0.0 #626

@ftnext

Description

@ftnext

In review of #625 , I found that we need to support pocketsphinx 5.0.0.
5.0.0 released on this October: https://github.com/cmusphinx/pocketsphinx/releases/tag/v5.0.0

Steps to reproduce

  1. Set up virtual environment including pip install pocketsphinx
  2. python -m unittest discover

Expected behaviour

All tests passed

Actual behaviour

$ python -m unittest discover
...............sssresult2:
{   'alternative': [   {'confidence': 0.96296197, 'transcript': '砸自己的脚'},
                       {'transcript': '咱自己的脚'},
                       {'transcript': '打自己的脚'},
                       {'transcript': '咱自己的角'},
                       {'transcript': '砸自己的角'}],
    'final': True}
.result2:
{   'alternative': [   {'confidence': 0.77418035, 'transcript': '123'},
                       {'transcript': '1 2 3'},
                       {'transcript': 'one two three'},
                       {'transcript': '1-2-3'},
                       {'transcript': 'one-two-three'}],
    'final': True}
.result2:
{   'alternative': [   {   'confidence': 0.93855578,
                           'transcript': "et c'est la dictée numéro 1"},
                       {'transcript': "eh c'est la dictée numéro 1"},
                       {'transcript': "hé c'est la dictée numéro 1"},
                       {'transcript': "hey c'est la dictée numéro 1"},
                       {'transcript': "c'est la dictée numéro 1"}],
    'final': True}
.ssss/.../speech_recognition-pr/speech_recognition/__init__.py:812: DeprecationWarning: default_config() is deprecated, just call Config() constructor
  config = pocketsphinx.Decoder.default_config()
./.../speech_recognition-pr/venv/lib/python3.9/site-packages/past/builtins/misc.py:45: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  from imp import reload
/.../speech_recognition-pr/venv/lib/python3.9/site-packages/whisper/__init__.py:40: ResourceWarning: unclosed file <_io.BufferedReader name='/.../.cache/whisper/small.pt'>
  model_bytes = open(download_target, "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./.../speech_recognition-pr/venv/lib/python3.9/site-packages/whisper/__init__.py:40: ResourceWarning: unclosed file <_io.BufferedReader name='/.../.cache/whisper/base.pt'>
  model_bytes = open(download_target, "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./.../speech_recognition-pr/venv/lib/python3.9/site-packages/whisper/__init__.py:40: ResourceWarning: unclosed file <_io.BufferedReader name='/.../.cache/whisper/base.pt'>
  model_bytes = open(download_target, "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
.s/.../speech_recognition-pr/speech_recognition/__init__.py:812: DeprecationWarning: default_config() is deprecated, just call Config() constructor
  config = pocketsphinx.Decoder.default_config()
/.../speech_recognition-pr/speech_recognition/__init__.py:830: DeprecationWarning: set_kws() is deprecated, use add_kws() instead
  decoder.set_kws("keywords", f.name)
/.../speech_recognition-pr/speech_recognition/__init__.py:831: DeprecationWarning: set_search() is deprecated, use activate_search() instead
  decoder.set_search("keywords")
F
======================================================================
FAIL: test_sphinx_keywords (test_special_features.TestSpecialFeatures)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/.../speech_recognition-pr/tests/test_special_features.py", line 19, in test_sphinx_keywords
    self.assertEqual(r.recognize_sphinx(audio, keyword_entries=[("wan", 0.95), ("too", 1.0), ("tree", 1.0)]), "tree too wan")
AssertionError: 'wan  too  wan  too ' doesn't consist of the same words as 'tree too wan'

----------------------------------------------------------------------
Ran 31 tests in 18.435s

FAILED (failures=1, skipped=8)

System information

My system is macOS Mojave. (For example, "Ubuntu 16.04 LTS x64", "Windows 10 x64", or "macOS Sierra".)

My Python version is 3.9.4. (You can check this by running python -V.)

My Pip version is 20.2.3. (You can check this by running pip -V.)

My SpeechRecognition library version is 3.8.1. (from https://github.com/joy-void-joy/speech_recognition-pr/tree/whisper_integration ) (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)

My PyAudio library version is 0.2.12. (You can check this by running python -c "import pyaudio as p;print(p.__version__)".)

My microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())".)

My working microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())".)

I installed PocketSphinx from PyPI. (For example, from the Debian repositories, from Homebrew, or from the source code.)

TODO

  • temporary workaround: pin version under 5 to pass tests
  • permanent workaround: fix code according to warnings
    • 812: DeprecationWarning: default_config() is deprecated, just call Config() constructor
    • 830: DeprecationWarning: set_kws() is deprecated, use add_kws() instead
    • 831: DeprecationWarning: set_search() is deprecated, use activate_search() instead
    • Fix test_sphinx_keywords

Metadata

Metadata

Assignees

Labels

pocketsphinxFeatures related to pocketsphinx

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions