Skip to content

Instantly share code, notes, and snippets.

View jiansoo's full-sized avatar

Jian Soo jiansoo

View GitHub Profile
import urllib.request
import ast
import time
from colorama import Fore, Style
completed = False
@jiansoo
jiansoo / SnowboyModel.py
Created February 27, 2019 13:46
Snowboy Model Python Application
import snowboydecoder
import sys
import signal
interrupted = False
def signal_handler(signal, frame):
global interrupted
interrupted = True
import signal
import snowboydecoder
interrupted = False
def interrupt_func(signal, frame):
global interrupted
interrupted = True
import speech_recognition
sr = speech_recognition
r = sr.Recognizer
class Recognise:
def detect(self):
import signal
import snowboydecoder
import interpret
interrupted = False
int = interpret.Recognise()
def interrupt_func(signal, frame):
global interrupted
interrupted = True
def imperative_pos_tag(sent):
return [(word, tag[:2]) if tag.startswith('VB') else (word,tag) for word, tag in nltk.pos_tag(['He']+sent)[1:]]
def find_verb(inp):
inp_token = nltk.word_tokenize(inp)
inp_tagged = imperative_pos_tag(inp_token)
print(inp_tagged)
for i in range(len(inp_tagged)):
if inp_tagged[i][1] == 'VB':
return(inp_tagged[i][0], inp, i)