From a6e749ce5ab33b156831b688b728e3d75a3bba52 Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Sun, 1 Aug 2021 17:02:21 +0200 Subject: [PATCH] Added all dialogs for spotify skill --- jarvis/skills/__init__.py | 5 ++++- .../skills/entertainement/spotify/__init__.py | 21 ++++++++----------- .../dialog/fr-fr/already_playing.dialog | 2 ++ ...> current_playing_song_from_artist.dialog} | 0 .../spotify/dialog/fr-fr/nothing_found.dialog | 3 +++ .../dialog/fr-fr/nothing_playing.dialog | 5 +++++ .../spotify/dialog/fr-fr/pause_spotify.dialog | 2 ++ ..._artist.dialog => play_from_artist.dialog} | 0 .../dialog/fr-fr/play_song_from_artist.dialog | 4 ++++ .../spotify/dialog/fr-fr/resume_music.dialog | 4 ++++ 10 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/already_playing.dialog rename jarvis/skills/entertainement/spotify/dialog/fr-fr/{playing_song_from_artist.dialog => current_playing_song_from_artist.dialog} (100%) create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_found.dialog create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_playing.dialog create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/pause_spotify.dialog rename jarvis/skills/entertainement/spotify/dialog/fr-fr/{playing_from_artist.dialog => play_from_artist.dialog} (100%) create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/play_song_from_artist.dialog create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/resume_music.dialog diff --git a/jarvis/skills/__init__.py b/jarvis/skills/__init__.py index 12277f4..443a89b 100644 --- a/jarvis/skills/__init__.py +++ b/jarvis/skills/__init__.py @@ -24,7 +24,10 @@ class Skill: def speak(self, sentence): 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" if os.path.exists(file): with open(file, "r") as infile: diff --git a/jarvis/skills/entertainement/spotify/__init__.py b/jarvis/skills/entertainement/spotify/__init__.py index da1a4aa..7ee79e1 100644 --- a/jarvis/skills/entertainement/spotify/__init__.py +++ b/jarvis/skills/entertainement/spotify/__init__.py @@ -16,34 +16,31 @@ class SpotifySkill(Skill, metaclass=SkillRegistering): if song_lists_matching is not None and len(song_lists_matching) >= 1: 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: - 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']}) spotify.get_spotify().add_to_queue(uri=song_lists_matching[0]['uri']) spotify.get_spotify().next_track() else: - print("Nothing found for :" + str(data)) + self.speak_dialog("nothing_found") @intent_file_handler("pause_music.intent", "PauseSpotifyIntent") def pause_music(self, data): if spotify.is_music_playing(): spotify.get_spotify().pause_playback() - print("[INFO INTENT] - Paused music for Spotify") + self.speak_dialog("pause_spotify") else: - self.speak("Rien n'est en cours de lecture sur Spotify...") - # TODO: speak : nothing is playing on spotify - pass + self.speak_dialog("nothing_playing") @intent_file_handler("resume_music.intent", "ResumeSpotifyIntent") def resume_music(self, data): if not spotify.is_music_playing(): + self.speak_dialog("resume_music") spotify.get_spotify().start_playback() - print("[INFO INTENT] - Resumed music for Spotify") else: - # TODO: speak : already playing song on spotify - pass + self.speak_dialog("already_playing") @intent_file_handler("current_song.intent", "CurrentSongSpotifyIntent") def current_song(self, data): @@ -52,9 +49,9 @@ class SpotifySkill(Skill, metaclass=SkillRegistering): song_name = current_playback['item']['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: - print("Nothing is playing") + self.speak_dialog('nothing_playing') def create_skill(data): diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/already_playing.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/already_playing.dialog new file mode 100644 index 0000000..1cf2778 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/already_playing.dialog @@ -0,0 +1,2 @@ +Spotify est déjà en cours de lecture +La musique est déjà en cours de lecture \ No newline at end of file diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_song_from_artist.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/current_playing_song_from_artist.dialog similarity index 100% rename from jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_song_from_artist.dialog rename to jarvis/skills/entertainement/spotify/dialog/fr-fr/current_playing_song_from_artist.dialog diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_found.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_found.dialog new file mode 100644 index 0000000..8eef4a9 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_found.dialog @@ -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 diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_playing.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_playing.dialog new file mode 100644 index 0000000..0b0c679 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/nothing_playing.dialog @@ -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 \ No newline at end of file diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/pause_spotify.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/pause_spotify.dialog new file mode 100644 index 0000000..d32de95 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/pause_spotify.dialog @@ -0,0 +1,2 @@ +Spotify à été mis en pause +J'ai mis spotify sur pause \ No newline at end of file diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_from_artist.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/play_from_artist.dialog similarity index 100% rename from jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_from_artist.dialog rename to jarvis/skills/entertainement/spotify/dialog/fr-fr/play_from_artist.dialog diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/play_song_from_artist.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/play_song_from_artist.dialog new file mode 100644 index 0000000..c9e67a2 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/play_song_from_artist.dialog @@ -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 \ No newline at end of file diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/resume_music.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/resume_music.dialog new file mode 100644 index 0000000..4511187 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/resume_music.dialog @@ -0,0 +1,4 @@ +Je remet la musique +La musique reprend +Spotify reprend +La musique redémarre \ No newline at end of file