Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 8 additions & 10 deletions examples/Python/demo4.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import snowboydecoder
import sys
import signal
Expand All @@ -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
Expand All @@ -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)

Expand All @@ -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]
Expand All @@ -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,
Expand All @@ -70,7 +72,3 @@ def interrupt_callback():
sleep_time=0.01)

detector.terminate()




11 changes: 9 additions & 2 deletions examples/Python/demo_threaded.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
6 changes: 2 additions & 4 deletions examples/Python3/demo4.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import snowboydecoder
import sys
import signal
Expand Down Expand Up @@ -69,7 +71,3 @@ def interrupt_callback():
sleep_time=0.01)

detector.terminate()




10 changes: 6 additions & 4 deletions examples/REST_API/training_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/evn python

from __future__ import print_function

import sys
import base64
import requests
Expand All @@ -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 = {
Expand All @@ -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)