Ejemplo n.º 1
0
 def read(self,interval_secs,voice) :
    while True :
      if get("read_sw").on :
         line = self.nextline()
         speak.say(line,voice)
         print line
      time.sleep(float(interval_secs))
Ejemplo n.º 2
0
    def __init__(self):

        speak.say("Word Document. Give the name of the file: ")
        filename = raw_input()
        if '.docx' not in filename:
            filename = filename + '.docx'
        self.filename = filename
        try:
            self.doc = Document(filename)
        except:
            try:
                #If new file
                self.filename = os.path.join("word", self.filename)
                self.doc = Document()
                self.saveAsDoc()
            except:
                speak.say(
                    'The document cannot be created due to some error.Try to use any other document name!'
                )
                self.exit()

        self.para = self.doc.add_paragraph('')

        # kb = threading.Thread(target=self.listenKeyboard)
        # kb.start()
        self.menu()
Ejemplo n.º 3
0
def main():
    get_mail()
    speak.say('recent.wav')
    speak.say('subject.wav')
    speak.say('send.wav')
    speak.say('content.wav')
    speak.say('finish.wav')
Ejemplo n.º 4
0
    def add_project(project_count):
        if (project_count==0):
            project_header=document.add_paragraph().add_run("Projects",style="HeadingStyle")

        say("Enter Project Name and Details")
        project_title_info=input("Project Name:")
        project_details_info=input("Project Details:")

        
        projects=document.add_paragraph()
        project_title=projects.add_run(project_title_info)
        project_title_font=project_title.font
        project_title_font.size=Pt(12)
        project_title_font.bold=True
        project_title_font.name='Segoe UI Historic'

        project_details=projects.add_run(" : " +project_details_info)
        project_details_font=project_details.font
        project_details_font.size=Pt(12)
        project_details_font.name='Segoe UI Historic'

        project_count+=1
        if(project_count>=1):
            option=input("Wanna Add More(y/n):")
            if option=='y' or option=='yes':
                add_project(1)
            else:
                pass
Ejemplo n.º 5
0
    def __init__(self, file, password=''):

        try:
            # creating a pdf file object
            self.pdfFileObj = open(file, 'rb')

            # creating a pdf reader object
            self.pdfReader = PyPDF2.PdfFileReader(self.pdfFileObj)

            #decrypting password
            if password != '':
                self.pdfReader.decrypt(password)
        except:
            speak.say('Unable to open the file')
            os._exit(1)

        #line no.
        self._line = 0
        #page no.
        self._page = 0

        # creating a page object
        self.pageObj = self.pdfReader.getPage(self._page)

        # extracting text from page
        self.lines = self.pageObj.extractText().splitlines()

        #Lock
        self.lock = threading.Lock()  #Initially pause is on

        #Pause button
        self.pause_key = 0

        kb = threading.Thread(target=self.listenKeyboard)
        kb.start()
Ejemplo n.º 6
0
 def repeat(self):
     self.lock.acquire()
     speak.say('Repeating')
     self.article -= 1
     if (self.article < 0):
         self.article = 0
     self.lock.release()
Ejemplo n.º 7
0
def follow(min_proximity,interval_secs,voice) :
   """ this does a simple follow of a route in serial order of the waypoints
       this detects 2 transitions:
           1. arrival - coming from a distance > proximity to within proximity
                 action - say arrival and the text 
           2. departure - changing from a distance < proximity to a distance > proximity
                 action - say new waypoint and distance

       start away from every waypoint
       anticipate problem with bouncing in and out at the periphery so make arrival proximity and departure proximity different 

   """

   inside = True
   while True :
      if get("follow_sw").on :
         route = get("route")
         current_wp = route.current_waypoint
         distance = current_wp.distance("km")
         if not inside and distance < min_proximity * 0.8  :     #  arrival
              text = "You are arriving at " + current_wp.name + ". " + current_wp.text
              speak.say(text,voice)
              inside = True
              print(text)
 
         elif inside and distance > min_proximity  :   # departure
              route.next     # move to next waypoint
              route.put()    # update
              next_wp = route.current_waypoint
              inside = False
              text = "Your next waypoint is " + next_wp.name + " which is " + str(round(next_wp.distance("km"),1))+ " km away."
              speak.say(text,voice)
              print(text)
      time.sleep(interval_secs)
