This commit is contained in:
wassname
2018-12-29 14:46:15 +08:00
parent d5c65b8f78
commit 75e9e2e5a8
+17 -25
View File
@@ -1,32 +1,21 @@
#### RUNNING THE MODEL
#Michels-MacBook-Pro:~ ShebMichel$ cd documents/pmlg/wake/decoder
#Michels-MacBook-Pro:decoder ShebMichel$ python demo.py resources/HiBitLit.pmdl
import sys, os
#### RUNNING THE MODEL
# Michels-MacBook-Pro:~ ShebMichel$ cd documents/pmlg/wake/decoder
# Michels-MacBook-Pro:decoder ShebMichel$ python demo.py resources/HiBitLit.pmdl
import os
import sys
import snowboydecoder
import signal
#import BitLit_main ## MAIN PROGRAM
####
from gtts import gTTS ## Packages for Text to voice
import speech_recognition as sr ## Packages for voice recognizer
import BitLit_main
# import tensorflow as tf
# tf.enable_eager_execution()
# from tensorflow.keras.layers import Embedding, GRU, Dense
import numpy as np
import re
from textblob import TextBlob
import random
import poem_generator ## POEM GENERATOR IMPORT
from poem_generator import*
import time
import BitLit_main
t0=time.time() ## Time counter
t0 = time.time() ## Time counter
interrupted = False
def signal_handler(signal, frame):
global interrupted
interrupted = True
@@ -36,6 +25,7 @@ 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")
@@ -47,14 +37,16 @@ model = sys.argv[1]
signal.signal(signal.SIGINT, signal_handler)
detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
print('Listening... Press Ctrl+C to exit')
print("Listening... Press Ctrl+C to exit")
detector.start(detected_callback=BitLit_main.generate_poem,
interrupt_check=interrupt_callback,
sleep_time=0.03)
detector.start(
detected_callback=BitLit_main.generate_poem,
interrupt_check=interrupt_callback,
sleep_time=0.03,
)
detector.terminate()
t1 =time.time()
total=t1-t0
print(('Time spent is about:', np.round(total), 'seconds'))
t1 = time.time()
total = t1 - t0
print(("Time spent is about:", np.round(total), "seconds"))