Skip to content

Commit

Permalink
feat: singing skill port
Browse files Browse the repository at this point in the history
Closes #27
  • Loading branch information
mikejgray committed Jan 29, 2024
1 parent 615a77a commit ec2a6b8
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Some funny things for OpenVoiceOS, mostly quotes from movies
- "What would Arnold say?"
- "What would GLaDOS say?"
- "What would Bender say?"
- "What would Malibu Stacey say?"
- "You know the best band in the world? Wyld Stallions?"
- "Sing me a song"

## Grandma Mode

Expand All @@ -28,5 +31,5 @@ If you want to go back into grandma mode, say "I'm too young to die."

## Credits

JarbasAI
mikejgray (revival)
- JarbasAI
- mikejgray (revival)
31 changes: 31 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,33 @@ def handle_malibu_stacey_intent(self, _):
else:
self.speak_dialog("bad_file")

@intent_handler(IntentBuilder("sing_intent").require("sing_keyword").build())
def handle_sing_intent(self, _):
if not self._sounds_like_popey():
self.speak_dialog("too_shy")
return
self.speak_dialog("sing")
path, files = self.get_reference_files("sounds/sing", "mp3")
if len(files):
mp3 = path + "/" + random.choice(files)
self.play_audio(filename=mp3)
else:
self.speak_dialog("bad_file")

def _sounds_like_popey(self):
tts = self.config_core.get("tts")
if "mimic" in tts.get("module", "").lower():
return True
for k, v in tts.items():
if isinstance(v, dict):
if "alan" in v.get("voice", "") and tts.get("module", "") == k:
return True
if "ap" in v.get("voice", "") and tts.get("module", "") == k:
return True
if "alan" in v.get("model", "") and tts.get("module", "") == k:
return True
return False

@skill_api_method
def get_display_date(self):
return StarDate().getStardate()
Expand All @@ -198,3 +225,7 @@ def _play_in_ocp(self, media, title="Easter Egg!"):
"skill_id": self.skill_id,
}
self.ocp.play(tracks=[data])

if __name__ == "__main__":
from ovos_utils.fakebus import FakeBus
EasterEggsSkill(bus=FakeBus(), skill_id="skill_easter_eggs.test")
3 changes: 3 additions & 0 deletions locale/en-us/dialog/singing.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
I would be happy to sing for you.
Here I go.
I'm a bit nervous about my voice, but here goes nothing.
3 changes: 3 additions & 0 deletions locale/en-us/dialog/too_shy.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
I couldn't, I'm much too shy.
I'm feeling a little shy. I don't really have a deep enough voice for that.
I'd be too shy to try without a British accent.
2 changes: 2 additions & 0 deletions locale/en-us/vocab/sing_keyword.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sing
sing me a song
Binary file added sounds/sing/drnimpo-robots.mp3
Binary file not shown.
Binary file added sounds/sing/popey-favourite.mp3
Binary file not shown.
Binary file added sounds/sing/popey-jackson.mp3
Binary file not shown.
Binary file added sounds/sing/popey-jerusalem.mp3
Binary file not shown.
Binary file added sounds/sing/popey-lose-yourself.mp3
Binary file not shown.
Binary file added sounds/sing/popey-lovemetender.mp3
Binary file not shown.
Binary file added sounds/sing/popey-rocketman.mp3
Binary file not shown.
3 changes: 3 additions & 0 deletions test/test_intents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ en-us:
- what would malibu stacy do
- what wood malley boo stay see do
- what wood malla boo stay see do
singkeyword:
- sing
- sing me a song
de-de:
adultmodekeyeword:
- hurt me plenty
Expand Down
2 changes: 2 additions & 0 deletions test/test_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ vocab:
- conan_keyword
- bill_and_ted_keyword
- malibu_stacey_keyword
- sing_keyword

# dialog is .dialog file basenames (case-sensitive)
dialog:
Expand Down Expand Up @@ -62,3 +63,4 @@ intents:
- conan_intent
- bill_and_ted_intent
- malibu_stacey_intent
- sing_intent
37 changes: 37 additions & 0 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,43 @@ def test_handle_malibu_stacey_intent(self, test_skill, reset_skill_mocks):
assert "skill_easter_eggs/sounds/malibustacey/" in test_skill.play_audio.call_args.kwargs.get("filename", "")
assert test_skill.speak_dialog.called is False

def test_sounds_like_popey(self, test_skill):
config = {
"tts": {
"module": "neon-tts-plugin-coqui-remote",
"fallback_module": "coqui",
"ovos-tts-plugin-mimic": {
"voice": "ap"
},
"neon-tts-plugin-larynx-server": {
"host": "https://larynx.2022.us"
},
"mozilla_remote": {
"api_url": "https://mtts.2022.us/api/tts"
},
"ovos-tts-plugin-piper": {
"voice": "alan-low"
}
}
}
# Test if we don't sound like Popey at all
test_skill.config_core = config
assert test_skill._sounds_like_popey() is False
# Test if "alan" is the voice name
config["tts"]["module"] = "ovos-tts-plugin-piper"
test_skill.config_core = config
assert test_skill._sounds_like_popey() is True
# Test if "mimic" is in the module name
config["tts"]["module"] = "ovos-tts-plugin-mimic"
test_skill.config_core = config
assert test_skill._sounds_like_popey() is True

def test_handle_sing_intent(self, test_skill, reset_skill_mocks): # TODO: Expand
test_skill.handle_sing_intent(None)
test_skill.play_audio.assert_called_once()
assert "skill_easter_eggs/sounds/sing/" in test_skill.play_audio.call_args.kwargs.get("filename", "")
test_skill.speak_dialog.assert_called_once_with("sing")

def test_get_display_date(self, test_skill):
# TODO: Fully implement
assert True
Expand Down

0 comments on commit ec2a6b8

Please sign in to comment.