Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/play_audio #23

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be >=1 to match the other checks

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