From 0a3aab9f7362159ae8af1702b141eaf5db255b7a Mon Sep 17 00:00:00 2001 From: NicoHood Date: Thu, 22 Feb 2018 09:14:18 +0100 Subject: [PATCH 01/15] Fixed unused shared libraries --- swig/Python/Makefile | 2 +- swig/Python3/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/swig/Python/Makefile b/swig/Python/Makefile index c4aa5cbc..e55ed020 100644 --- a/swig/Python/Makefile +++ b/swig/Python/Makefile @@ -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 CXXFLAGS += -std=c++0x # Make sure you have Atlas installed. You can statically link Atlas if you # would like to be able to move the library to a machine without Atlas. diff --git a/swig/Python3/Makefile b/swig/Python3/Makefile index 5bf8b15d..901db1a0 100644 --- a/swig/Python3/Makefile +++ b/swig/Python3/Makefile @@ -39,7 +39,7 @@ else CXX := g++ PYINC := $(shell python3-config --cflags) PYLIBS := $(shell python3-config --ldflags) - SWIGFLAGS := -shared + SWIGFLAGS := -Wl,-O1,--as-needed -shared CXXFLAGS += -std=c++0x # Make sure you have Atlas installed. You can statically link Atlas if you # would like to be able to move the library to a machine without Atlas. From 94260ad8e981e9261a5bca0c013b8b3b4cc3963b Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 25 Feb 2018 18:18:51 +0100 Subject: [PATCH 02/15] Fix Python3 module compilation --- examples/Python3/_snowboydetect.so | 1 - examples/Python3/requirements.txt | 1 - examples/Python3/snowboydetect.py | 1 - setup.py | 8 ++++---- swig/Python3/Makefile | 2 +- {examples => swig}/Python3/resources | 0 {examples => swig}/Python3/snowboydecoder.py | 0 7 files changed, 5 insertions(+), 8 deletions(-) delete mode 120000 examples/Python3/_snowboydetect.so delete mode 120000 examples/Python3/requirements.txt delete mode 120000 examples/Python3/snowboydetect.py rename {examples => swig}/Python3/resources (100%) rename {examples => swig}/Python3/snowboydecoder.py (100%) diff --git a/examples/Python3/_snowboydetect.so b/examples/Python3/_snowboydetect.so deleted file mode 120000 index 447c5831..00000000 --- a/examples/Python3/_snowboydetect.so +++ /dev/null @@ -1 +0,0 @@ -../../swig/Python3/_snowboydetect.so \ No newline at end of file diff --git a/examples/Python3/requirements.txt b/examples/Python3/requirements.txt deleted file mode 120000 index d8614c7d..00000000 --- a/examples/Python3/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -../Python/requirements.txt \ No newline at end of file diff --git a/examples/Python3/snowboydetect.py b/examples/Python3/snowboydetect.py deleted file mode 120000 index 9b6bc3ec..00000000 --- a/examples/Python3/snowboydetect.py +++ /dev/null @@ -1 +0,0 @@ -../../swig/Python3/snowboydetect.py \ No newline at end of file diff --git a/setup.py b/setup.py index 2f0b54fa..155efbc4 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,13 @@ py_dir = 'Python' if sys.version_info[0] < 3 else 'Python3' +swig_dir = os.path.join('swig', py_dir) class SnowboyBuild(build): def run(self): cmd = ['make'] - swig_dir = os.path.join('swig', py_dir) def compile(): call(cmd, cwd=swig_dir) @@ -39,14 +39,14 @@ def compile(): setup( name='snowboy', - version='1.2.0b1', + version='1.3.1', description='Snowboy is a customizable hotword detection engine', maintainer='KITT.AI', maintainer_email='snowboy@kitt.ai', license='Apache-2.0', url='https://snowboy.kitt.ai', - packages=find_packages(os.path.join('examples', py_dir)), - package_dir={'snowboy': os.path.join('examples', py_dir)}, + packages=find_packages(swig_dir), + package_dir={'snowboy': swig_dir}, py_modules=['snowboy.snowboydecoder', 'snowboy.snowboydetect'], package_data={'snowboy': ['resources/*']}, zip_safe=False, diff --git a/swig/Python3/Makefile b/swig/Python3/Makefile index 901db1a0..7abf51f8 100644 --- a/swig/Python3/Makefile +++ b/swig/Python3/Makefile @@ -46,7 +46,7 @@ else ifneq ("$(ldconfig -p | grep lapack_atlas)","") LDLIBS := -lm -ldl -lf77blas -lcblas -llapack_atlas -latlas else - LDLIBS := -lm -ldl -lf77blas -lcblas -llapack -latlas + LDLIBS := -lm -lcblas endif SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/ubuntu64/libsnowboy-detect.a ifneq (,$(findstring arm,$(shell uname -m))) diff --git a/examples/Python3/resources b/swig/Python3/resources similarity index 100% rename from examples/Python3/resources rename to swig/Python3/resources diff --git a/examples/Python3/snowboydecoder.py b/swig/Python3/snowboydecoder.py similarity index 100% rename from examples/Python3/snowboydecoder.py rename to swig/Python3/snowboydecoder.py From 7b78f5fdc73b41902380d7162c3a602732ad9d5c Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 25 Feb 2018 18:19:41 +0100 Subject: [PATCH 03/15] Improved Python3 demo --- examples/Python3/demo.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/examples/Python3/demo.py b/examples/Python3/demo.py index 305b8b62..9e8737b1 100644 --- a/examples/Python3/demo.py +++ b/examples/Python3/demo.py @@ -1,6 +1,8 @@ -import snowboydecoder +#!/usr/bin/env python3 +from snowboy import snowboydecoder import sys import signal +import os interrupted = False @@ -14,22 +16,30 @@ def interrupt_callback(): global interrupted return interrupted -if len(sys.argv) == 1: - print("Error: need to specify model name") +if len(sys.argv) != 2: + print("Error: need to specify 1 model name") print("Usage: python demo.py your.model") sys.exit(-1) -model = sys.argv[1] +def main(): + model = sys.argv[1] + if not os.path.isfile(model): + print("Error: Not a valid model.") + sys.exit(-1) -# capture SIGINT signal, e.g., Ctrl+C -signal.signal(signal.SIGINT, signal_handler) + # capture SIGINT signal, e.g., Ctrl+C + signal.signal(signal.SIGINT, signal_handler) -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) + print('Listening... Press Ctrl+C to exit') -# main loop -detector.start(detected_callback=snowboydecoder.play_audio_file, - interrupt_check=interrupt_callback, - sleep_time=0.03) + # main loop + detector.start(detected_callback=snowboydecoder.play_audio_file, + interrupt_check=interrupt_callback, + sleep_time=0.03) -detector.terminate() + detector.terminate() + +if __name__ == "__main__": + main() From d7a4ee30c1120d21ab98d10f4742cab4c4c13e5b Mon Sep 17 00:00:00 2001 From: cclauss Date: Sun, 15 Apr 2018 09:17:51 +0200 Subject: [PATCH 04/15] Fix Python syntax errors and undefined names --- .travis.yml | 2 ++ examples/Python/demo4.py | 18 ++++++++---------- examples/Python/demo_threaded.py | 11 +++++++++-- examples/Python3/demo4.py | 6 ++---- examples/REST_API/training_service.py | 10 ++++++---- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 306bea20..8e34c408 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,6 +69,8 @@ install: - node lib/node/index.js before_script: +# python: check for syntax errors or undefined names +- if [[ $NODE_VERSION == "9.0.0" ]]; then pip install flake8; flake8 . --select=E901,E999,F821,F822,F823; fi; # if publishing, do it - if [[ $REPUBLISH_BINARY == true ]]; then node-pre-gyp package unpublish; fi; - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish; fi; diff --git a/examples/Python/demo4.py b/examples/Python/demo4.py index a59eedaa..8dce406c 100644 --- a/examples/Python/demo4.py +++ b/examples/Python/demo4.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import snowboydecoder import sys import signal @@ -18,7 +20,7 @@ def audioRecorderCallback(fname): - print "converting audio to text" + print("converting audio to text") r = sr.Recognizer() with sr.AudioFile(fname) as source: audio = r.record(source) # read the entire audio file @@ -29,9 +31,9 @@ def audioRecorderCallback(fname): # instead of `r.recognize_google(audio)` print(r.recognize_google(audio)) except sr.UnknownValueError: - print "Google Speech Recognition could not understand audio" + print("Google Speech Recognition could not understand audio") except sr.RequestError as e: - print "Could not request results from Google Speech Recognition service; {0}".format(e) + print("Could not request results from Google Speech Recognition service; {0}".format(e)) os.remove(fname) @@ -51,8 +53,8 @@ def interrupt_callback(): return interrupted if len(sys.argv) == 1: - print "Error: need to specify model name" - print "Usage: python demo.py your.model" + print("Error: need to specify model name") + print("Usage: python demo.py your.model") sys.exit(-1) model = sys.argv[1] @@ -61,7 +63,7 @@ def interrupt_callback(): signal.signal(signal.SIGINT, signal_handler) detector = snowboydecoder.HotwordDetector(model, sensitivity=0.38) -print "Listening... Press Ctrl+C to exit" +print("Listening... Press Ctrl+C to exit") # main loop detector.start(detected_callback=detectedCallback, @@ -70,7 +72,3 @@ def interrupt_callback(): sleep_time=0.01) detector.terminate() - - - - diff --git a/examples/Python/demo_threaded.py b/examples/Python/demo_threaded.py index ded146c7..e6c14a94 100644 --- a/examples/Python/demo_threaded.py +++ b/examples/Python/demo_threaded.py @@ -1,8 +1,15 @@ +from __future__ import print_function + import snowboythreaded import sys import signal import time +try: + raw_input # Python 2 +except NameError: + raw_input = input # Python 3 + stop_program = False # This a demo that shows running Snowboy in another thread @@ -40,8 +47,8 @@ def signal_handler(signal, frame): try: num1 = int(raw_input("Enter the first number to add: ")) num2 = int(raw_input("Enter the second number to add: ")) - print "Sum of number: {}".format(num1 + num2) + print("Sum of number: {}".format(num1 + num2)) except ValueError: - print "You did not enter a number." + print("You did not enter a number.") threaded_detector.terminate() diff --git a/examples/Python3/demo4.py b/examples/Python3/demo4.py index dc52119e..11ea8b2f 100644 --- a/examples/Python3/demo4.py +++ b/examples/Python3/demo4.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import snowboydecoder import sys import signal @@ -69,7 +71,3 @@ def interrupt_callback(): sleep_time=0.01) detector.terminate() - - - - diff --git a/examples/REST_API/training_service.py b/examples/REST_API/training_service.py index 0e842fff..3a174981 100644 --- a/examples/REST_API/training_service.py +++ b/examples/REST_API/training_service.py @@ -1,5 +1,7 @@ #! /usr/bin/evn python +from __future__ import print_function + import sys import base64 import requests @@ -25,7 +27,7 @@ def get_wave(fname): try: [_, wav1, wav2, wav3, out] = sys.argv except ValueError: - print "Usage: %s wave_file1 wave_file2 wave_file3 out_model_name" % sys.argv[0] + print("Usage: %s wave_file1 wave_file2 wave_file3 out_model_name" % sys.argv[0]) sys.exit() data = { @@ -46,7 +48,7 @@ def get_wave(fname): if response.ok: with open(out, "w") as outfile: outfile.write(response.content) - print "Saved model to '%s'." % out + print("Saved model to '%s'." % out) else: - print "Request failed." - print response.text + print("Request failed.") + print(response.text) From 1b299b95765de76b8204a147bdfaefac3cb867fa Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 14:59:20 +0200 Subject: [PATCH 05/15] Used apply_frontend parameter --- examples/Python3/demo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/Python3/demo.py b/examples/Python3/demo.py index 9e8737b1..306deeae 100644 --- a/examples/Python3/demo.py +++ b/examples/Python3/demo.py @@ -30,8 +30,7 @@ def main(): # capture SIGINT signal, e.g., Ctrl+C signal.signal(signal.SIGINT, signal_handler) - detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5) - detector.detector.ApplyFrontend(False) + detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5, apply_frontend=True) print('Listening... Press Ctrl+C to exit') # main loop From 52284ce3c55afded8ac54746f9cf58af54bc56c9 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 15:15:58 +0200 Subject: [PATCH 06/15] Made python scripts executeable --- examples/Python3/demo.py | 0 examples/Python3/demo2.py | 0 examples/Python3/demo3.py | 0 examples/Python3/demo4.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 examples/Python3/demo.py mode change 100644 => 100755 examples/Python3/demo2.py mode change 100644 => 100755 examples/Python3/demo3.py mode change 100644 => 100755 examples/Python3/demo4.py diff --git a/examples/Python3/demo.py b/examples/Python3/demo.py old mode 100644 new mode 100755 diff --git a/examples/Python3/demo2.py b/examples/Python3/demo2.py old mode 100644 new mode 100755 diff --git a/examples/Python3/demo3.py b/examples/Python3/demo3.py old mode 100644 new mode 100755 diff --git a/examples/Python3/demo4.py b/examples/Python3/demo4.py old mode 100644 new mode 100755 From cf39fe99f70631e3abafa045a2c12d418d9de52e Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 15:18:54 +0200 Subject: [PATCH 07/15] Use default hotword for python demo --- examples/Python3/demo.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/Python3/demo.py b/examples/Python3/demo.py index 306deeae..ccab96e6 100755 --- a/examples/Python3/demo.py +++ b/examples/Python3/demo.py @@ -16,13 +16,17 @@ def interrupt_callback(): global interrupted return interrupted -if len(sys.argv) != 2: - print("Error: need to specify 1 model name") - print("Usage: python demo.py your.model") - sys.exit(-1) - def main(): - model = sys.argv[1] + if len(sys.argv) < 2: + print("Using default alexa model.") + model = os.path.join(snowboydecoder.TOP_DIR, 'resources/alexa/alexa-avs-sample-app/alexa.umdl') + elif len(sys.argv) > 2: + print("Error: need to specify 1 model name") + print("Usage: python demo.py your.model") + sys.exit(-1) + else: + model = sys.argv[1] + if not os.path.isfile(model): print("Error: Not a valid model.") sys.exit(-1) From c9d2d07b2517a72f43852a448da2d6be5983285e Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 15:39:10 +0200 Subject: [PATCH 08/15] Added Python2 compatiblity for demo --- examples/Python3/demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/Python3/demo.py b/examples/Python3/demo.py index ccab96e6..57442ed9 100755 --- a/examples/Python3/demo.py +++ b/examples/Python3/demo.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from __future__ import print_function from snowboy import snowboydecoder import sys import signal From c18b1930b206d1529498d7d80aa242a08e71f4ec Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 15:47:21 +0200 Subject: [PATCH 09/15] Added note about python path --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3d1b328a..f6152332 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,8 @@ To run the Java example script: cd swig/Python make + # Set temporary python path to load the compiled module instead of the currently installed one. + PYTHONPATH=$(pwd) SWIG will generate a `_snowboydetect.so` file and a simple (but hard-to-read) python wrapper `snowboydetect.py`. We have provided a higher level python wrapper `snowboydecoder.py` on top of that. From 79420742d334192b26df6dae6543210b38f109aa Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 15:55:15 +0200 Subject: [PATCH 10/15] Adapt python demo fixes to all demos --- examples/Python3/demo2.py | 44 +++++++++++++++++++++---------------- examples/Python3/demo3.py | 46 +++++++++++++++++++++------------------ examples/Python3/demo4.py | 40 ++++++++++++++++++---------------- 3 files changed, 71 insertions(+), 59 deletions(-) diff --git a/examples/Python3/demo2.py b/examples/Python3/demo2.py index fab9b981..b1817666 100755 --- a/examples/Python3/demo2.py +++ b/examples/Python3/demo2.py @@ -1,4 +1,6 @@ -import snowboydecoder +#!/usr/bin/env python3 +from __future__ import print_function +from snowboy import snowboydecoder import sys import signal @@ -16,26 +18,30 @@ def interrupt_callback(): global interrupted return interrupted -if len(sys.argv) != 3: - print("Error: need to specify 2 model names") - print("Usage: python demo.py 1st.model 2nd.model") - sys.exit(-1) +def main(): + if len(sys.argv) != 3: + print("Error: need to specify 2 model names") + print("Usage: python demo.py 1st.model 2nd.model") + sys.exit(-1) -models = sys.argv[1:] + models = sys.argv[1:] -# capture SIGINT signal, e.g., Ctrl+C -signal.signal(signal.SIGINT, signal_handler) + # capture SIGINT signal, e.g., Ctrl+C + signal.signal(signal.SIGINT, signal_handler) -sensitivity = [0.5]*len(models) -detector = snowboydecoder.HotwordDetector(models, sensitivity=sensitivity) -callbacks = [lambda: snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING), - lambda: snowboydecoder.play_audio_file(snowboydecoder.DETECT_DONG)] -print('Listening... Press Ctrl+C to exit') + sensitivity = [0.5]*len(models) + detector = snowboydecoder.HotwordDetector(models, sensitivity=sensitivity) + callbacks = [lambda: snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING), + lambda: snowboydecoder.play_audio_file(snowboydecoder.DETECT_DONG)] + print('Listening... Press Ctrl+C to exit') -# main loop -# make sure you have the same numbers of callbacks and models -detector.start(detected_callback=callbacks, - interrupt_check=interrupt_callback, - sleep_time=0.03) + # main loop + # make sure you have the same numbers of callbacks and models + detector.start(detected_callback=callbacks, + interrupt_check=interrupt_callback, + sleep_time=0.03) -detector.terminate() + detector.terminate() + +if __name__ == "__main__": + main() diff --git a/examples/Python3/demo3.py b/examples/Python3/demo3.py index 29ecec63..d65ea993 100755 --- a/examples/Python3/demo3.py +++ b/examples/Python3/demo3.py @@ -1,4 +1,6 @@ -import snowboydecoder +#!/usr/bin/env python3 +from __future__ import print_function +from snowboy import snowboydecoder import sys import wave @@ -12,29 +14,31 @@ # Should print: # Hotword Not Detected! +def main(): + if len(sys.argv) != 3: + print("Error: need to specify wave file name and model name") + print("Usage: python demo3.py wave_file model_file") + sys.exit(-1) -if len(sys.argv) != 3: - print("Error: need to specify wave file name and model name") - print("Usage: python demo3.py wave_file model_file") - sys.exit(-1) + wave_file = sys.argv[1] + model_file = sys.argv[2] -wave_file = sys.argv[1] -model_file = sys.argv[2] + f = wave.open(wave_file) + assert f.getnchannels() == 1, "Error: Snowboy only supports 1 channel of audio (mono, not stereo)" + assert f.getframerate() == 16000, "Error: Snowboy only supports 16K sampling rate" + assert f.getsampwidth() == 2, "Error: Snowboy only supports 16bit per sample" + data = f.readframes(f.getnframes()) + f.close() -f = wave.open(wave_file) -assert f.getnchannels() == 1, "Error: Snowboy only supports 1 channel of audio (mono, not stereo)" -assert f.getframerate() == 16000, "Error: Snowboy only supports 16K sampling rate" -assert f.getsampwidth() == 2, "Error: Snowboy only supports 16bit per sample" -data = f.readframes(f.getnframes()) -f.close() + sensitivity = 0.5 + detection = snowboydecoder.HotwordDetector(model_file, sensitivity=sensitivity) -sensitivity = 0.5 -detection = snowboydecoder.HotwordDetector(model_file, sensitivity=sensitivity) + ans = detection.detector.RunDetection(data) -ans = detection.detector.RunDetection(data) - -if ans == 1: - print('Hotword Detected!') -else: - print('Hotword Not Detected!') + if ans == 1: + print('Hotword Detected!') + else: + print('Hotword Not Detected!') +if __name__ == "__main__": + main() diff --git a/examples/Python3/demo4.py b/examples/Python3/demo4.py index dc52119e..63952d7d 100755 --- a/examples/Python3/demo4.py +++ b/examples/Python3/demo4.py @@ -1,4 +1,6 @@ -import snowboydecoder +#!/usr/bin/env python3 +from __future__ import print_function +from snowboy import snowboydecoder import sys import signal import speech_recognition as sr @@ -49,27 +51,27 @@ def interrupt_callback(): global interrupted return interrupted -if len(sys.argv) == 1: - print("Error: need to specify model name") - print("Usage: python demo.py your.model") - sys.exit(-1) +def main(): + if len(sys.argv) != 2: + print("Error: need to specify 1 model name") + print("Usage: python demo.py your.model") + sys.exit(-1) -model = sys.argv[1] + model = sys.argv[1] -# capture SIGINT signal, e.g., Ctrl+C -signal.signal(signal.SIGINT, signal_handler) - -detector = snowboydecoder.HotwordDetector(model, sensitivity=0.38) -print('Listening... Press Ctrl+C to exit') - -# main loop -detector.start(detected_callback=detectedCallback, - audio_recorder_callback=audioRecorderCallback, - interrupt_check=interrupt_callback, - sleep_time=0.01) - -detector.terminate() + # capture SIGINT signal, e.g., Ctrl+C + signal.signal(signal.SIGINT, signal_handler) + detector = snowboydecoder.HotwordDetector(model, sensitivity=0.38) + print('Listening... Press Ctrl+C to exit') + # main loop + detector.start(detected_callback=detectedCallback, + audio_recorder_callback=audioRecorderCallback, + interrupt_check=interrupt_callback, + sleep_time=0.01) + detector.terminate() +if __name__ == "__main__": + main() From c9bc770e14d61c183861d18b7c62ede2e085ba69 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 18:25:31 +0200 Subject: [PATCH 11/15] Fix import for python2 demo --- examples/Python/demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Python/demo.py b/examples/Python/demo.py index 305b8b62..8bf8f124 100644 --- a/examples/Python/demo.py +++ b/examples/Python/demo.py @@ -1,4 +1,4 @@ -import snowboydecoder +from snowboy import snowboydecoder import sys import signal From 9c1be64b28dc94eea2f03166d686f97652d8c611 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 18:28:16 +0200 Subject: [PATCH 12/15] Remove unrequired symlinks in python2 example --- examples/Python/__init__.py | 0 examples/Python/_snowboydetect.so | 1 - examples/Python/resources | 1 - examples/Python/snowboydetect.py | 1 - {examples => swig}/Python/snowboydecoder.py | 0 5 files changed, 3 deletions(-) delete mode 100644 examples/Python/__init__.py delete mode 120000 examples/Python/_snowboydetect.so delete mode 120000 examples/Python/resources delete mode 120000 examples/Python/snowboydetect.py rename {examples => swig}/Python/snowboydecoder.py (100%) diff --git a/examples/Python/__init__.py b/examples/Python/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/Python/_snowboydetect.so b/examples/Python/_snowboydetect.so deleted file mode 120000 index 3f67a404..00000000 --- a/examples/Python/_snowboydetect.so +++ /dev/null @@ -1 +0,0 @@ -../../swig/Python/_snowboydetect.so \ No newline at end of file diff --git a/examples/Python/resources b/examples/Python/resources deleted file mode 120000 index 81bd1c59..00000000 --- a/examples/Python/resources +++ /dev/null @@ -1 +0,0 @@ -../../resources/ \ No newline at end of file diff --git a/examples/Python/snowboydetect.py b/examples/Python/snowboydetect.py deleted file mode 120000 index a1393ff2..00000000 --- a/examples/Python/snowboydetect.py +++ /dev/null @@ -1 +0,0 @@ -../../swig/Python/snowboydetect.py \ No newline at end of file diff --git a/examples/Python/snowboydecoder.py b/swig/Python/snowboydecoder.py similarity index 100% rename from examples/Python/snowboydecoder.py rename to swig/Python/snowboydecoder.py From 0f7ef1d9c9e7a5ac3b63289c0292344fcc0eec8c Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 18:30:13 +0200 Subject: [PATCH 13/15] Fix building also for python2 --- swig/Python/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swig/Python/Makefile b/swig/Python/Makefile index e55ed020..d48f69d6 100644 --- a/swig/Python/Makefile +++ b/swig/Python/Makefile @@ -42,7 +42,7 @@ else ifneq ("$(ldconfig -p | grep lapack_atlas)","") LDLIBS := -lm -ldl -lf77blas -lcblas -llapack_atlas -latlas else - LDLIBS := -lm -ldl -lf77blas -lcblas -llapack -latlas + LDLIBS := -lm -lcblas endif SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/ubuntu64/libsnowboy-detect.a ifneq (,$(findstring arm,$(shell uname -m))) From d56765680d3914ec76e5de8be602a0799e0b316b Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 18:32:45 +0200 Subject: [PATCH 14/15] Added python2 shebang --- examples/Python/demo.py | 1 + examples/Python/demo2.py | 3 ++- examples/Python/demo3.py | 4 ++-- examples/Python/demo4.py | 7 ++----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/Python/demo.py b/examples/Python/demo.py index 8bf8f124..73296f66 100644 --- a/examples/Python/demo.py +++ b/examples/Python/demo.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python2 from snowboy import snowboydecoder import sys import signal diff --git a/examples/Python/demo2.py b/examples/Python/demo2.py index fab9b981..f6c3ded6 100644 --- a/examples/Python/demo2.py +++ b/examples/Python/demo2.py @@ -1,4 +1,5 @@ -import snowboydecoder +#!/usr/bin/env python2 +from snowboy import snowboydecoder import sys import signal diff --git a/examples/Python/demo3.py b/examples/Python/demo3.py index 29ecec63..808e4e40 100644 --- a/examples/Python/demo3.py +++ b/examples/Python/demo3.py @@ -1,4 +1,5 @@ -import snowboydecoder +#!/usr/bin/env python2 +from snowboy import snowboydecoder import sys import wave @@ -37,4 +38,3 @@ print('Hotword Detected!') else: print('Hotword Not Detected!') - diff --git a/examples/Python/demo4.py b/examples/Python/demo4.py index a59eedaa..ac946e0a 100644 --- a/examples/Python/demo4.py +++ b/examples/Python/demo4.py @@ -1,4 +1,5 @@ -import snowboydecoder +#!/usr/bin/env python2 +from snowboy import snowboydecoder import sys import signal import speech_recognition as sr @@ -70,7 +71,3 @@ def interrupt_callback(): sleep_time=0.01) detector.terminate() - - - - From e6e4de32fbbb6a346bb4eb9f21756789c83072e0 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 6 May 2018 18:40:45 +0200 Subject: [PATCH 15/15] Import snowboydetect from local path --- swig/Python/snowboydecoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swig/Python/snowboydecoder.py b/swig/Python/snowboydecoder.py index 2ddb5949..a7a76b22 100644 --- a/swig/Python/snowboydecoder.py +++ b/swig/Python/snowboydecoder.py @@ -2,7 +2,7 @@ import collections import pyaudio -import snowboydetect +from . import snowboydetect import time import wave import os