Exemplo n.º 1
0
player = Player(pa)

spi.write('online\n')


def handle_int(sig, frame):
    global mission_completed
    mission_completed = True
    mic.close()


signal.signal(signal.SIGINT, handle_int)

while not mission_completed:
    if not awake:
        if mic.detect():
            spi.write('wakeup\n')
            awake = True
            player.play(hi)
        continue

    data = mic.listen()
    spi.write('wait\n')

    # recognize speech using Microsoft Bing Voice Recognition
    try:
        text = bing.recognize(data, language='en-US')
        spi.write('answer\n')
        print('Bing:' + text.encode('utf-8'))

        if re.search(r'start', text):
Exemplo n.º 2
0
    print "Terminating..."
    mission_completed = True
    mic.close()
    player.close()
    worker.stop()
    pa.terminate()



signal.signal(signal.SIGINT, handle_int)

worker.start()

while not mission_completed:
    if not awake:
        if mic.detect():
            awake = True
            player.play(hi)
        continue

    data = mic.listen()

    if not data:
        awake = False
        continue

    # recognize speech using Microsoft Bing Voice Recognition
    try:
        text = recognizer.recognize(data, language='en-US')
        print('Bing:' + text.encode('utf-8'))
        worker.push_cmd(text)
Exemplo n.º 3
0
mic = Microphone(pa)
player = Player(pa)

spi.write('online\n');

def handle_int(sig, frame):
    global mission_completed
    mission_completed = True
    mic.close()


signal.signal(signal.SIGINT, handle_int)

while not mission_completed:
    if not awake:
        if mic.detect('r2d2'):
            spi.write('wakeup\n')
            awake = True
            player.play(hi)
        continue

    data = mic.listen()
    spi.write('wait\n')

    # recognize speech using Microsoft Bing Voice Recognition
    try:
        text = bing.recognize(data, language='en-US')
        spi.write('answer\n')
        print('Bing:' + text.encode('utf-8'))
        
        if re.search(r'start', text):