-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Major code cleanup #124
Major code cleanup #124
Conversation
This is a rather big change. I replaced hardcoded filenames for tempfiles, that were written inside the cwd by using the tempfile module. Hardcoded paths (most of them, I assume) were replaced by the brand new and shiny jasperpath module. Also, some minor bugs were fixed and manipulation of sys.path has been removed.
Great job! |
PHONETISAURUS_PATH + "/phonetisaurus/dictionary.dic") | ||
sentences_path = jasperpath.config('sentences.txt') | ||
dictionary_path = jasperpath.config('dictionary.dic') | ||
translateFile(sentences_path,dictionary_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can you put a space between the arguments?
This is great! Thanks a ton for doing this--really appreciate it. Most of my comments are just style nits (sorry to be picky). @shbhrsaha is going to test this on a device in the near future (I don't have one handy at the moment); hopefully we can get this merged in soon. |
…guagemodel generation routines
Currently no need to test this. I'm still making improvements and found some minor bugs in my code. I'll let you know as soon as it's finished ;-) |
Right now, I think that some of the above bugs should be handled differently:
So why not put the file path of the FST model into the config file? We could create some kind of "advanced settings" namespace, so that the user can use his or her own FST model to improve recognition rate, if he wants to. The config file contains something something like: advanced_settings:
fst: '/home/pi/phonetisaurus/g014b2b.fst'
hmm: '/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k' If jasper-client is packed for other distributions, the package mantainer can just change the default paths inside the config path template via |
Ah, good solution. Yes, and we can specify in the docs for Jasper disk image users to configure their setup accordingly. I'll be able to test this again this weekend. Will post an update then. |
Removed the HMM_PATH and PHONETISAURUS_MODEL stuff from the jasperpath module. Added default values for them to stt/g2p and made them overwritable by config
@shbhrsaha Problem solved. We just check if we have the advanced_settings in the profile. If so, we overwrite the hardcoded defaults. This should work for the moment (until we have the config module). |
Great, thanks for putting that in. I gave it another shot this weekend. The problem that surfaces now is that, on the Pi, the espeak voice is really slow and choppy. In addition, Jasper isn't responding to microphone input. I imagine the first might have to do with overwhelming the Pi's resources-- I'll try profiling tomorrow to try to share more details As for mic input, @Holzhaus , how has the experience been running this refactored activeListen on your computer? Does it work smoothly? I've ruled out mic levels as a factor because the master version appears to be responding fine on the same settings |
Well, that espeak issue might be caused by either the Rpi hardware being too slow to output something via PyAudio instead of aplay (you should check the CPU via Regarding the Mic module: Does |
Ok, just tested it again. Even tough it takes ages (>20 attempts) until pocketsphinx recognizes 'Jasper' - if it does, it works fine for me. |
Got it, thanks for checking. Yes, that passiveListen is the troubling one because I too require many, many attempts to get it to trigger, while master works on the first 2-3 tries on same setup. Possible discrepancy between the two passiveListen implementations, will look into it |
Strange . I thought that bad recognition rate was caused by thr lack of good opensource acoustic models. But if the master branch performs better, something has to be rotten in the state of Possible way to check this might be to keep the wave files to analyze them in audacity. |
Any way we can carve out some of the smaller bugfixes here and merge them in? Perhaps:
|
The Problem is, that sometimes my commits are not just addressing one issue. They should, and now I know why. ;-)
|
Yeah, this is getting messy. I suppose if we're just trying to fix this one recognition issue in Either way, we should keep start.sh as a wrapper file for backwards compatibility, as this is all part of v1.0. |
@Holzhaus To separate the low-hanging fruit, and if it's not too much work, each of these could be a separate pull request:
I'm can work on breaking this up myself, but thought you might want to send them in as you wrote the original code. |
As an aside: the passiveListen in this implementation actually does seem to trigger at the right times, but with a ~10-second delay. Dropping the master's mic.py into this one makes that delay shorter, but the program is still generally sluggish (probably because of Pi resource limitations). This suggests the tunable parameters are probably correct in passiveListen, but maybe we're running up against resource constraints. Let's go ahead with Charlie's suggestion to break this PR into those smaller ones that can be merged in more easily, while keeping a close eye on program performance when testing each PR. Might help to narrow down the cause of the sluggishness. |
I agree with the separate-pull-requests idea. I think there are some great ones here, but as they are all together, it's harder to review and merge them afterwards. And a big PR needs to be kept up-to-date while things in the codebase change, smaller ones are easier to maintain, and get merged faster. |
This fixes #123 and also fixes #119. It partly resolves #51.
You now should use "client.jasperpath"-module for all path related stuff (instead of hardcoding the strings). There's room for improvement (e.g. put the paths into a config file), but anyhow, this should do it for the moment.
Also, you really need to use the "tempfile"-module, which will create temporary files in the right location (and deletes them afterwards).
Last but not Least: I really don't get all this crazy sys.path-manipulation...what's the deal with that? I removed it for now.
I'll hope you can use these changes.
Fun fact: I did this to make it possible to create a ArchLinux PKGBUILD.