Skip to content

Commit

Permalink
feat/play_audio
Browse files Browse the repository at this point in the history
companion PR for OpenVoiceOS/ovos-core#180
  • Loading branch information
JarbasAl committed Jul 28, 2022
1 parent dedfded commit 0b69e46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ovos_workshop/skills/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try:
from ovos_workshop.skills.ovos import MycroftSkill, OVOSSkill, OVOSFallbackSkill
from ovos_workshop.skills.ovos import MycroftSkill, OVOSSkill, OVOSFallbackSkill
from ovos_workshop.skills.idle_display_skill import IdleDisplaySkill
except ImportError:
pass
Expand Down
15 changes: 13 additions & 2 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ensure mycroft can be imported
from ovos_utils import ensure_mycroft_import
from ovos_utils.log import LOG
from ovos_utils.messagebus import Message
from ovos_utils.messagebus import Message, dig_for_message, get_message_lang
from ovos_utils.skills.settings import PrivateSettings

ensure_mycroft_import()
Expand All @@ -13,11 +13,11 @@
from mycroft.skills.mycroft_skill.event_container import create_wrapper
from ovos_utils.skills import get_non_properties
from ovos_utils.intents import IntentBuilder, Intent, AdaptIntent
from ovos_utils.sound import play_audio
from ovos_workshop.patches.base_skill import MycroftSkill, FallbackSkill
from ovos_workshop.decorators.killable import killable_event, \
AbortEvent, AbortQuestion
from ovos_workshop.skills.layers import IntentLayers
from ovos_utils.messagebus import dig_for_message, get_message_lang


class OVOSSkill(MycroftSkill):
Expand All @@ -43,6 +43,17 @@ def bind(self, bus):
self.private_settings = PrivateSettings(self.skill_id)
self.intent_layers.bind(self)

def play_audio(self, filename):
try:
from mycroft.version import OVOS_VERSION_BUILD, OVOS_VERSION_MINOR
if OVOS_VERSION_MINOR > 0 or OVOS_VERSION_BUILD >= 4:
self.bus.emit(Message("mycroft.audio.queue",
{"filename": filename}))
except:
pass
LOG.warning("self.play_audio requires ovos-core >= 0.0.4a44, falling back to local skill playback")
play_audio(filename).wait()

# lang support
@property
def lang(self):
Expand Down

0 comments on commit 0b69e46

Please sign in to comment.