def tell_news(category): page = requests.get(urls[category]) soup = BeautifulSoup(page.content, 'html.parser') headlines_list = soup.find_all('h3', class_='story-title') for headlines in headlines_list: tts.operation(headlines.get_text()) time.sleep(1)
def ir_operation(r_name, f_name): f_name = f_name.replace(' ', '_') print(f_name) key = ir_helper.get_key(r_name, f_name) if (not key): tts.operation("Either Device or function is incorrect") else: print(key) ir_helper.send_code(r_name, key) tts.operation("Command send to " + r_name)
def play_music(query_text, driver): tts.operation('playing song') music.play_song(query_text, driver) #check stop command while True: speech_to_text.resetSTT(driver) if speech_to_text.invoke(driver, 'stop'): #user said stop music.stop_song(driver) return else: #user did not said stop in n tries speech_to_text.resetSTT(driver)
def main(): text_to_speech.operation( 'Hello There! Wait for a while to let me set things up.') #get profile data from firebase profile = fb.get('/profile', None) #initialize STT for the first time speech_to_text.resetSTT(driver) #welcome message text_to_speech.operation('Hello ' + profile['name'] + '. How can I help you?') while True: if speech_to_text.invoke(driver, 'listen'): #user said listen text_to_speech.operation('Yes, say it') rec_text = speech_to_text.operation(driver) think(rec_text, driver) else: #user did not said listen in n tries speech_to_text.resetSTT(driver)
def unknown_request(): tts.operation("Sorry I don't know this.")
def get_req_news(category): tts.operation('fetching latest news') news_helper.tell_news(category) tts.operation('this was all for today')
def get_weather(): tts.operation('getting weather') response = weather_helper.get_report() tts.operation(response)
def search_wiki(input_text): tts.operation('searching') response = wiki_helper.search(input_text) print(response) tts.operation(response)
def set_alarm(hours, minutes, ap): response = alarm_helper.create(hours, minutes, ap) tts.operation(response)
def relay_operation(l_name, state): response = relay_helper.toggle(l_name, state) tts.operation(response)
def what_is_time(): text = time_tell.tell() tts.operation(text)
def who_are_you(): text = introduce.intro() tts.operation(text)