示例#1
0
    def sear():
        keyboard = Controller()

        p = p = subprocess.Popen(["google-chrome", "http://www.google.com"])
        time.sleep(3)

        while True:
            tts.textToSpeech("Speak your search query after the beep").say()
            time.sleep(0.5)
            os.system("echo '\a'")
            time.sleep(0.2)
            with keyboard.pressed(Key.ctrl):
                with keyboard.pressed(Key.shift):
                    keyboard.press('.')
                    keyboard.release('.')
            #keyboard.press_and_release('ctrl+shift+.')
            time.sleep(15)
            tts.textToSpeech("Do you want to search another query").say()
            time.sleep(0.2)
            os.system("echo '\a'")
            time.sleep(0.2)
            stt.SpeechToText('./Desktop/major/sound/ask.wav').record(3)
            os.system("echo '\a'")
            ask = stt.SpeechToText(
                './Desktop/major/sound/ask.wav').speech_to_text()
            if ask == "no":
                break

        p.kill()
def verify(command):
	print command
	print "\n"

	text = command[0]
	conf = command[1]
	intent = command[2]
	JSON = command[3]

	if text is None:
		print "Command not detected"
		return
	
	if 'UNKNOWN' in intent or conf < .5:
		print "Try again"
		tts.textToSpeech("I didn't quite catch that")
		take_command()
	else:
		print intent
		if "nevermind" in intent:
			return
		else:
			try:
				eval(intent + ".run(JSON)")
			except:
				print "Try again"
				tts.textToSpeech("I didn't quite catch that")
				take_command()
示例#3
0
    def pld():
        files = []
        sep = "."
        for filename in os.listdir('./Desktop/major/pymusic'):
            filename = filename.split(sep, 1)[0]
            files.append(filename)
        #print(files[0])
        #print(files[1])
        tts.textToSpeech("Speak the name of the song you want to play").say()
        time.sleep(0.2)
        os.system("echo '\a'")
        time.sleep(0.2)
        stt.SpeechToText('./Desktop/major/sound/song.wav').record(5)
        os.system("echo '\a'")
        song = stt.SpeechToText(
            '.Desktop/major/sound/song.wav').speech_to_text()

        print(song)
        file_index = files.index(song) if song in files else None
        if file_index == None:
            tts.textToSpeech("Sorry this song is not available").say()
        else:
            pygame.init()
            pygame.display.set_mode((200, 100))
            pygame.mixer.music.load('./Desktop/major/pymusic/' +
                                    files[file_index] + '.mp3')
            pygame.mixer.music.play(0)
            while True:  #to close using x button
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        pygame.quit()
                        exit()
def take_command():
	tts.textToSpeech("How may I help you?")
	wit.init()
	commandJSON = json.loads('{}'.format(wit.voice_query_auto(tok)))

	parsed = jsonparser.parse(commandJSON)
	verify(parsed)
	wit.close()
示例#5
0
def writing():
    #writeDoc object
    wr = writeD.writeDoc()
    #taking the title
    tts.textToSpeech("Speak the title of the document").say()
    time.sleep(0.5)
    os.system("echo '\a'")
    time.sleep(0.2)
    stt.SpeechToText('./Desktop/major/sound/docTitle.wav').record(5)
    os.system("echo '\a'")
    doc_title = stt.SpeechToText(
        './Desktop/major/sound/docTitle.wav').speech_to_text()
    paragraph = []
    #taking the first paragraph
    while True:
        tts.textToSpeech("Speak the Paragraph").say()
        time.sleep(0.5)
        os.system("echo '\a'")
        time.sleep(0.2)
        stt.SpeechToText('./Desktop/major/sound/docPara.wav').record(15)
        os.system("echo '\a'")
        file_para = stt.SpeechToText(
            './Desktop/major/sound/docPara.wav').speech_to_text()
        paragraph.append(file_para)
        tts.textToSpeech("Do you want add more content").say()
        time.sleep(0.2)
        os.system("echo '\a'")
        time.sleep(0.2)
        stt.SpeechToText('./Desktop/major/sound/res.wav').record(3)
        os.system("echo '\a'")
        res = stt.SpeechToText(
            './Desktop/major/sound/res.wav').speech_to_text()
        if res == "no":
            break
    time.sleep(0.2)
    tts.textToSpeech("What would you like to name the file").say()
    time.sleep(0.5)
    os.system("echo '\a'")
    time.sleep(0.2)
    stt.SpeechToText('./Desktop/major/sound/docName.wav').record(4)
    os.system("echo '\a'")
    file_Name = stt.SpeechToText(
        './Desktop/major/sound/docName.wav').speech_to_text().replace(" ", "")
    file_Name = file_Name + ".docx"
    wr.addHeading(doc_title)
    for p in paragraph:
        print(p)
        wr.addParagraph(p)
    wr.saveDoc("./Desktop/major/documents/" + file_Name)
    tts.textToSpeech("Document saved sucessfully").say()
