Skip to content

Commit

Permalink
feat/play_audio (#23)
Browse files Browse the repository at this point in the history
* feat/play_audio

companion PR for OpenVoiceOS/ovos-core#180

* version

* ovos-core >= 0.0.4a45

Co-authored-by: jarbasai <[email protected]>
  • Loading branch information
NeonJarbas and JarbasAl authored Jul 28, 2022
1 parent dedfded commit 576baed
Show file tree
Hide file tree
Showing 2 changed files with 16 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
17 changes: 15 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,19 @@ 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, OVOS_VERSION_MAJOR
if OVOS_VERSION_MAJOR >= 1 or \
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.4a45, falling back to local skill playback")
play_audio(filename).wait()

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

0 comments on commit 576baed

Please sign in to comment.