Ejemplo n.º 8
0
 def speak(self, text):
     self.lock.acquire()
     if (len(text) == 0):
         speak.say('None')
     else:
         speak.say(text)
     self.lock.release()
Ejemplo n.º 9
0
    def resume(self):
        #Wait until pause is not false
        try:
            # Get articles
            self.articles = self.headlines(categories[self.category_code])

            while self.article < len(self.articles):
                #if on first article of category,then tell category
                if self.article == 0:
                    self.speak(categories[self.category_code] + ' news')
                a = self.article
                if (self.article == a):
                    self.speak('Title ' +
                               self.articles[self.article]['title'].encode(
                                   'ascii', 'ignore').decode('ascii'))
                if (self.article == a):
                    self.speak('Desciption ' +
                               self.articles[self.article]['description'].
                               encode('ascii', 'ignore').decode('ascii'))
                self.article += 1
            self.category_code = (self.category_code + 1) % 7
            #self.resume()

        except:
            speak.say("Some error")
            return
Ejemplo n.º 10
0
    def add_awards(award_count):
        if (award_count==0):
            award_header=document.add_paragraph().add_run("Awards",style="HeadingStyle")

        say("Mention about your awards")
        competition_info=input("Competition Name:")
        winning_info=input("Position:")

        
        awards=document.add_paragraph()
        competition=awards.add_run(competition_info)
        competition_font=competition.font
        competition_font.size=Pt(12)
        competition_font.bold=True
        competition_font.name='Segoe UI Historic'

        winning=awards.add_run(" : " +winning_info)
        winning_font=winning.font
        winning_font.size=Pt(12)
        winning_font.name='Segoe UI Historic'

        award_count+=1
        if(award_count>=1):
            option=input("Wanna Add More(y/n):")
            if option=='y' or option=='yes':
                add_awards(1)
            else:
                pass
Ejemplo n.º 11
0
    def resume(self):
        #Wait until pause is not false
        try:
            if (self._page >= self.total_pages):
                speak.say('We reached the end of file')
                self.exit()

            # creating a page object
            self.pageObj = self.pdfReader.getPage(self._page)

            # extracting text from page
            self.lines = self.pageObj.extractText().splitlines()
            if len(self.lines) == 0:
                speak.say('Unable to detect the content')
            while self._line < len(self.lines):
                #if on first line of page,then tell page number
                if self._line == 0:
                    self.lock.acquire()
                    speak.say(
                        n2w.num2words(self._page + 1, to='ordinal') + ' page')
                    self.lock.release()

                self.lock.acquire()
                speak.say(self.lines[self._line].encode(
                    'ascii', 'ignore').decode('ascii'))
                self._line += 1
                self.lock.release()
            self._page += 1
            self._line = 0
            self.resume()

        except Exception as e:
            print(e)
            speak.say("Some error")
            return
Ejemplo n.º 12
0
def visit(item):
    action = item.getAttribute("action")
    if action == "":
        text = item.getAttribute("title")
    else:
        text = eval(action)
    speak.say(text)
    print(text)
Ejemplo n.º 13
0
	def googleSearch(self):
		from google import google as web
		speak.say("Enter keywords to search")
		keyWords = raw_input()
		data = {'name': keyWords,'link': 'google.com'}
		self.createHistory(data)
		self.googleData = web.search(keyWords,1)
		print "End loading search"
Ejemplo n.º 14
0
 def skip(self):
     self.lock.acquire()
     speak.say('Moving to next Category')
     self.article = 0
     self.category_code = (self.category_code + 1) % 7
     # Get articles
     self.articles = self.headlines(categories[self.category_code])
     self.lock.release()
