) while True: if not browser.is_active(): print("In ascolto...") sentence = sr.recognize() #sentence = "Riproduci Orphans dei Coldplay" if not sentence == "": print("Not empty") dizionario_confidenza = NLU.predictIntention(sentence) print("Predetto ---> " + dizionario_confidenza['intento']) if dizionario_confidenza['intento'] == 'musica': print("musica") sentence = NLU.format_query_uri(sentence) speech_engine.say("Un secondo...") print("requested --> " + sentence) browser.navigate_music(sentence, speech_engine) if dizionario_confidenza['intento'] == 'aiuto': print("aiuto") speech_engine.say( "Sono un assistente vocale a cui puoi chiedere le seguenti cose: musica da riprodurre, le ultime notizie, il meteo e come funziono! Inoltre supporto anche le gesture! Sono forte, no?" ) continue if dizionario_confidenza['intento'] == 'notizie': print("notizie") speech_engine.set_speed(175) # Meglio rallentarlo notizie = requests.get( 'https://newsapi.org/v2/top-headlines?country=it&apiKey=f896205045cc40cb947d864b5e2df8f9' ) notizie = json.loads(notizie.text)['articles'][0:5] print("Leggo le notizie") speech_engine.say("Ti leggo i titoli delle ultime 5 notizie!")