From aa9979e5e0ff3da56465e29dcafff5d296e44e2d Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Fri, 30 Jul 2021 10:14:18 +0200 Subject: [PATCH] Added "what's the current song" for spotify skill --- jarvis/main.py | 1 + jarvis/skills/entertainement/spotify/__init__.py | 11 +++++++++++ .../dialog/fr-fr/playing_song_from_artist.dialog | 3 +++ .../spotify/vocab/fr-fr/current_song.intent | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_song_from_artist.dialog create mode 100644 jarvis/skills/entertainement/spotify/vocab/fr-fr/current_song.intent diff --git a/jarvis/main.py b/jarvis/main.py index d2e0869..e00b07c 100644 --- a/jarvis/main.py +++ b/jarvis/main.py @@ -51,6 +51,7 @@ if __name__ == '__main__': # intent_manager.recognise("raconte moi une blague") # WORKING # intent_manager.recognise("joue le morceau crazy crazy nights de KISS sur spotify") # WORKING # intent_manager.recognise("coupe la musique") # WORKING + intent_manager.recognise("c'est quoi le nom de cette chanson ?") # start the flask server app.config['JSON_AS_ASCII'] = False diff --git a/jarvis/skills/entertainement/spotify/__init__.py b/jarvis/skills/entertainement/spotify/__init__.py index b230913..17cd3c0 100644 --- a/jarvis/skills/entertainement/spotify/__init__.py +++ b/jarvis/skills/entertainement/spotify/__init__.py @@ -27,3 +27,14 @@ class SpotifySkill(Skill, metaclass=SkillRegistering): def pause_music(self, data): spotify.get_spotify().pause_playback() print("[INFO INTENT] - Paused music for Spotify") + + @intent_file_handler("current_song.intent", "CurrentSongSpotifyIntent") + def current_song(self, data): + current_playback = spotify.get_spotify().current_playback() + if current_playback['is_playing']: + song_name = current_playback['item']['name'] + artist = current_playback['item']['artists'][0]['name'] + + print(song_name + " from " + artist ) + + print("[INFO INTENT] - Current playback : music for Spotify") diff --git a/jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_song_from_artist.dialog b/jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_song_from_artist.dialog new file mode 100644 index 0000000..3ec8830 --- /dev/null +++ b/jarvis/skills/entertainement/spotify/dialog/fr-fr/playing_song_from_artist.dialog @@ -0,0 +1,3 @@ +{{song}} de {{artist}} +Ce morceau s'appele {{song}} il est chanté par {{artist}} +{{song}} chanté par {{artist}} \ No newline at end of file diff --git a/jarvis/skills/entertainement/spotify/vocab/fr-fr/current_song.intent b/jarvis/skills/entertainement/spotify/vocab/fr-fr/current_song.intent new file mode 100644 index 0000000..800d98d --- /dev/null +++ b/jarvis/skills/entertainement/spotify/vocab/fr-fr/current_song.intent @@ -0,0 +1,5 @@ +C'est quoi le nom du morceau actuel +On écoute quoi la +C'est quoi le titre de la chanson actuelle +C'est quoi cette chanson +C'est quoi cette musique \ No newline at end of file