Skip to content
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

WIP Python fixes #383

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

WIP Python fixes #383

wants to merge 18 commits into from

Conversation

NicoHood
Copy link

@NicoHood NicoHood commented Feb 25, 2018

This PR tries to fix several problem with the Python package:

  • The example folder and the python module folder were mixed before. Because of this the local import of snowboydecoder.py did not work properly. Now the module is properly separated and the module can be loaded by setting the python path
  • The version number was wrong, bumped to 1.3.1
  • The example now has a main() method
  • The example now check if exactly 1 (not more) models are passed
  • The example checks if the model file exists
  • The example shebang is now correct
  • The example also explains for to set the frontend option (seems to be better with alexa model, see Usage of ApplyFrontend #380 )
  • It also fixes Too many libraries specified in Makefile #377

TODO:

  • Adapt changes with Python2 We should make all examples rather Python2 and 3 compatible or remove python2 support/examples completely.
  • Explain pythonpath setting in the readme Done
  • Also fix remaining demos ( NumHotwords() incorrect #381 blocking)

I would like to have some feedback, then I am willing to fix the remaining TODOs

@NicoHood
Copy link
Author

Any feedback on those changes?

@chenguoguo
Copy link
Collaborator

Sorry for the radio silence, don't have time to check it yet. I'll review and merge in the next few days.

@NicoHood
Copy link
Author

NicoHood commented Apr 8, 2018

push
I am happy to resolve the merge conflicts and do the reminding todos if you give me some feedback if the changes are okay for you.

@chenguoguo
Copy link
Collaborator

Thanks Nico. I'll make sure I give a pass to this tomorrow.

Copy link
Collaborator

@chenguoguo chenguoguo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @NicoHood for the PR. I added a few comments. And also some high level comments:

  1. I think it's better if you and also finish your three TODOs in this PR.

  2. I'm a little bit hesitating moving things like snowboydecoder.py and resources to swig/Python3 or swig/Python. That's a bit change. If we are going to do that, could you document that in the README? Also, swig/Python3/resources is just a softlink to the actual file. When you make the Python package, could you make sure you copy the directory following the soft link (so that you could copy the actual files)?

detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
print('Listening... Press Ctrl+C to exit')
detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
detector.detector.ApplyFrontend(False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new param for apply_frontend. We can now set it through initialization.

@@ -35,7 +35,7 @@ else
CXX := g++
PYINC := $(shell python-config --cflags)
PYLIBS := $(shell python-config --ldflags)
SWIGFLAGS := -shared
SWIGFLAGS := -Wl,-O1,--as-needed -shared
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the -O1 option here asks the compiler to do level 1 optimizations, might be helpful

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand. What do you mean? Was this just a "hey, thats good!" or are you requesting some change? I am already using -O1?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh OK sorry, mis-read it... I thought "SWIGFLAGS := -Wl,-O1,--as-needed -shared" was the original line.

@@ -39,14 +39,14 @@ else
CXX := g++
PYINC := $(shell python3-config --cflags)
PYLIBS := $(shell python3-config --ldflags)
SWIGFLAGS := -shared
SWIGFLAGS := -Wl,-O1,--as-needed -shared
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, the -O1 option here asks the compiler to do level 1 optimizations, might be helpful

@NicoHood
Copy link
Author

NicoHood commented May 6, 2018

I have updated my PR, however I cannot get the python2 examples working in general. This seems to not be a problem of this PR, it just doesnt work on my system.

Another thing I noticed is that the decoder file differs for python2 and 3, which we want to avoid:

meld ../../swig/Python/snowboydecoder.py ../../swig/Python3/snowboydecoder.py

@NicoHood
Copy link
Author

@chenguoguo I've merged the other PR into this one. Could you please give it a test? For me the python2 examples dont work at all, but they also did not work before the PR for me.

Beside this the snowboydecoder.py for python2 and 3 are out of sync. You should know best which one of the two is the most up to date. Those should be merged into a single file, that is simpler to maintain.

The same for the examples itself. If the import for python2 gets fixed, there is no need to have examples for python2 or 3 separated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too many libraries specified in Makefile
2 participants