NaomiProject / Naomi

The Naomi Project is an open source, technology agnostic platform for developing always-on, voice-controlled applications!
https://projectnaomi.com/
MIT License
242 stars 47 forks source link

Fix issue with CMU Dictionary path #382

Closed aaronchantrill closed 1 year ago

aaronchantrill commented 1 year ago

Description

Back in the old days, we used to require the user to download their own HMM model and CMU dictionary. The HMM model might be installed by installing a system package, along with the download of the pocketsphinx source code, or independently. Same with the CMU dictionary file.

At one point, it just seemed easier to host copies of the HMM model and dictionary ourselves. That way we would know where to download them from and could help the user with that, and would know what format everything is in.

Recently, I decided instead of asking for the locations of both the HMM model and the dictionary, just ask for the HMM model and assume that the dictionary is in that same folder and named CMUDict.dict.

Unfortunately, if it isn't, then that causes problems. I may need to revert to keeping the two settings separate in the future, but for right now, I am going to stop searching in all the odd places for the HMM model and dictionary and just assume we are using our hosted version. If the user does not have that installed, then download it for them.

There was an additional problem where if you did not download the HMM model and CMUDict during startup, the CMUDict variable did not get set.

Expected Behavior

After downloading the correct CMUSphinx_standard_language_models repository branch, you should be able to rebuild your Phonetisaurus model as needed.

Actual Behavior

Right now, if your computer attempts to re-build the Phonetisaurus G2P model, it does not know where to find the CMU dictionary file, because that variable is only set in the block of code used to download the CMUSphinx_standard_language_models repository. Additionally, it may be looking for the dictionary in the wrong place since I am now assuming that the dictionary will be in the HMM directory.

Possible Fix

Move the initialization of that variable outside of that if/then block. Do not search for other versions of the HMM directory other than the one Downloaded from our Github repository.

Steps to Reproduce

  1. Download and install Naomi
  2. Set pocketsphinx as at least one of the STT engines (passive, active, special)
  3. Run Naomi and let it download the CMUSphinx_standard_language_models repository and create a Phonetisaurus G2P FST
  4. Delete the g2p_model.fst file from ~/.config/naomi/pocketsphinx/Standard/... folder
  5. Try to run Naomi again.

Context

This prevents me from running Naomi in certain circumstances, especially when upgrading older versions.