Ejemplo n.º 15
0
 def rewind(self):
     self.lock.acquire()
     speak.say('Rewinding')
     self.article -= 10
     if (self.article < 0):
         self.article = 0
         self.category_code = (self.category_code - 1 + 7) % 7
     self.lock.release()
Ejemplo n.º 16
0
def create_directory(path, name):
    list2 = []
    for x in os.listdir(path):
        if (x == name):
            speak.say("Folder name already exist. Please choose another name")
            return 0
    os.makedirs(os.path.join(path, name))
    return 1
Ejemplo n.º 17
0
def visit(item) :
   action = item.getAttribute('action')
   if action == "" :
      text = item.getAttribute('title')
   else : 
      text = eval(action)
   speak.say(text)
   print text
Ejemplo n.º 18
0
 def search_first_para(self):
     speak.say("Enter the word to search in paragraphs: ")
     word = raw_input()
     word = re.compile(word, re.I)
     for paras in self.doc.paragraphs:
         if word.search(paras.text) is not None:
             return paras
     return None
Ejemplo n.º 19
0
def visit(item):
    action = item.getAttribute('action')
    if action == "":
        text = item.getAttribute('title')
    else:
        text = eval(action)
    speak.say(text)
    print(text)
Ejemplo n.º 20
0
	def read(self):
		speak.say('Press 1 for bookmark and 2 for history')
		ch = int(raw_input())
		if ch == 1:
			self.accessBookmark()
		elif ch == 2:
			self.accessHistory()
		else:
			speak.say('Invalid Choice! Exiting Bookmark or History Reading Task')
def visit(item) :
   action = item.getAttribute('action')
   if action == "" :
      text = item.getAttribute('title')
   else : 
      text = eval(action)
   say_text = speak.expand(text,Weather.substitutes)
   print text
   speak.say(say_text) 
Ejemplo n.º 22
0
 def addPicture(self):
     speak.say(
         "Enter the name of the Picture (with extension i.e. .png or .jpeg): "
     )
     pic_name = raw_input()
     pic_name = os.path.join("image", pic_name)
     speak.say("Enter the picture width in inches: ")
     pic_width = float(raw_input())
     pic = self.doc.add_picture(pic_name, width=Inches(pic_width))
     self.saveAsDoc()
Ejemplo n.º 23
0
	def createBookmark(self):
		b = {}
		b["name"] = self.result.name.encode('ascii','ignore').decode('ascii')
		b["url"] = self.result.link.encode('ascii','ignore').decode('ascii')
		b["created at"] = str(datetime.datetime.now())
		with open(os.path.join("browser",'bookmarks.txt'), 'a+') as f:
  			json.dump(b, f, ensure_ascii=False)
  			f.write('\n')
  			f.close()
  		speak.say('Bookmark added')
Ejemplo n.º 24
0
def visit(item) :
   action = item.getAttribute('action')
   if action == "" :
      text = item.getAttribute('title')
   else : 
      text = eval(action)
   if text is not None :
      mtext = speak.expand(text,speak.tracker_substitutes)
      speak.say(mtext,c.menu_voice,c.menu_speed)
      print (text)
Ejemplo n.º 25
0
def visit(item):
    action = item.getAttribute('action')
    if action == "":
        text = item.getAttribute('title')
    else:
        text = eval(action)
    if text is not None:
        mtext = speak.expand(text, speak.tracker_substitutes)
        speak.say(mtext, c.menu_voice, c.menu_speed)
        print(text)
Ejemplo n.º 26
0
def open_MyPc():
    list = get_drives()
    for l in list:
        print(l)
        speak.say(l)
    drive = input()
    if is_valid_path(drive):
        return drive
    else:
        speak.say("Enter correct drive")
        return 0
Ejemplo n.º 27
0
 def playPlaylist(self):
     speak.say("Press y to play the song")
     for file in self.autoPlaylist:
         f = file[0:len(file) - 4]
         speak.say("Do you want to listen {0}".format(f))
         r = raw_input()
         if r == 'y':
             m = music()
             m.play(file)
         else:
             pass
