def watch_rand_vid(r): 'Function that gets called during wakeup' (playlist, vid_name) = get_random_playlist(r) first_item = playlist[0] show_name2 = os.path.split(first_item)[0].replace(r'D:\sys\e','').replace('E:','').replace('\\',' ').replace(':','').replace('TV','') print("vidname: %r " % (first_item,)) robos.speak(r, 'How about some '+show_name2, -3) play_playlist(r, playlist)
def research(r, start_line_str=None, rate='3', sentence_mode=True, open_file=False): fname = join(split(__file__)[0], 'to_speak.txt') if start_line_str == "prep": os.system(fname) return if open_file is True: os.system(fname) import utool as ut input_str = preprocess_research(ut.readfrom(fname)) if sentence_mode: input_str = input_str.replace('\n', ' ').replace('. ', '.\n') input_str = re.sub(' *', ' ', input_str) line_count = 0 page = 0 page_re = re.compile(' *--- Page [0-9]* *--- *') if start_line_str is None: try: start_page = 0 start_line = int(input('Did you forget the start line?')) except Exception: pass elif start_line_str.find('page') != -1: start_page = int(start_line_str.replace('page', '')) start_line = 0 else: start_page = 0 start_line = int(start_line_str) print('Starting on line: %d' % (start_line)) print('Starting on page: %d' % (start_page)) for line in input_str.split('\n'): print('____') # Check for page marker if page_re.findall(line) != []: page = int(re.sub(' *--- Page ', '', line).replace('---', '')) # Print out what is being read line_count += 1 print('%d, %d > %s' % (page, line_count, line)) if start_line > line_count or start_page > page: continue # Preprocess the line line = process_research_line(line) if line == '': continue print('--') robos.speak(r, line, rate)
def research(r, start_line_str=None, rate='3', sentence_mode=True, open_file=False): fname = join(split(__file__)[0], 'to_speak.txt') if start_line_str == "prep": os.system(fname) return if open_file is True: os.system(fname) import ubelt as ub input_str = preprocess_research(ub.readfrom(fname)) if sentence_mode: input_str = input_str.replace('\n', ' ').replace('. ', '.\n') input_str = re.sub(' *', ' ', input_str) line_count = 0 page = 0 page_re = re.compile(' *--- Page [0-9]* *--- *') if start_line_str is None: try: start_page = 0 start_line = int(input('Did you forget the start line?')) except Exception: pass elif start_line_str.find('page') != -1: start_page = int(start_line_str.replace('page', '')) start_line = 0 else: start_page = 0 start_line = int(start_line_str) print('Starting on line: %d' % (start_line)) print('Starting on page: %d' % (start_page)) for line in input_str.split('\n'): print('____') # Check for page marker if page_re.findall(line) != []: page = int(re.sub(' *--- Page ', '', line).replace('---', '')) # Print out what is being read line_count += 1 print('%d, %d > %s' % (page, line_count, line)) if start_line > line_count or start_page > page: continue # Preprocess the line line = process_research_line(line) if line == '': continue print('--') robos.speak(r, line, rate)
def speak(r, to_speak, rate=-5): print('alarm> Speaking at rate ' + str(rate) + ': ' + to_speak) robos.speak(r, to_speak, rate)
def sc(r, rate=-5): to_speak = robos.get_clipboard() robos.speak(r, to_speak, rate)
def wake_up(r, WAKE_UP_MODE=0): if type(WAKE_UP_MODE) == type(''): WAKE_UP_MODE = int(WAKE_UP_MODE) (year, month, day, weekday, hour, minu, ampm) = get_readable_time(r) #if r.computer_name == "BakerStreet": #set_volume(r, 40) #else: #set_volume(r, 30) if WAKE_UP_MODE == 411: #set_volume(r, 50) webbrowser.open('http://www.youtube.com/watch?v=eh7lp9umG2I') return elif WAKE_UP_MODE == 0: wake_up_text = '' elif WAKE_UP_MODE == 2: wake_up_text = ''' day na day na hey listen day na. Listen Listen! day na and jon I have something to tell you guess what did you guess yet ok, well here it is I have good news! You dont have to wake up. Isnt it wonderful? Do you love me yet day na? I just want to make you happy and this is the only way I know how ''' elif WAKE_UP_MODE == 3: wake_up_text = ''' ok this is going to suck a little bit but don't worry there is good news, and there is bad news. The bad news is it is around %s %s %s The date is %s %s, %s ... But here is the good news. it is %s, and %s is a fine day for science! ''' % ( hour, minu, ampm, month, day, year, weekday, weekday ) elif WAKE_UP_MODE == 1: wake_up_text = ''' wake up! wake up! wake up! This is your reminder to wake up! Wait I have a better idea ''' rate_of_speach_base = -10 text_lines = map(lambda x: x.strip(), wake_up_text.split('\n')) for i in range(len(text_lines)): line = text_lines[i] if line == "": continue import numpy as np percent_through = (float(i)/float(len(text_lines))) rate_of_speach = rate_of_speach_base + (8 * np.sqrt(percent_through)) robos.speak(r, line, rate_of_speach) OLD_VID = False if OLD_VID: selectables = ['Bill Nye', 'Bob Ross', 'BBC Life', 'Sheep in the Big City'] selection = 3 show_name = selectables[selection] show_dir = r.f.alarm_videos[show_name] robos.speak(r, 'How about some '+show_name2, -2) random_video(r, [show_dir]) else: watch_rand_vid(r)