def sendmail(): message = ' ' b = open('body', 'r') b_line = b.readlines() for i in range(0, b_line.__len__()): message += b_line[i] c = open('credentials', 'r') c_line = c.readlines() id = c_line[0] password = c_line[1] d = open('recipient', 'r') d_line = d.readlines() rec = d_line[0] e = open('subject', 'r') e_line = e.readlines() sub = e_line[0] #fromaddr = "*****@*****.**" #toaddr = "*****@*****.**" msg = MIMEMultipart() msg['From'] = id msg['To'] = rec msg['Subject'] = sub msg.attach(MIMEText(message, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.ehlo() server.login(id, password) text = msg.as_string() server.sendmail(id, rec, text) text1 = "mail sent successfully bro!!!!!" print(text1) pyspeak.speakup(text1)
def searchtopic(): f = open('topicinput', 'r') t = f.readlines() try: o = wikipedia.summary(t, sentences=5) t = re.sub(r'\([^)]*\)', '', o) p = t.encode("utf-8") print(p) pyspeak.speakup(p) except Exception as e: print(str(e)) pyspeak.speakup(e) print("----------")
def weather_info(loc): url = api_address + loc json_data = requests.get(url).json() print(json_data) w_description = json_data['weather'][0]['description'] m_tempmax = str(float(json_data['main']['temp_max']) - 273.15) m_tempmin = str(float(json_data['main']['temp_min']) - 273.15) m_humidity = str(json_data['main']['humidity']) m_presure = str(json_data['main']['pressure']) wind_speed = str(json_data['wind']['speed']) #wind_dir = str(json_data['wind']['deg']) #print('max temp ='+m_tempmax+'min temp='+m_tempmin) text = 'hello today is %d %s %d time is ' % (day, month, year) text2 = hour + 'hours' + mins + 'minutes.' + ' todays weather will be' + w_description + ', max temperature will be ' + m_tempmax + 'degree celsius, minimum temperature will be ' + m_tempmin + 'degree celsius,the humidity in air will be ' + m_humidity + 'percentage and wind flowing' + wind_speed + "kilometer per hour" texts = text + text2 #hitext=speech.translation(texts) print(texts) #speech.speak(texts) pyspeak.speakup(texts)
# if msg.is_multipart(): # for payload in msg.get_payload(): # # if payload.is_multipart(): ... # email_body=payload.get_payload() # print (email_body) #else: email_body = msg.get_payload() # print (email_body) #email_body=msg.get_payload() #t = re.sub(r'\<[^>]*\>', '', email_body) #soup=BeautifulSoup(str(email_body),"html.parser") #b=html2text(email_body, ignore_tags=("img"), indent_width=4, page_width=80) #email_body=soup.get_text() #p=email_body.encode("utf-8") #body=soup.get_text() #t = re.sub(r'\[[^>]*\]', '', body) text = 'Mail Number' + str( count ) + 'From : ' + email_from + 'Subject : ' + email_subject + 'Message is:' print('Mail Number' + str(count) + '\n\nFrom : ' + email_from + '\n') print('Subject : ' + email_subject + '\n') print('Message is' + '\n') print(email_body) pyspeak.speakup(text) count = count + 1 except Exception as e: print(str(e))
data1=dict() z=-1 k=0 key='' for i in id: print(i) for j in data: print(j) k=k+1 if i==j: print("match found at "+i+" "+j ) key=data[k-1] z=k-1 k=0 print(key) if z==-1: pyspeak.speakup("speak properly") #if z==0 or z==1 or z==2 or z==3: if z==4 or z==5 or z==6: searchtopic() if z==7: weather() if z==8: sendmail()
import sounddevice as sd from speak import pyspeak myrec=sd.rec() print(myrec) pyspeak.speakup(myrec)