Added all dialogs for spotify skill
This commit is contained in:
parent
2f2069696a
commit
a6e749ce5a
@ -24,7 +24,10 @@ class Skill:
|
|||||||
def speak(self, sentence):
|
def speak(self, sentence):
|
||||||
client_utils.speak(sentence, self.client_ip, self.client_port)
|
client_utils.speak(sentence, self.client_ip, self.client_port)
|
||||||
|
|
||||||
def speak_dialog(self, dialog, data):
|
def speak_dialog(self, dialog, data=None):
|
||||||
|
if data is None:
|
||||||
|
data = {}
|
||||||
|
|
||||||
file = self.path + "/dialog/" + languages_utils.get_language() + "/" + dialog + ".dialog"
|
file = self.path + "/dialog/" + languages_utils.get_language() + "/" + dialog + ".dialog"
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
with open(file, "r") as infile:
|
with open(file, "r") as infile:
|
||||||
|
@ -16,34 +16,31 @@ class SpotifySkill(Skill, metaclass=SkillRegistering):
|
|||||||
|
|
||||||
if song_lists_matching is not None and len(song_lists_matching) >= 1:
|
if song_lists_matching is not None and len(song_lists_matching) >= 1:
|
||||||
if 'artist' in data and 'song' not in data:
|
if 'artist' in data and 'song' not in data:
|
||||||
self.speak_dialog("playing_from_artist", {'artist': song_lists_matching[0]['artists'][0]['name']})
|
self.speak_dialog("play_from_artist", {'artist': song_lists_matching[0]['artists'][0]['name']})
|
||||||
else:
|
else:
|
||||||
self.speak_dialog("playing_song_from_artist", {'song': song_lists_matching[0][
|
self.speak_dialog("play_song_from_artist", {'song': song_lists_matching[0][
|
||||||
'name'], 'artist': song_lists_matching[0]['artists'][0]['name']})
|
'name'], 'artist': song_lists_matching[0]['artists'][0]['name']})
|
||||||
|
|
||||||
spotify.get_spotify().add_to_queue(uri=song_lists_matching[0]['uri'])
|
spotify.get_spotify().add_to_queue(uri=song_lists_matching[0]['uri'])
|
||||||
spotify.get_spotify().next_track()
|
spotify.get_spotify().next_track()
|
||||||
else:
|
else:
|
||||||
print("Nothing found for :" + str(data))
|
self.speak_dialog("nothing_found")
|
||||||
|
|
||||||
@intent_file_handler("pause_music.intent", "PauseSpotifyIntent")
|
@intent_file_handler("pause_music.intent", "PauseSpotifyIntent")
|
||||||
def pause_music(self, data):
|
def pause_music(self, data):
|
||||||
if spotify.is_music_playing():
|
if spotify.is_music_playing():
|
||||||
spotify.get_spotify().pause_playback()
|
spotify.get_spotify().pause_playback()
|
||||||
print("[INFO INTENT] - Paused music for Spotify")
|
self.speak_dialog("pause_spotify")
|
||||||
else:
|
else:
|
||||||
self.speak("Rien n'est en cours de lecture sur Spotify...")
|
self.speak_dialog("nothing_playing")
|
||||||
# TODO: speak : nothing is playing on spotify
|
|
||||||
pass
|
|
||||||
|
|
||||||
@intent_file_handler("resume_music.intent", "ResumeSpotifyIntent")
|
@intent_file_handler("resume_music.intent", "ResumeSpotifyIntent")
|
||||||
def resume_music(self, data):
|
def resume_music(self, data):
|
||||||
if not spotify.is_music_playing():
|
if not spotify.is_music_playing():
|
||||||
|
self.speak_dialog("resume_music")
|
||||||
spotify.get_spotify().start_playback()
|
spotify.get_spotify().start_playback()
|
||||||
print("[INFO INTENT] - Resumed music for Spotify")
|
|
||||||
else:
|
else:
|
||||||
# TODO: speak : already playing song on spotify
|
self.speak_dialog("already_playing")
|
||||||
pass
|
|
||||||
|
|
||||||
@intent_file_handler("current_song.intent", "CurrentSongSpotifyIntent")
|
@intent_file_handler("current_song.intent", "CurrentSongSpotifyIntent")
|
||||||
def current_song(self, data):
|
def current_song(self, data):
|
||||||
@ -52,9 +49,9 @@ class SpotifySkill(Skill, metaclass=SkillRegistering):
|
|||||||
song_name = current_playback['item']['name']
|
song_name = current_playback['item']['name']
|
||||||
artist = current_playback['item']['artists'][0]['name']
|
artist = current_playback['item']['artists'][0]['name']
|
||||||
|
|
||||||
print("[INFO INTENT] - Current playback : " + song_name + " from " + artist + " on Spotify")
|
self.speak_dialog("current_playing_song_from_artist", {'song': song_name, 'artist': artist})
|
||||||
else:
|
else:
|
||||||
print("Nothing is playing")
|
self.speak_dialog('nothing_playing')
|
||||||
|
|
||||||
|
|
||||||
def create_skill(data):
|
def create_skill(data):
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
Spotify est déjà en cours de lecture
|
||||||
|
La musique est déjà en cours de lecture
|
@ -0,0 +1,3 @@
|
|||||||
|
Je n'ai pas trouvé ce morceau
|
||||||
|
Je suis désolé je n'ai pas trouvé cette chanson
|
||||||
|
Impossible de trouver ce morceau
|
@ -0,0 +1,5 @@
|
|||||||
|
Rien n'est en cours de lecture
|
||||||
|
Rien n'est en cours de lecture sur spotify
|
||||||
|
Aucun morceau n'est en cours de lecture
|
||||||
|
Spotify est déjà sur pause
|
||||||
|
Spotify est déjà à l'arrêt
|
@ -0,0 +1,2 @@
|
|||||||
|
Spotify à été mis en pause
|
||||||
|
J'ai mis spotify sur pause
|
@ -0,0 +1,4 @@
|
|||||||
|
{{song}} de {{artist}} sur spotify
|
||||||
|
C'est parti pour {{song}} de {{artist}} sur spotify
|
||||||
|
Voici {{song}} de {{artist}} sur spotify
|
||||||
|
{{song}} de {{artist}} c'est maintenant
|
@ -0,0 +1,4 @@
|
|||||||
|
Je remet la musique
|
||||||
|
La musique reprend
|
||||||
|
Spotify reprend
|
||||||
|
La musique redémarre
|
Reference in New Issue
Block a user