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 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 working2(event): while (True): text1 = stt.SpeechToText() print "YOU: " + text1 if (text1.upper() == "BYE ") or (text1.upper() == "QUIT ") or ( text1.upper() == "BYE") or (text1.upper() == "QUIT"): break else: text2 = Eliza_Algo.Heart(text1) print "BOT: " + text2 text_to_speech.TextToSpeech(text2, 1)
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()
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()
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 data = {} data['userName'] = userName data['password'] = pswd data['isRegistered'] = "True"
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() #waha dalega test.py wala code while True: key_press = raw_input() if key_press == "":
"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()