"""
A simple module for playing music
Usage Examples:
- "Play some music"
- "Turn up!"
"""
from athena.classes.module import Module
from athena.classes.task import ActiveTask
from athena.tts import play_mp3
MOD_PARAMS = {
'name': 'music',
'priority': 2,
}
# Checks 'media' folder by default
TURN_UP_SONG = 'godj.mp3'
[docs]class PlaySongTask(ActiveTask):
def __init__(self):
super().__init__(patterns=[r'.*\b(get turnt|turn up|play.*music)\b.*'])
[docs] def match(self, text):
return self.match_any(text)
[docs] def action(self, text):
self.speak('Turning up...')
play_mp3(TURN_UP_SONG)
[docs]class Music(Module):
def __init__(self):
tasks = [PlaySongTask()]
super().__init__(MOD_PARAMS, tasks)