示例#6
0
    def evaluate(self):
        os.system("echo '\a'")
        time.sleep(0.2)
        obj=SpeechToText('./Desktop/major/sound/file.wav')
        obj.record(5)
        time.sleep(0.2)
        os.system("echo '\a'")
        var=obj.speech_to_text();

        equation=var.replace("x","*");

        ans=eval(equation);
        #print(ans);

        spe=textToSpeech("the calculated value is equal to "+str(ans))
        spe.say();
示例#7
0
def reading():
    tts.textToSpeech("Speak the File Name after the beep").say()
    time.sleep(0.5)
    os.system("echo '\a'")
    time.sleep(0.2)
    stt.SpeechToText('./Desktop/major/sound/filename.wav').record(3)
    os.system("echo '\a'")
    file_name = stt.SpeechToText(
        './Desktop/major/sound/filename.wav').speech_to_text().replace(
            " ", "")
    file_name = file_name + ".docx"
    print(file_name)
    if len(readDoc.readFile(file_name).find_all(
            "./Desktop/major/documents")) <= 0:
        print("No such file found")
        tts.textToSpeech("No File Found").say()
    else:
        doc_data = readDoc.readFile("./Desktop/major/documents/" +
                                    file_name).read()
        print(doc_data)
        tts.textToSpeech(doc_data).say()
示例#8
0
response = myVoiceIt.createUser(userName, pswd)
ind1 = response.find("ResponseCode")
ind1 += 15
ind2 = response.find('"', ind1)
if response[ind1:ind2] == 'SUC':
    print("User Created Successfully")
else:
    print("Something Went wrong! Please try after sometime")
    sys.exit()

i = 0
while True:
    if i == 3:
        break
    tts.textToSpeech(
        "Please Speak Zoos are filled with small and large animals after the beep"
    ).say()
    time.sleep(0.5)
    os.system("echo '\a'")
    time.sleep(0.2)
    stt.SpeechToText('./Desktop/major/sound/file.wav').record(5)
    os.system("echo '\a'")
    response = myVoiceIt.createEnrollment(userName, pswd,
                                          "./Desktop/major/sound/file.wav",
                                          "en-US")
    print(response)
    ind1 = response.find("ResponseCode")
    ind1 += 15
    ind2 = response.find('"', ind1)
    if response[ind1:ind2] == 'SUC':
        i += 1
def run(JSON):
	tts.textToSpeech("Toggling power on the lights")
	os.system("irsend SEND_ONCE lights KEY_POWER")
示例#10
0
def perform_command(argument):
    func = switcher.get(argument, "Invalid Command")
    if (func != "Invalid Command"):
        return func()
    else:
        tts.textToSpeech("Invalid Command").say()
示例#11
0
}


def perform_command(argument):
    func = switcher.get(argument, "Invalid Command")
    if (func != "Invalid Command"):
        return func()
    else:
        tts.textToSpeech("Invalid Command").say()


#authentication
while (True):
    spch = "Hello " + data[
        'userName'] + " ! Please Speak:  Zoos are filled with small and large animals after the beep :"
    tts.textToSpeech(spch).say()
    time.sleep(0.5)
    os.system("echo '\a'")
    time.sleep(0.2)
    stt.SpeechToText('./Desktop/major/sound/file.wav').record(5)
    os.system("echo '\a'")
    response = myVoiceIt.authentication(data['userName'], data['password'],
                                        "./Desktop/major/sound/file.wav",
                                        "en-US")
    ind1 = response.find("ResponseCode")
    ind1 += 15
    ind2 = response.find('"', ind1)
    print(response[ind1:ind2])
    if response[ind1:ind2] == "SUC":
        tts.textToSpeech("Welcome " + data['userName'] +
                         "  How may i Help You!").say()
示例#12
0
    "browse internet": browse,
    "calculate": calc,
    "play music": plmusic
}


def perform_command(argument):
    func = switcher.get(argument, "Invalid Command")
    if (func != "Invalid Command"):
        return func()
    else:
        tts.textToSpeech("Invalid Command").say()


#print(perform_command("read document"))

while True:
    key_press = raw_input()
    if key_press == "":
        print("You pressed enter")
        os.system("echo '\a'")
        time.sleep(0.2)
        stt.SpeechToText('./sound/command.wav').record(3)
        cmd = stt.SpeechToText('./sound/command.wav').speech_to_text()
        print(cmd)
        perform_command(cmd)

    else:
        print("Something went Wront Try Again")
        tts.textToSpeech("Something went Wrong. Try Again").say()
示例#13
0
def textToSpeech(body, lastComment):
    tts.textToSpeech(body, lastComment)