def initializeUserData(): ''' Should only be used in tests. Collects user data every time program starts. In official version this should store data permanently, not to memory. ''' wantedName=False #boolean variable which states that the user is OK with his/her name or not while not wantedName: speech.say('what is your name?') name=speech.input() #stores user input to name variable speech.say('your name is ' + name) speech.say('is this o k with you') response=speech.input() #stores user response to previous question to variable if response=='Yes': wantedName=True #user is OK with name gender=None #creates gender variable. we dont know users gender yet (hence the None) doneGender=False while not doneGender: #same thing as before speech.say(name + ', What is your sex, male or female?') gender=speech.input() #user's response if gender=='Male' or gender=='Mail': #pyspeech misinterprets 'male' for 'mail' sometimes pronoun='sir' #this is what CHRIS will use to refer to the user doneGender=True if gender=='Female': pronoun='mam' doneGender=True speech.say('O K , we\'re done') ret_info=[name, gender, pronoun] #returns the name, gender, and pronoun of the user in form of list return ret_info
def tellpassword(): x = cur.execute("SELECT `onlypassword` FROM `adminpasswd` ") x = cur.fetchone() x = x[0] # speech.say("In order to view passwords, first verify your identity") speech.say("Say admin password") admpass = speech.input() print(admpass) x = x.lower() if admpass.lower() == x: speech.say("identity verified") speech.say("which password do you want to view?") act = speech.input() print(act) cur.execute("SELECT * from `act_password`") acts = cur.fetchall() flag = 1 for ac in acts: if ac[0] == act.lower(): speech.say("The password for " + str(act) + " is " + str(ac[1])) flag = 0 if flag: speech.say("Sorry. Account not found") else: speech.say("Identity unverified") speech.say("Try again after some time")
def inputSpeech(self): print "Hello" file = open("Bill.txt","w"); response = "NO" response1 = "Google" speech.say("Hello!!! Welcome to speech recognition for the visually impaired") #while((response != "YES") or (response != "Yes") or (response != "yes")): while((response == "NO") or (response == "No") or (response == "no")): speech.say("Please enter your search query") response1 = speech.input("Say something, please.") speech.say("You said " + response1) print response1 speech.say("Is this what you said?") response = speech.input("Is it ok?") response=str(response) print response #while((response != "No") or (response != "NO") or (response != "no") or (response != "YES") or (response != "Yes") or (response != "yes")): #print "Please say yes or no" #speech.say("Please say yes or no ") #response= speech.input("Please say yes or no") #print response return response1
def rempassword(): speech.say("Which password would you like to add?") act = speech.input() print(act) speech.say("Say COMPLETED when you say password completely") speech.say("Now say the password letter by letter") passwd = speech.input() passwd = passwd.lower() fr = '' while passwd != "completed" and passwd != "Completed": fr = fr + char.retchar(passwd.lower()) print(fr) speech.say("next") passwd = speech.input() print(passwd) print(passwd) speech.say( "to confirm say the password again by following the previous steps") speech.say("start saying the password again") passwd1 = speech.input() passwd1 = passwd1.lower() sr1 = '' while passwd1 != "completed" or passwd1 != "Completed": sr1 = sr1 + char.retchar(passwd1) print(sr1) speech.say("next") passwd1 = speech.input() passwd1 = passwd1.lower() if fr == sr1: cur.execute( "INSERT INTO `act_password`(`account`,`password`) VALUES('%s','%s')" % (act, sr)) else: speech.say("Sorry, the passwords do not match.") speech.say("try again later")
def inputSpeech(self): file = open("Bill.txt","w"); #Variables to store recognized contents response = "NO" response1 = "Google" #Give instructions self.ttsEngine.speakTextSync("Getting ready to take search query") self.ttsEngine.speakText("Please say Yes if query is recognized") self.ttsEngine.speakText("Please say No if you want to re enter the query") #Until the desired query is recognized while((response == "NO") or (response == "No") or (response == "no")): self.ttsEngine.speakTextSync("Search Query?") response1 = speech.input("Say something, please.") #speech.input() : Blocking call. Recognizes speech self.ttsEngine.speakTextSync("You said " + response1) print response1 self.ttsEngine.speakText("Is this what you said?") response = speech.input("Please say yes or no") self.ttsEngine.stopSpeak() response=str(response) print response #Return the recognized query return response1
def blockListen(): while True: phrase = speech.input() speech.say("You said %s" % phrase) print "You said " + phrase if phrase == "turn off": break
def run(self): while True: print "Talk:" phrase = speech.input() #speech.say("You said %s" % phrase) print "You said {0}".format(phrase) #if phrase == "turn off": if phrase.lower() == "goodbye": break
def fun(): var1 = random.choice(("Good morning Sir", "Hello", "Good To see you")) spoken_text = speech.input() if spoken_text in ("Hi", "Hello", "Hey", "Welcome", "Good morning", "Good afternoon"): speech.say(var1) elif spoken_text == "goodbye": exit() else: None
def fun1(): les3 = ("Date", "What's the date", "Tell me the date", "Show me the date") phrase1 = speech.input() for phrase1 in les3: print "Showing Time" a = time.strftime('%X %x %Z') '16:08:12 05/08/03 AEST' print a speech.say(a) break
def fun4(): les7 = "Open youtube" phrase5 = speech.input() for phrase5 in les7: speech.say("I will open Youtube") print "Opening Youtube" f_path = abspath("youtube.bat") if exists(f_path): os.system("youtube.bat") break
def fun3(): les5 = ("Close your eyes") phrase4 = speech.input() for phrase4 in les5: f_path = abspath("eye.bat") if exists(f_path): os.system("eye.bat") else: None break
def fun5(): les8 = "Open Facebook" phrase6 = speech.input() for phrase6 in les8: speech.say("I will open Facebook") print "Opening Facebook..." f_path = abspath("Facebook.bat") if exists(f_path): os.system("Facebook.bat") break
def commands(): speech.say("What can I do for you ") les = ("Open browser", "Open chrome", "Open Mozilla", "Start browser", "Run browser") phrase1 = speech.input() for phrase1 in les: f_path = abspath("browser.bat") if exists(f_path): os.system("browser.bat") break
def mailtop(person): speech.say("What is the message?") while True: msg = speech.input() print(msg) if msg: break else: speech.say("say the message") continue login(person, msg)
def fun6(): les9 = "Open Email" phrase7 = speech.input() for phrase7 in les9: speech.say("I will open your email") print "Opening Email ..." f_path = abspath("Email.bat") if exists(f_path): os.system("Email.bat") else: None break
def adminpassword(text): cur.execute("INSERT INTO `adminpasswd`(`onlypassword`) VALUES('%s')" % (text)) x = cur.execute("SELECT `onlypassword` FROM `adminpasswd` ") x = cur.fetchone() x = x[0] if x is 0: speech.say( "there is no default password to access accounts. Would you like to activate the password?" ) inp = speech.input('') inp = inp.lower() if inp == 'yes': speech.say("Say the password") passwd = speech.input() passwd = passwd.lower() speech.say("To activate the accounts say it again") passwd1 = speech.input() passwd1 = passwd1.lower() if passwd == passwd1: adminpassword(passwd) speech.say("password activate successfully")
def Voice(child_conn): ## #Jarvis will first listen for either turn on speech or turn off speech ## listener = speech.listenfor(["turn on speech", ## "Turn on speech", ## "Turn off speech", ## "turn off speech", ## "turnoff speech", ## "Turnoff speech"], speech_callback) while True: cval.wait_for(0) line = speech.input() child_conn.send(line) print "Voice:",line cval.set_release(2)
def retname(name): try: return {'your': 'my', 'you': 'my', 'yours': 'mine'}[name] except: if name == "my": lst = detector.detectothers() print(lst) if len(lst) > 1: speech.say("many people are there") speech.say("Whose is it?") name = speech.input("") else: name = lst[0] return name else: return name
#coding: utf-8 import wallpaper import speech if __name__ == '__main__': cl = wallpaper.Classifier() while True: response = speech.input('说下你的心情吧:') cl.classify(response) cl.wallpaper() file = open('emotion.txt', 'w') file.write(str(cl.idx + 1)) file.close()
# -*- coding: utf-8 -*- import configparser import speech import os file_name = 'cmdConfig.conf' config = configparser.ConfigParser() # 写入命令配置 # config['command'] = { # '关闭谷歌': 'taskkill /F /IM chrome.exe', # '打开谷歌': '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"', # '打开命令行': 'cmd.exe /c start', # '关闭命令行': 'taskkill /F /IM cmd.exe', # } # config.write(open(file_name, 'w', encoding='utf_8_sig')) config.read(file_name, 'utf_8_sig') commands = config['command'] phrase = speech.input('打开命令行') if phrase in commands.keys(): print(commands[phrase]) speech.say('即将为您%s' %phrase) os.system(commands[phrase]) speech.say('任务已完成!')
import speech import time response = speech.input("Say something, please.") speech.say("You said " + response) def callback(phrase, listener): if phrase == "再见": listener.stoplistening() speech.say(phrase) print(phrase) listener = speech.listenforanything(callback) while listener.islistening(): time.sleep(.5)
def command(text): text = text.lower() if "what is my name" in text or "who am i" in text: speech.say("You are " + uname) elif "how are you" in text: speech.say("Great! How are you?") elif "what is your name" in text: speech.say("I am Raja") elif text == "goodbye": listener.stoplistening() elif "goto" in text: a = text - "goto" mapfinal.destination = a elif "shutdown" in text or "shut down" in text: subprocess.call(["shutdown", "\s"]) elif "restart" in text: subprocell.call[("restart", "\r")] elif "log out" in text or "sign out" in text: subprocell.call[("shutdown", " \l")] elif "tomorrow" in text: know = text.split() st = '' print(know) for l in range(3, len(know)): st += str(know[l]) + " " eventadd.addevent(cyear, cmonth, cday + 1, st, know[2]) elif "note an event" in text: left = text.lstrip("note an event ") fin = left.split() dv = fin[0].lower() day = num.text2int(fin[1]) mon = int(month.retmon(dv)) eventadd.addevent(cyear, mon, day, fin[4], fin[3]) elif "navigate to" in text: destination = text.lstrip("navigate to") mapfinal.route(destination) elif "note a paragraph" in text: subprocell.call(["notepad.exe"]) elif "play songs" in text or "play music" in text or "open music" in text: os.system("start mswindowsmusic:") elif "how much is" in text: fin = text.lstrip("how much is") calc.find(fin) elif "what is" in text: fin = text.lstrip("what is") calc.find(fin) elif "start counter" in text: speech.say("okay. starting counter.") speech.say("how many hours?") hourdur = speech.input('') speech.say("how many minutes?") mindur = speech.input('') speech.say("how many seconds?") secdur = speech.input('') swc.counter(secdur, mindur, hourdur) elif "wake me up in " in text: speech.say("Definitely!") wk = text.lstrip("wake me up in") a = wk.split() count = 0 hourdur = 0 mindur = 0 secdur = 0 for i in a: count += 1 for i in range(0, count): if a[i] == "minutes": mindur = int(a[i - 1]) if a[i] == "seconds": secdur = int(a[i - 1]) if a[i] == "hours": hourdur = int(a[i - 1]) swc.counter(secdur, mindur, hourdur) elif "set an alarm for" in text: al = text.lstrip("set an alarm for") count = 0 hrs = None min = None if "in the morning" in al: ap = 1 elif "in the evening" in al or "in the night": ap = 2 if "o'clock" in text: min = 0 tt = al.split() for i in tt: count += 1 for i in range(0, count): if tt[i] == "o'clock": hrs = int(tt[i - 1]) break if tt[i] == "hours": hrs = int(tt[i - 1]) if tt[i] == "minutes": min = int(tt[i - 1]) swc.addalarm(hrs, min, ap, dt.now().day, dt.now().month) elif "tell me a password" in text: rempassword.tellpassword() elif "who are here" in text: detector.whoarehere()
#! python3 # NOTE: this example requires PyAudio because it uses the Microphone class import speech_recognition as sr import speech # say() speaks out loud. speech.say("I am speaking out loud.") # input() waits for user input. The prompt text is optional. spoken_text = speech.input("Say something, user!") print "You said: %s" % spoken_text # You can limit user input to a set of phrases. spoken_text = speech.input("Are you there, user?", ["Yes", "No", "Shut up, computer."]) print "You said: %s" % spoken_text # If you don't want to wait for input, you can use listenfor() to run a callback # every time a specific phrase is heard. Meanwhile your program can move on to other tasks. def L1callback(phrase, listener): print "Heard the phrase: %s" % phrase # listenfor() returns a Listener object with islistening() and stoplistening() methods. listener1 = speech.listenfor(["any of", "these will", "match"], L1callback) # You can listen for multiple things at once, doing different things for each. def L2callback(phrase, listener): print "Another phrase: %s" % phrase listener2 = speech.listenfor(["good morning Michael"], L2callback) # If you don't have a specific set of phrases in mind, listenforanything() will
def searchQuery(self,query): try: file = open("Bill.txt","w") file1 = open("HTML.txt","w"); #file2 = open("x.txt","w"); #file3 = open("test.txt","w"); gs = GoogleSearch(query) gs.results_per_page = 50 results = gs.get_results() speech.say("Yor results are:") i = 1; for res in results: print "\n" print "Result number" print i print "Title:" print res.title.encode("utf8") print "***************************************" print "Description: " print "***************************************" print res.desc.encode("utf8") print "Link is: " print "***************************************" print res.url.encode("utf8") print "***************************************" print "\n" print "\n" j = str(i) speech.say(j + res.title.encode("utf8") + " And the corresponding description is: " + res.desc.encode("utf-8")) speech.say("Is this option good?") response3 = speech.input("Is this option good ? ") print response3 if ((response3 == "Yes") or (response3 == "YES") or (response3 == "yes")): #if((response3 != "No") or (response3 != "NO") or (response3 != "no")): req = urllib2.Request(res.url, headers={'User-Agent' : "Magic Browser"}) con = urllib2.urlopen( req ) #file.write(con) html = BeautifulSoup(con) #file1.open() print "zzzzzzzzzzzzz" hrefs = html.findAll('a') paras = html.findAll('p') #body = html.findAll('body') #z = str(paras[0]) #print type(z) #print len(paras) lst = [] #for b in body: #file3.write(b.renderContents()); #tags = b.renderContents(); #for tag in tags: #file3.write(tag.contents) for p in paras: #lst.append(re.sub("<.*span.*>","",re.sub("<a href.*>","",re.sub("<p>","",re.sub('<.*b>','',str(p)))))) #re.sub("<p>","",str(p)) #file2.write(p.renderContents()); cnt = p.contents for c in cnt: file.write((str(c.string).replace(""","")).replace("None","").replace("var","")) file1.write((str(c.string).replace(""","")).replace("None","").replace("var","")) #print lst #for l in lst: #file.write(l.encode("utf-8")) file.close() file1.close() #file1.close() #file2.close() #file3.close() print "\n"; print hrefs[10]; print "crewhaha"; break; i = i + 1 except SearchError, e: print "Search failed: %s" % e
#在RollCall表中添加该新字段 #print newkey #print type(newkey) #注意:由于字段的唯一性,每个日期只能执行程序一次,如果需要多次实验,请修改一下机器的日期 cur.execute("alter table RollCall add " + newkey + " varchar(6) NULL") cur.execute("select * from RollCall") li = cur.fetchall() #初始化回答列表 response = ["ye", "here", "yes"] for line in li: print(line[1]) answer = "NULL" i = 1 #每人语音点名在3次以内 while i <= 3: speech.say(line[1]) answer = speech.input() if answer.lower() in response: answer_flag = "T" break #学生回答,则在回答列表中修改新字段的标记为T,并中断该生语音点名 else: answer_flag = "F" #书中代码需要如此修改 i += 1 cur.execute("update RollCall set " + newkey + "='" + answer_flag + "' where stud_id=" + str(line[0]) + " ") #书中代码需要如此修改 print("%s:%s" % (str(line[1]), answer_flag)) conn.commit() conn.close()
import speech # say() speaks out loud. speech.say("I am speaking out loud.") # input() waits for user input. The prompt text is optional. spoken_text = speech.input("Say something, user!") print ("You said: %s" % spoken_text) # You can limit user input to a set of phrases. spoken_text = speech.input("Are you there, user?", ["Yes", "No", "Shut up, computer."]) print ("You said: %s" % spoken_text) # If you don't want to wait for input, you can use listenfor() to run a callback # every time a specific phrase is heard. Meanwhile your program can move on to other tasks. def L1callback(phrase, listener): print ("Heard the phrase: %s" % phrase) # listenfor() returns a Listener object with islistening() and stoplistening() methods. listener1 = speech.listenfor(["any of", "these will", "match"], L1callback) # You can listen for multiple things at once, doing different things for each. def L2callback(phrase, listener): print ("Another phrase: %s" % phrase) listener2 = speech.listenfor(["good morning Michael"], L2callback) # If you don't have a specific set of phrases in mind, listenforanything() will # run a callback every time anything is heard that doesn't match another Listener. def L3callback(phrase, listener): speech.say(phrase) # repeat it back if phrase == "stop now please":
def searchQuery(self,query): try: gs = GoogleSearch(query) gs.results_per_page = 50 results = gs.get_results() queryFlag = 0 url = "" self.ttsEngine.speakText("Your results are:") i = 0 self.ttsEngine.speakTextSync("Pronounce Yes for selecting the link when it is read out. Pronounce No to move to next link.Pronounce back to move to previous link") previousFlag = 0 #Iterate through the obtained results while i < len(results): res = results[i] print "\n" print "Result number" print i + 1 print "Title:" print res.title.encode("utf8") print "***************************************" print "Description: " print "***************************************" print res.desc.encode("utf8") print "Link is: " print "***************************************" print res.url.encode("utf8") print "***************************************" print "\n" print "\n" j = str(i) #Read out the title and description corresponding to the ith link self.ttsEngine.speakText(j + res.title.encode("utf8") + ". And the corresponding description is: " + res.desc.encode("utf-8") + "Is this option good?") #Wait for the text-to-speech engine to start speaking time.sleep(3) queryFlag = 0 #Wait until a speech command is given by user while self.ttsEngine.isSpeaking(): response3 = speech.input() print response3 response3 = str(response3) print type(response3) print len(response3) #if yes, link is selected if ((response3 == "Yes") or (response3 == "YES") or (response3 == "yes") or (response3 == "As") or (response3 == "as")): self.ttsEngine.stopSpeak() url = res.url queryFlag = 1 break #If previous, move to the previous link elif response3 == "previous" or response3 == "Previous" or response3 == "PREVIOUS" or response3 == "back" or response3 == "Back" or response3 == "BACK": previousFlag = 1 self.ttsEngine.stopSpeak() break #Else move to next link else: self.ttsEngine.stopSpeak() break if queryFlag == 1: break if previousFlag == 1: previousFlag = 0 if i == 0: i = 0 else: i = i - 1 continue i = i + 1 return url except SearchError, e: print "Search failed: %s" % e
import speech listener = speech.input() print listener raw_input()
import speech import time response = speech.input("Say something, please.") speech.say("You said " + response) def callback(phrase, listener): if phrase == "goodbye": listener.stoplistening() speech.say(phrase) listener = speech.listenforanything(callback) while listener.islistening(): time.sleep(.5)
import os import smtplib import speech import time server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login("*****@*****.**", "Shiva@01") mailbox={'chandrahaas':'*****@*****.**','shiva':'*****@*****.**',} #text='mail to shiva' text=speech.input() #msg = "message from python....." speech.say("what is the message") msg = speech.input() if text.split()[2] in mailbox.keys(): server.sendmail("*****@*****.**", str(mailbox[text.split()[2]]), str(msg) server.quit()
def askCurrentCommand(self): ## asks for command speech.say('What would you like me to do?') self.__currentCommand=speech.input()+'.'
ser = serial.Serial('COM3', 9600, timeout=1) def commandLED(phraseID): print phraseID result = { 0: 'R', #! Red max 1: 'r', #! Red up 2: 'e', #! Red down 3: 'E', #! Red off 4: 'G', #! Green max 5: 'g', #! Green up 6: 'f', #! Green down 7: 'F', #! Green off 8: 'B', #! Blue max 9: 'b', #! Blue up 10: 'v', #! Blue down 11: 'V', #! Blue off 12: 'o', #! All off 13: 'w' #! All on (white) }[phraseID] ser.write(result) phrases = ['Max Ruby', 'Increase Ruby', 'Decrease Ruby', 'Minimum Ruby', 'Max Green', 'Increase Green', 'Decrease Green', 'Minimum Green', 'Max Blue', 'Increase Blue', 'Decrease Blue', 'Min Blue', 'L E D Off', 'L E D white'] while True: phrase = speech.input("Control the LED", phrases ) print phrase commandLED(phrases.index(phrase)) #ser.close()
def main(): #navFlag is the flag set if 1 iteration is complete ttsEngine.speakTextSync("Hello!!! Welcome to speech recognition for the visually impaired") ttsEngine.speakTextSync("In this system, you can obtain information about your desired topic using a speech query") ttsEngine.speakTextSync("Control the tool, by closely following the various instructions") navFlag = 0 navLink = "" title = "" baseUrl = "" while 1: try: selectedLink = "" if navFlag == 0: #Operations is the speech recognition engine speechRecog = SpeechRecog() query = speechRecog.inputSpeech() print query ttsEngine.speakTextSync("Returned query is " + query) #Iterate through the links and get the selected link selectedLink = speechRecog.searchQuery(query) elif navFlag == 1 and navLink != "": ttsEngine.speakTextSync("Navigating to the requested link. Please wait.") navFlag = 0 selectedLink = navLink navLink = "" baseUrl = getBaseUrl(selectedLink) print baseUrl time1 = time.time() #-------------------------------------------------------- #Create an instance of the FetchHtml Class #-------------------------------------------------------- fetchCntnts = FetchHTMLContent(selectedLink) #-------------------------------------------------------- #Fetch the html contents from the selected page #-------------------------------------------------------- htmlCntnt = fetchCntnts.fetchUrlContents() #-------------------------------------------------------- #Fetch all the content embedded in the <p> tag #-------------------------------------------------------- html = fetchCntnts.fetchParaContent(htmlCntnt) #-------------------------------------------------------- #Remove all the invalid tags in the text #-------------------------------------------------------- removeTags=removeHTMLtags() html = removeTags.StripTags(html) #-------------------------------------------------------- #Fetch the valid required pure content and summarize #-------------------------------------------------------- txt = html time2 = time.time() time3=time.time() obj = SimpleSummarizer() newTxt = obj.summarize(txt,40) time4=time.time() timeTaken = time4 - time3 print "time taken for parsing raw html file is totally: " + str(time2-time1) print "Total time taken for summarization is: " + str(timeTaken) #-------------------------------------------------------- #Clean up the summarized text. Remove the javascript contents and write it to a file #-------------------------------------------------------- regExp=RegexpTokenizer('\w*;$') txtCleanUp=LineTokenizer().tokenize(newTxt) s="" a = "" for i in txtCleanUp: a=regExp.tokenize(i) if a: print a else: s = "" + i print s file1=open("summary.txt","w") file1.write(s) file1.close() #--------------------------------------------------------- #Block to control the reading of summarized contents #--------------------------------------------------------- ttsEngine.speakText("The summarized contents are: ") spkAndListen = speak_listen_summary() navFlag, navLink, title = spkAndListen.readSummary(baseUrl) if navLink == "": navFlag = 0 print "RETURNED" print navFlag print navLink print title #--------------------------------------------------------- except: print "Some error happened" time.sleep(5) ttsEngine.speakText("Odd!! Thr was sm error processing this page We are trying to restart your browser Do you want to continue?") print "Odd!! Thr was sm error processing this page We are trying to restart your browser Do you want to continue?" query = speech.input() print query if(query == "yes" or query == "YES" or query == "Yes"): continue else: sys.exit()
import speech speech.say("我是谁啊") speech.input()
mndel = int("".join(time[2:4])) - now.minute scdel = int("".join(time[4:6])) - now.second if hrdel<0: hrdel+=24 if mndel<0: mndel+=60 if scdel<0: scdel+=60 delay = 3600*hrdel + 60*mndel + scdel print delay #Create a thread to execute action at given time Timer(delay, tmp).start() while True: try: print "Please say the command out loud or press Ctrl+C twice to exit" speech.say("Please say the command out loud") input = speech.input("Please press Control plus C to type the command instead.") #"on fan zero nine three eight" print input, while speech.islistening(): delta = speech.input(" - ") input += delta print delta, speech.say("You said: "+input) print "" except KeyboardInterrupt: speech.stoplistening() print ("Please type your command here; Press Ctrl+C to exit") try: input = raw_input() except KeyboardInterrupt: break if input!="": evaluate(input) input = ""
''' Created on Nov 10, 2014 @author: rajni ''' import json import speech import wikipedia query = speech.input("say something") print query print wikipedia.summary(query, sentences=2) speech.say(wikipedia.summary(query, sentences=2))
import string import speech import webbrowser while True: print "Talk:" phrase = speech.input() speech.say("You said %s" % phrase) print "You said {0}".format(phrase) if phrase.lower() == "One": #it doesn't matter it's not case sensitive url="http://www.google.com" webbrowser.open_new(url)
def fun2(): les2 = ("Tell me a joke") phrase3 = speech.input() for phrase3 in les2: speech.say("I'm programmer, I have no life !") break
#saysomething import speech import time saysomthing = speech.input("hello") time.sleep(3) speech.say(saysomething) print(saysomthing)
def onvoice(self): speech.say("say something")#<--- says "say something" jj=speech.input() print jj self.text.insert(INSERT,str(jj)) '''
#coding: utf-8 from Tom_Data.StreamingAssets import wallpaper import speech if __name__ == '__main__': cl = wallpaper.Classifier() while True: response = speech.input('说下你的心情吧:'.decode('utf-8').encode('gbk')) cl.classify(response) cl.wallpaper() file = open('Tom_Data/StreamingAssets/emotion.txt', 'w') file.write(str(cl.idx + 1)) file.close()
#Devem estar na mesma pasta do codigo. local1 = u'GermanAIML/' local2 = u'aiml_set/' local3 = u'EnglishAIML/' local4= u'Portuguese/' local5 = u'Japanese/' #for l in glob.glob(local1): #taina.learn('aiml_set/'+'*.aiml') #taina.learn('standard/'+'*.aiml') #Database knowledge. Carrega base de conhecimento do bot. #Pode baixa-la internet e usar para testar o codigo. taina.learn('standard/'+'*.aiml') while True: #If don't have Pyspeech or Speech SDK Windows change speech.input to raw_input(). #And use tts for speak. #Se ão tem Pyspeech ou Speech SDK Windows mude o trecho speech.input para raw_input(). #E use o tts para fala. spoken_text = speech.input("User>>") print '-----------------------------------' print 'Voce disse > %s \n' % spoken_text print '-----------------------------------' #spoken_text = raw_input(">>") resposta = taina.respond(spoken_text) print 'Taina>>',resposta speech.say(resposta) if spoken_text == "Close": break print u'Dank.' # #tts.speak(u'Dank.')
# -*-coding:utf-8-*- import speech while True: say = speech.input() speech.say("你说:" + say) if say == "你好": speech.say("你好啊,主人") elif say == "天气": speech.say("今天天气晴朗,主人")
import pyttsx import aiml import os import speech engine=pyttsx.init() k=aiml.Kernel() k.loadBrain("Omegle.brn") # Knowledge Base of Pari k.setBotPredicate("name","Pari") #Name k.setBotPredicate("age","Well i'm 21 years old, how old are u?") #Pari's Age k.setBotPredicate("gender","Female") k.setBotPredicate("location","India") #Location of Pari k.setBotPredicate("birthday","12th May, 1997") #Birthdate of Pari k.setBotPredicate("nationality","Indian") #Nationality of Pari # To change the voice of the bot, go to control panel -> select speech recognition -> Select text to speech and select a voice from there. while True: phrase = speech.input() #Speech to text converter, phrase variable contains the converted text engine.say(k.respond(phrase)) #Text to speech converter engine.runAndWait() if phrase == "Ok, see ya Pari": #To stop talking to Pari, replace Pari with name of your choice. break
openMusic = '我要听音乐' stormPlayer = '我要看电影' tencentQQ = '我要' listenMusic = '我累了' Hawk = '你是谁' Users = '你知道我是谁么' Love = '你喜欢我么' ## judge=speech.input() ## while True: ## if(judge == Start): ## speech.say("我在这呢,你说吧") ## break while True: words = speech.input("Say you want to do.") ##print(words) if (words == Control): speech.say("已关闭语音控制") break elif (words == Hello): speech.say("你也好,今天过得怎么样") elif (words == openPython): os.system('D:\Python\python.exee') ## win32.api.ShellExecute(0,'open','D:\Python\python.exe','','',0) ## win32.api.ShellExecute(0,'open','D:\Python\python.exe','','',1) elif (words == openMusic): os.system('D:\QQ音乐\QQMusic\QQMusic.exe') ## win32.api.ShellExecute(0,'open','D:\QQ音乐\QQMusic\QQMusic.exe','','',0) ## win32.api.ShellExecute(0,'open','D:\QQ音乐\QQMusic\QQMusic.exe','','',1) elif (words == stormPlayer):
# _*_ coding:utf-8 _*_ import os import sys import speech import webbrowser def callback(phr): if phr == '停止交互': speech.say("Goodbye. 人机交互即将关闭,谢谢使用") speech.stoplistening() sys.exit() elif phr == '好累啊': webbrowser.open_new("http://www.youku.com/") elif phr == '深度学习': speech.say("深度学习是个好东西,语音识别已经有了") elif phr == 'cmd': speech.say("即将打开CMD") os.popen("C:\Windows\System32\cmd.exe") # 可以继续用 elif 写对应的自制中文库中的对应操作 while True: phr = speech.input() print(phr) speech.say("You said %s" % phr) callback(phr)
# -*- coding: UTF-8 -*- # thread模块导入方式修改为 import _thread as thread # input方法中 print prompt 改为 return prompt 以返回输入的文件 import speech speech.say('语音识别已开启 ') while True: phrase = speech.input() speech.say('您说的是%s' % phrase) if phrase == "退出程序": break
import speech import time from xgoogle.search import GoogleSearch, SearchError from BeautifulSoup import BeautifulSoup import urllib2 import re file = open("Bill.txt","w"); response = "NO" response1 = "Google" speech.say("Hello!!! Welcome to speech recognition for the visually impaired") while((response != "YES") or (response != "Yes") or (response != "yes")): speech.say("Please enter your search query") response1 = speech.input("Say something, please.") speech.say("You said " + response1) print response1 speech.say("Is this what you said?") response = speech.input("Is it ok?") print response try: gs = GoogleSearch(response1) gs.results_per_page = 50 results = gs.get_results() speech.say("Yor results are:") i = 0; for res in results: