Add fuzzy and text-classification light model #1
					 3 changed files with 42 additions and 21 deletions
				
			
		Add play genre action
				commit
				
					
					
						aa512535aa
					
				
			
		|  | @ -4,10 +4,12 @@ from rapidfuzz import process, fuzz, utils | ||||||
| ROOMS = ["cuisine", "salon", "chambre", "bureau"] | ROOMS = ["cuisine", "salon", "chambre", "bureau"] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| MUSIQUE_GENRE_SHORT = ["synthpop", "jazz classique", "jazz manouche", "classique", "rock", "jazz", "blues", "film", "francaise", "pop",  "reggae", "folk", | MUSIQUE_GENRE_SHORT = ["synthpop", "jazz classique", "jazz manouche", "latine", "classique", "rock", "jazz", | ||||||
|  |                        "blues", "film", "francaise", "pop",  "reggae", "folk", | ||||||
|                        "électro", "punk", "corse", "arabe", "persane",  "piano", "rap", "slam"] |                        "électro", "punk", "corse", "arabe", "persane",  "piano", "rap", "slam"] | ||||||
| 
 | 
 | ||||||
| MUSIQUE_GENRE_LONG = ["synthpop", "jazz classique", "jazz manouche", "classique", "rock", "jazz", "blues", "musique de film", "chanson francaise", "pop",  "reggae", "folk", | MUSIQUE_GENRE_LONG = ["synthpop", "jazz classique", "jazz manouche", "chanson latine", "classique", "rock", "jazz", | ||||||
|  |                       "blues", "musique de film", "chanson francaise", "pop",  "reggae", "folk", | ||||||
|                       "électro", "punk", "chanson corse", "chanson arabe", "chanson persane",  "piano", "rap", "slam", "chanson classique"] |                       "électro", "punk", "chanson corse", "chanson arabe", "chanson persane",  "piano", "rap", "slam", "chanson classique"] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										46
									
								
								src/mpd.py
									
										
									
									
									
								
							
							
						
						
									
										46
									
								
								src/mpd.py
									
										
									
									
									
								
							|  | @ -2,17 +2,18 @@ import logging | ||||||
| import random | import random | ||||||
| from mpd import MPDClient | from mpd import MPDClient | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class Mpd(): | class Mpd(): | ||||||
| 
 | 
 | ||||||
|     def __init__(self, ip, yoda): |     def __init__(self, ip, yoda): | ||||||
|         self.ip = ip |         self.ip = ip | ||||||
|         self.port = 6600 |         self.port = 6600 | ||||||
|         self.client = MPDClient()               # create client object |         self.client = MPDClient()               # create client object | ||||||
|         self.client.timeout = 10                # network timeout in seconds (floats allowed), default: None |         # network timeout in seconds (floats allowed), default: None | ||||||
|  |         self.client.timeout = 10 | ||||||
|         self.client.idletimeout = None |         self.client.idletimeout = None | ||||||
|         self.yoda = yoda |         self.yoda = yoda | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|         self.client.connect(ip, self.port) |         self.client.connect(ip, self.port) | ||||||
|         logging.debug(self.client.mpd_version) |         logging.debug(self.client.mpd_version) | ||||||
|         self.client.close() |         self.client.close() | ||||||
|  | @ -36,7 +37,8 @@ class Mpd(): | ||||||
|         logging.debug('Listing '+self.normalize_genre(genre)) |         logging.debug('Listing '+self.normalize_genre(genre)) | ||||||
|         try: |         try: | ||||||
|             # todo: select only one album instead of the artist |             # todo: select only one album instead of the artist | ||||||
|             list_album = self.client.lsinfo("Files/Genres/"+self.normalize_genre(genre)) |             list_album = self.client.lsinfo( | ||||||
|  |                 "Subsonic/Genre/"+self.normalize_genre(genre)) | ||||||
|         except: |         except: | ||||||
|             list_album = [] |             list_album = [] | ||||||
| 
 | 
 | ||||||
|  | @ -61,17 +63,31 @@ class Mpd(): | ||||||
|         return NORMALIZED_GENRE[genre.lower()] |         return NORMALIZED_GENRE[genre.lower()] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| NORMALIZED_GENRE = { | NORMALIZED_GENRE = { | ||||||
|     'classique': 'classique', |     'classique': 'Classique', | ||||||
|     'musique classique': 'classique', |     'musique classique': 'Classique', | ||||||
|     'jazz': 'jazz', |     'jazz': 'Jazz', | ||||||
|     'chanson française': 'chanson francaise', |     'chanson française': 'Chanson Francaise', | ||||||
|     'chanson anglaise': 'chanson anglaise', |     'francaise': 'Chanson Francaise', | ||||||
|     'musique de film': 'musique de film', |     'chanson anglaise': 'Chanson anglaise', | ||||||
|     'électro': 'electro', |     'reggae': 'Reggae', | ||||||
|     'musique électronique': 'electro', |     'folk': 'Folk', | ||||||
|     'rock': 'rock', |     'électro': 'Electro', | ||||||
|     'pop': 'pop', |     'musique électronique': 'Electro', | ||||||
|     'chanson latine': 'chanson latine', |     'punk': 'Punk', | ||||||
|  |     'rock': 'Rock', | ||||||
|  |     'pop': 'Pop', | ||||||
|  |     'latine': 'Latin', | ||||||
|  |     'arabe': 'Arabic', | ||||||
|  |     'corse': 'Chants Corse', | ||||||
|  |     'persane': 'Chanson Persane', | ||||||
|  |     'piano': 'Piano', | ||||||
|  |     'rap': 'Rap', | ||||||
|  |     'slam': 'Slam', | ||||||
|  |     'synthpop': 'Synthpop', | ||||||
|  |     'jazz classique': 'Classique Jazz', | ||||||
|  |     'jazz manouche': 'Jazz Manouche', | ||||||
|  |     'blues': 'Blues', | ||||||
|  |     'film': 'Soundtrack', | ||||||
|  |     'musique de film': 'Soundtrack', | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -68,6 +68,9 @@ class Ratatouille(): | ||||||
|             return self.light_on_single(payload['intentArg'][0]) |             return self.light_on_single(payload['intentArg'][0]) | ||||||
|         elif command == "LightOff": |         elif command == "LightOff": | ||||||
|             return self.light_off_single(payload['intentArg'][0]) |             return self.light_off_single(payload['intentArg'][0]) | ||||||
|  |         elif command == "PlayMusicGenre": | ||||||
|  |             return self.play_genre(payload['intentArg'][0]) | ||||||
|  |         return '42' | ||||||
| 
 | 
 | ||||||
|     def weather_query(self, entities): |     def weather_query(self, entities): | ||||||
|         if any(a in entities['B-weather_descriptor'] for a in TEMPERATURE_KEYWORD): |         if any(a in entities['B-weather_descriptor'] for a in TEMPERATURE_KEYWORD): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue