Added spotify skill (not really working atm... issue with regexs)

This commit is contained in:
Mathieu B 2021-07-29 12:35:07 +02:00
parent a3e1da051b
commit 837b87a41d
10 changed files with 46 additions and 9 deletions

View File

@ -3,8 +3,7 @@ from flask import Flask, request, jsonify, Response
from jarvis.ia import process
from jarvis.skills import intent_manager
from jarvis.skills.entertainement.jokes import JokesSkill
from jarvis.skills.research.wikipedia import WikipediaSkill
from jarvis.skills.entertainement.spotify import SpotifySkill
from utils import config_utils, flask_utils, intents_utils, utils
app = Flask(__name__)
@ -36,13 +35,17 @@ def process_request():
if __name__ == '__main__':
# Tests
WikipediaSkill().register()
JokesSkill().register()
# WikipediaSkill().register()
# JokesSkill().register()
SpotifySkill().register()
intent_manager.process_handlers()
intent_manager.recognise("cherche sur wikipedia Elon Musk")
intent_manager.recognise("raconte moi une blague")
# intent_manager.recognise("cherche sur wikipedia Elon Musk")
# intent_manager.recognise("raconte moi une blague")
intent_manager.recognise("joue le morceau crazy crazy nights de KISS sur spotify")
intent_manager.recognise("joue le morceau crazy crazy nights de KISS sur spotify")
intent_manager.recognise("joue crazy crazy nights")
# start the flask server
app.config['JSON_AS_ASCII'] = False

View File

@ -0,0 +1,17 @@
from adapt.intent import IntentBuilder
from jarvis.skills import Skill, SkillRegistering
from jarvis.skills.decorators import intent_handler
class SpotifySkill(Skill, metaclass=SkillRegistering):
def __init__(self):
super().__init__("SpotifySkill")
@intent_handler(IntentBuilder("PlaySongOnlyTitle").require("Play").optionally("Spotify").optionally("SongNameOnly"))
def handle_play_song_only_title(self, data):
print("")
@intent_handler(IntentBuilder("PlaySongTitleAndSinger").require("Play").optionally("Spotify").require("From").optionally("SongName").optionally("Singer"))
def handle_play_song_title_and_singer(self, data):
print("")

View File

@ -0,0 +1 @@
.*(?:joue|mets|mets|fait moi écouter|moi|écouter) (?:le morceau|la chanson|voir|) ?(?P<SongNameOnly>.+?(?= sur|$)())

View File

@ -0,0 +1 @@
(?:joue|mets|mets|fait moi écouter|moi|écouter) (?:le morceau|la chanson|voir|) ?(?P<SongName>.+) (?:de) (?P<Singer>.+?(?= sur|$))

View File

@ -0,0 +1,3 @@
de
du groupe
d'

View File

@ -0,0 +1,6 @@
joue
mets
mets
fait moi écouter
écouter
joue le morceau

View File

@ -0,0 +1,3 @@
Spotify
spotify
spot

View File

@ -38,7 +38,10 @@ def handle(intent_name):
def recognise(sentence):
for intents in engine.determine_intent(sentence):
json_response = json.loads(json.dumps(intents))
sentence = sentence.lower()
print(sentence)
handle(json_response['intent_type'])
best_intents = engine.determine_intent(sentence, 100)
best_intent = next(best_intents)
print(best_intent)