Ejemplo n.º 28
0
	def say(self):
		#os.system("say {0}".format(line))
		while True:
			if len(self.buffer):
				line = self.buffer.pop()
				while self.pause_key:
					pass
				if len(line):
					self.lock.acquire()
					speak.say(line)
					self.lock.release()
Ejemplo n.º 29
0
 def enterText(self):
     speak.say("Enter the text: ")
     lines = []
     while True:
         line = raw_input()
         if line:
             lines.append(line)
         else:
             break
     text = '\n'.join(lines)
     return text
Ejemplo n.º 30
0
    def add_experience(experience_count):
        if (experience_count==0):
            experience_header=document.add_paragraph().add_run("Experience",style="HeadingStyle")

        say("Name of the Company")
        company_info=input("Company Name:")
        experience=document.add_paragraph()
        company=experience.add_run(company_info)
        company_font=company.font
        company_font.bold=True
        company_font.size=Pt(15)
        company_font.name='Segoe UI Historic'
        
        spacing = experience.add_run()
        spacing.add_break(WD_BREAK.LINE)

        say("Your Role in the company")
        role_info=input("Role:")
        role=experience.add_run(role_info)
        
        spacing = experience.add_run()
        spacing.add_break(WD_BREAK.LINE)

        say("How long")
        time_period_info=input("Time Period:")
        time_period=experience.add_run(time_period_info)

        experience_count+=1
        if(experience_count>=1):
            say("Wanna Add one more")
            option=input("Wanna Add More(y/n):")
            if option=='y' or option=='yes':
                add_experience(1)
            else:
                pass
Ejemplo n.º 31
0
    def jump(self):
        #Clear the input flush
        while msvcrt.kbhit():
            msvcrt.getch()
        self.lock.acquire()
        speak.say('Tell me the para number to jump on?')
        self._para = int(raw_input()) - 1
        if (self._para < 0):
            self._para = 0
        if (self._para > self.total_paras):
            self._para = self.total_paras - 1
        if (self._para >= self.total_paras):
            speak.say('We reached the end of file')
            self.exit()
        self._line = 0
        #if on first line of para,then tell para number
        if self._line == 0:
            speak.say(n2w.num2words(self._para + 1, to='ordinal') + 'para')

        # creating a para object
        self.paraObj = self.paragraphs[self._para]

        # extracting text from para
        self.lines = self.paraObj.text.splitlines()
        if len(self.lines) == 0:
            speak.say('Unable to detect the content')
        self.lock.release()
Ejemplo n.º 32
0
	def __init__(self):
		speak.say("Welcome to Web Browsing")
		self.url = ""
		self.googleData = None
		self.buffer = ["Press f to google search", "Press r to listen bookmark or history"]
		#Pause 
		self.pause_key = 0 #Initially pause is off
		#Lock
		self.lock = threading.Lock()  
		kb = threading.Thread(target=self.listenKeyboard)
		#sp = threading.Thread(target=self.say)
		google = threading.Thread(target=self.googleSearchSpeak)
		kb.start()
		#sp.start()
		google.start()
		self.say()
Ejemplo n.º 33
0
def scanFace():
    flag = "1"
    camera = picamera.PiCamera()
    camera.resolution = (320, 240)
    output = np.empty((240, 320, 3), dtype=np.uint8)
    print("Loading known face image(s)")
    # obama_image = face_recognition.load_image_file("abhi.jpg")
    # obama_face_encoding = face_recognition.face_encodings(obama_image)[0]
    # npar=np.frombuffer(obama_face_encoding)
    # np.save('test3.npy',npar)
    # d = np.load('test3.npy')

    # Initialize some variables
    face_locations = []
    face_encodings = []
    dataset = []
    nameset = []
    loadDataset(dataset, nameset)
    print("Please face the camera")
    say("Please face the camera")
    scannedName = "#"
    while flag == "1":
        #checkLock()
        # Grab a single frame of video from the RPi camera as a numpy array
        camera.capture(output, format="rgb")

        # Find all the faces and face encodings in the current frame of video
        face_locations = face_recognition.face_locations(output)
        # print("Found {} faces in image.".format(len(face_locations)))
        face_encodings = face_recognition.face_encodings(
            output, face_locations)
        # Loop over each face found in the frame to see if it's someone we know.
        for face_encoding in face_encodings:
            # See if the face is a match for the known face(s)
            match = face_recognition.compare_faces(dataset, face_encoding)
            for name, status in zip(nameset, match):
                if status == True:
                    scannedName = name
                    break

            if scannedName != '#':
                print(scannedName)
                flag = "0"
                break
    camera.close()
    say(scannedName)
    return scannedName
