def query(self, text): from voice_recognition import VoiceRecognition text = text.lower() vr = VoiceRecognition() if "search " in text: print(text[8:]) if "wikipedia" in text: text = text.replace("wikipedia", "") result = wiki.summery(text, sentences=2) vr.speak(f"According to wikipedia, {result}") if "play music" in text: songs = subprocess.Popen("ls ~/Music/*.mp3", shell=True, stdout=subprocess.PIPE) all_songs = [] for song in songs.stdout: song = str(song) all_songs.append(f"{song[1:-3]}'") os.system(f"open {choice(all_songs)}") if "system" in text: os.system("alacritty -e htop") if "the time" in text: cur_time = datetime.datetime.now().strftime("%H:%M:%S") vr.speak(f"sir, current time is {cur_time}") print(f"sir, current time is {cur_time}") if "weather" in text: weather = WeatherData() cur_weather = weather.get_current_data() vr.speak(f"current weather is {cur_weather['status']}, \ having {cur_weather['temp']} temperature") print( f"current weather is {cur_weather['status']}, having {cur_weather['temp']} temperature" ) if "current price" in text: tracker = PriceTracker() try: data = tracker.get_data() except Exception as e: vr.speak( "Sir, you have not given url of the product you are trying to track. Please go to gui section and click on price tracker button and set urls first" ) print( "Sir, you have not given url of the product you are trying to track. Please go to gui section and click on price tracker button and set urls first" ) if "amazon" in text: amazon_price = data['amazon'] vr.speak( f"currently, price of your selected product {amazon_price[0]} on amazon is {amazon_price[1]}" ) print( f"currently, price of your selected product {amazon_price[0]} on amazon is {amazon_price[1]}" ) elif "flipkart" in text: flipkart_price = data['flipkart'] vr.speak( f"currently, price of your selected product {flipkart_price[0]} on flipkart is {flipkart_price[1]}" ) print( f"currently, price of your selected product {flipkart_price[0]} on flipkart is {flipkart_price[1]}" ) else: vr.speak(f"Ok sir") vr.speak( f"Your product : {data['amazon'][0]} on amazon has price of rupees {data['amazon'][1]}" ) vr.speak( f"and {data['flipkart'][0]} on flipkart has price of rupees {data['flipkart'][1]}" ) vr.speak( f"currently price is low on {data['low price website']} which is {data[data['low price website']][1]}" ) vr.speak(f"and your desired price is {data['desired price']}") print( f"Your product : {data['amazon'][0]} on amazon has price of rupees {data['amazon'][1]}" ) print( f"and {data['flipkart'][0]} on flipkart has price of rupees {data['flipkart'][1]}" ) print( f"currently price is low on {data['low price website']} which is {data[data['low price website']][1]}" ) print(f"and your desired price is {data['desired price']}")
def weather_page(self): def destroy_win(): weather_win.destroy() def store_names(): weather_data.save_names(city_entry.get(), country_entry.get()) weather_win.destroy() self.weather_page() def confirm_msg(): msg = messagebox.askquestion( 'Warning', 'Are you sure you want to chenge city name ?', icon='warning') if msg == 'yes': weather_win.destroy() change_names() def change_names(): os.system("rm weather.txt") self.weather_page() data = None weather_data = WeatherData() weather_win = Tk() weather_win.title("Weather Forcast Information") weather_win.config(padx=30, pady=30) weather_win.resizable(0, 0) if not weather_data.status: Label(weather_win, text="Welcome").grid(row=0, column=0, columnspan=2) Label(weather_win, text="Enter your location detail here").grid(row=1, column=0, columnspan=2) Label(weather_win, text="City name : ").grid(row=2, column=0) city_entry = Entry(weather_win, width=20) city_entry.grid(row=2, column=1) Label(weather_win, text="Country name : ").grid(row=3, column=0) country_entry = Entry(weather_win, width=20) country_entry.grid(row=3, column=1) Button(weather_win, text="Done", command=store_names, bg='brown', fg='white').grid(row=8, column=0, columnspan=2) else: data = weather_data.get_current_data() will_rain = weather_data.rain_alert() Label(weather_win, text="Current Weather Forcast").grid(row=0, column=0, columnspan=2) Label(weather_win, text=f"Temperature : ").grid(row=1, column=0) Label(weather_win, text=f"{data['temp']} C").grid(row=1, column=1) Label(weather_win, text=f"Wind : ").grid(row=2, column=0) Label(weather_win, text=f"{data['wind speed']['speed']} m/s").grid(row=2, column=1) Label(weather_win, text=f"Status :").grid(row=3, column=0) Label(weather_win, text=f"{data['status']}").grid(row=3, column=1) Button(weather_win, text="Ok", command=destroy_win, bg='brown', fg='white').grid(row=4, column=0) Button(weather_win, text="Change city name", bg='brown', fg='white', command=confirm_msg).grid(row=4, column=1)