def action(msg): import csv with open(JOKES, newline='') as csvfile: reader = csv.DictReader(csvfile) chosen_row = np_random_choice(list(reader)) logging.info(f"chose joke #{chosen_row['ID']} from 231,657 jokes") return chosen_row['Joke']
def start_listen(): logging.info(START_SCREEN) stt = SpeechToText() tts = TextToSpeech() while True: text = stt.transcribe() output = commands(text) tts.speak(output)
def action(msg): import wikipedia split_msg = msg.split(' ') for key in ['is']: if key in split_msg: target = ' '.join(split_msg[split_msg.index(key) + 1:]) logging.info(f"looking on wikipedia for: {target}") summary = threading(wikipedia.summary, target, sentences=2) return summary
def listen(self) -> sr.AudioData: """ listens to local microphone Returns: AudioData from record """ with sr.Microphone() as source: t0 = time.time() logging.info('start listening...') audio = self.r.listen(source) t1 = time.time() logging.info(f'stopped ... after {t1 - t0}') return audio
def onEnd(self, name, completed): logging.info('finishing', name, completed)
def onWord(self, name, location, length): logging.info('word', name, location, length)
def onStart(self): logging.info('starting')