Ejemplo n.º 34
0
    def repeat(self):
        self.lock.acquire()
        speak.say('Repeating')
        self._line -= 1
        if (self._line < 0):
            self._line = 0
            self._page -= 1
            if (self._page < 0):
                self._page = 0

            # creating a page object
            self.pageObj = self.pdfReader.getPage(self._page)

            # extracting text from page
            self.lines = self.pageObj.extractText().splitlines()
            if len(self.lines) == 0:
                speak.say('Unable to detect the content')
        self.lock.release()
Ejemplo n.º 35
0
   def refresh(self) :
      page = urlopen(self.url).read().decode("UTF8")   # fetch the JSON
      parsed_page= json.loads(page) 
      tweets = []
      for tweetj in parsed_page['results'] :
         tweet = tts_tweet(tweetj)
         if tweet.pubDate > self.last and tweet.accept() :
               tweet.clean()
               tweets.append(tweet)

      if len(tweets) > 0 :
            self.last = tweets[0].pubDate
            tweets.reverse() # to get them into chronological order

            for tweet in tweets :   
               print(">",tweet.pubDate,":",tweet.text)
               speak.say(tweet.cleanText)
               time.sleep( self.pause_secs)

      time.sleep(self.refresh_secs)
Ejemplo n.º 36
0
	def connectAuth(self):
		print "Connecting to server:" +self.server + " using creds ( username:"******" , password:"******")";
		headers = {'X-Auth-User': self.username , 'X-Auth-Key': self.password }		
		res = requests.get(self.server ,headers=headers)
		print res.json;
		print res.headers;		
		
		if( res.status_code == requests.codes.ok):
		  say("I am successfully authenticated for cloud storage");
		  self.authenticated="true";
			  
		else:
		  say("I am unable to connect to the cloud storage.  I got a response code of " + str(res.status_code)); 
		
		#set the local headers
		self.authToken=res.headers["x-auth-token"];
		self.storageToken=res.headers["x-storage-token"];
		self.storageUrl=res.headers["x-storage-url"];
        
		if(self.authenticated):
		  say("Now that I am connected I will attempt to take and upload a picture.");
		
		
		#try to take the picture
		
		filename = 'image' + datetime.datetime.now().strftime("_%B_%d_%Y_%I%M%p");
		filetype ='jpg';
		store(filename,filetype);
		
		fullname = filename+'.'+filetype;
		
		myfile = open("/orbital/media/"+fullname,"rb");  
		data = myfile.read();
		#now prepare to upload it to the cloud.
		urlPath = self.storageUrl +'/media/pictures/'+fullname
		#headers = {'X-Auth-Token': self.authToken,  'X-Storage-Url': (self.storageUrl +'/media/pictures/myfile.jpg') ,'Content-Length': str(os.path.getsize('/orbital/media/image.jpg')) }	
		headers = {'X-Auth-Token': self.authToken }	
		
		
		res2 = requests.put(urlPath, data=data ,headers=headers);
		print res2.text;
		print res2.headers;
		say("OK I tried to upload.");
Ejemplo n.º 37
0
import xmlutils
import control
from persistant import get
import position

