예제 #1
0
def initSpeech():
    r = sr.Recognizer()
    cmd = Commander()
    
    print("Listening")
    #play_audio('./audio/before.wav')
        
    with sr.Microphone() as source:                # use the default microphone as the audio source
        print("say something")
        audio = r.listen(source) 

    #play_audio('./audio/after.wav')
    command = ""

    try:
        command = r.recognize_google(audio)
    except:
        print("please repeat")

    print("Your command:" )
    print(command)

    if command in ["quit", "exit", "bye", "goodbye"]:
        global running 
        running = False

    command = command.replace("'", "")
    cmd.discover(command)
예제 #2
0
 def process_html(self, html):
     commander = Commander(self.fixture, StringIO(html))
     commander.process()
     self.result = commander.result
     if self.patcher:
         self.patcher.stop()
     return self.result
예제 #3
0
def initSpeak():
    print("Speaking")
    open_file('./audio/audio_initiate.wav')
    with sr.Microphone() as source:
        print("Say something")
        audio = r.listen(source)

    open_file('./audio/audio_end.wav')

    command = ""

    # recognize speech using Google Speech Recognition
    try:
        # for testing purposes, we're just using the default API key
        # to use another API key, use `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
        # instead of `r.recognize_google(audio)`
        # print("Google Speech Recognition thinks you said " + r.recognize_google(audio))
        obj = engine.rootObjects()
        myObj = obj[0].findChild(QObject, 'mainPage')
        QMetaObject.invokeMethod(myObj, "updateQuestion", Qt.DirectConnection, Q_ARG("QVariant", r.recognize_google(audio)))
        command = r.recognize_google(audio)


    except sr.UnknownValueError:
        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))

    if command in quit:
        say("Bye")
        active = False
    else:
        commander = Commander()
        commander.discover(command)
예제 #4
0
    def runTest(self):
        # hack to prevent the base class to be run
        if self.__class__.__name__ == ConcordionTestCase.__name__:
            return True

        filename = self._find_spec()

        runner = Commander(self, filename)
        runner.process()

        runner.tree.xpath("//body")[0].insert(0, self.bread_crumb_tag())
        self.__write(filename, runner.tree)
        self.assertTrue(runner.result.has_succeeded())
예제 #5
0
    def runTest(self):
        # hack to prevent the base class to be run
        if self.__class__.__name__ == ConcordionTestCase.__name__:
            return True

        filename = self._find_spec()

        runner = Commander(self, filename)
        runner.process()

        runner.tree.xpath("//body")[0].insert(0, self.bread_crumb_tag())
        self.__write(filename, runner.tree)
        self.assertTrue(runner.result.has_succeeded())
                     rate=wf.getframerate(),
                     output=True)
    data_stream = wf.readframes(chunk)

    while data_stream:
        stream.write(data_stream)
        data_stream = wf.readframes(chunk)

    stream.close()
    pa.terminate()


play_audio('./audio/hollow.wav')

r = sr.Recognizer()
cmd = Commander()


def speech():
    print("Listening...")
    play_audio("./audio/hollow.wav")
    with sr.Microphone() as source:
        print("Say Something")
        audio = r.listen(source)

    play_audio("./audio/insight.wav")

    command = " "

    try:
        command = r.recognize_google(audio)
예제 #7
0
#!/usr/bin/env python
import sys
import datetime
import aiohttp
import signal
import itertools
import requests
import math
import asyncio
from time import sleep
from commands import Commander
from resources import SimpleLed, RGBLed, Buzzer

# Config & setup
API_URL = 'https://ino-state-server.herokuapp.com'
commander = Commander('localhost', 6000, authkey=b'qweqwe')
frequency = .1
loop = asyncio.get_event_loop()

# Resources
led1 = RGBLed('one', commander, loop)
led2 = RGBLed('two', commander, loop)
simple_led = SimpleLed('smallRed', commander, loop)
bz = Buzzer('buzz', commander)

state = {}


def handle_state(state, prev_state):
    print(state)
예제 #8
0
	    rate = wf.getframerate(),
        output = True
	)

	data_stream = wf.readframes(chunk)# read the data

	# play the stream
	while data_stream:
	    stream.write(data_stream)
	    data_stream = wf.readframes(chunk)

	stream.close()# stop the stream
	pa.terminate()# close pyaduio

r = sr.Recognizer()# instantiate SpeechRecognizer
cmd = Commander()# listen to you speech and recognize
def youTalk():
	print("Listening...")
	play_audio("./audio/suppressed.wav")# plays audio to begin listening

	with sr.Microphone() as source:
	    print("Say Something")
	    audio = r.listen(source)# listens to our speech

	play_audio("./audio/wet.wav")# plays sound to end listening

	command = ""

	try:
		command = r.recognize_google(audio)# uses google to determine what we say
	except:
    output=True
  )

  dataStream = wf.readframes(chunk)

  while dataStream:
    stream.write(dataStream)
    dataStream = wf.readframes(chunk)

  stream.clsoe()
  pa.terminate()

#open_file("./audio/nameofFile.wav") 

r = sr.Recognizer()
cmd = Commander()
def initSpeech();
  print("Listening ...")
  play_audio("./audio/nameofFileStartTone.wav")

  with sr.Microphone() as sources
  print ("Say Something")
  audio = r.listen(source)

  play_audio("./audio/nameOfFileEndTone.wav")

  command = ""

  try:
    command = r.recognize_goodle(audio)
  except:
예제 #10
0
        rate = wave_file.getframerate(),
        output = True
    )

    data_stream = wave_file.readframes(chunk)

    while data_stream:
        stream.write(data_stream)
        data_stream = wave_file.readframes(chunk)

    stream.close()
    pa.terminate()


recognizer = speech_recognition.Recognizer()
commander = Commander()


def init_speech():
    print("Wait for the beep...\n")
    play_audio("./audio/start.wav")

    with speech_recognition.Microphone() as source:
        print("Say something!")
        audio = recognizer.listen(source)

    play_audio("./audio/end.wav")

    command = ""

    try:
예제 #11
0
#!/usr/bin/env python
import sys
from commands import Commander

arg = sys.argv[1]
Commander('localhost', 6000, authkey=b'qweqwe').order(arg)