substitutes = {
     "W":"West","N":"North","S":"South","E":"East",
     "km/h":"kilometers per hour","C":"Celsius","mph":"miles per hours", "kts": "knots",
     "Mon":"Monday","Tue":"Tuesday","Wed":"Wednesday","Thu":"Thursday","Fri":"Friday","Sat":"Saturday","Sun":"Sunday",
     "NNE":"Nor Nor East","NE":"Nor East","ENE":"East Nor East","ESE":"East Sow East",
     "SE":"Sow East" ,"SSE" :"Sow Sow East", "SSW":"Sow Sow West","SW":"Sow West","WSW":"West Sow West",
     "WNW":"West Nor West","NW":"Nor West","NNW":"Nor Nor West",
     "%":"percent"
     }


control.Control("speed",step=10,initial=60)

while True :
   if get("speed").on :
      position = get("gps")
      speed = round(conv.convert(position.speedOverGround,"kt","mph"),1)
      course = int(position.courseOverGround)
      points = conv.degree_to_compass_point(course)
      text = points + " at " + str(speed) + " mph " 
      mtext = speak.expand(text,substitutes)
      speak.say(mtext)
      print(text)

   time.sleep(get("speed").value)
Ejemplo n.º 38
0
Switch("talk_sw")
Option("talk_mode",["location","velocity","time","relative location","relative velocity","expected time of arrival"])

if c.talk_status == "off" :
   Switch("talk_sw").toggle()

while True :
   if get("talk_sw").on :
      mode = get("talk_mode").value
      if mode == "location" :
          string = get("gps").location
      elif mode== "velocity" :
          string = get("gps").velocity    
      elif mode == "relative location" :
          destination = get("route").current_waypoint
          string = destination.relative_location
      elif mode == "relative velocity" :
          destination = get("route").current_waypoint
          string = destination.relative_velocity
      elif mode == "expected time of arrival" :
          destination = get("route").current_waypoint
          string = destination.eta
      elif mode == "time" :
          string = date_time.say_time()
      else :
          pass
      mstring = speak.expand(string,speak.tracker_substitutes)
      speak.say(mstring,c.talk_voice)
      print string
   time.sleep(get("talk_rate").value)
Ejemplo n.º 39
0
#!/usr/bin/python

import speak

from persistant import *
from barometer import *
from switch import *

while True :
    baro = get("baro")
    sw = get("barotalk")
    if sw.on :
       msg = baro.talk_text()
       speak.say(msg)
    time.sleep (300)
    
 
Ejemplo n.º 40
0
#!/usr/bin/env python3
import time
import speak

from persistant import *
from switch import *

Switch("clock").put()

while True :
   sw = get("clock")
   if sw.on :
      hours = int(time.strftime('%I'))
      minutes = int(time.strftime('%M'))
      time_message = \
          str(int(hours)) + " oh clock " if minutes == 0 else \
          "a quarter past " + str(int(hours)) if minutes == 15 else \
          "half past " + str(int(hours)) if minutes == 30 else \
          str(minutes) + "minutes past " + str(int(hours)) if minutes < 30 else \
          "a quarter to " +str (int(hours) + 1) if minutes == 45 else \
          str(60 - minutes) + "minutes to " + str(int(hours) + 1) 

      message = "The Raspberry Pi time is " + time_message
      speak.say(message)
      
   time.sleep(60)

Ejemplo n.º 41
0
def visit(item) :
   text = item.getAttribute('title')
   speak.say(text)
   print text
Ejemplo n.º 42
0
#!/usr/bin/env python
import time,sys

import speak
import conv
import xmlutils
import control
from persistant import get
import position

control.Control("speed",step=10,initial=60)

while True :
   if get("speed").on :
      position = get("gps")
      speed = int(float(position.speedOverGround))
      course = int(float(position.courseOverGround))
      points = conv.degree_to_compass_point(course)
      text = points + " at " + str(speed) + " knots " 
      speak.say(text)
      print(text)

   time.sleep(get("speed").value)
Ejemplo n.º 43
0
#!/usr/bin/python
import speak
import presenter

for key in presenter.read_key() :
   print key
   speak.say(key)