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

fix/legacy_play #514

Merged
merged 2 commits into from
Jun 21, 2024
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
31 changes: 19 additions & 12 deletions ovos_core/intent_services/ocp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ovos_bus_client.util import wait_for_reply
from ovos_classifiers.skovos.classifier import SklearnOVOSClassifier
from ovos_classifiers.skovos.features import ClassifierProbaVectorizer, KeywordFeaturesVectorizer
from ovos_plugin_manager.ocp import load_stream_extractors, available_extractors
from ovos_plugin_manager.ocp import available_extractors
from ovos_utils import classproperty
from ovos_utils.gui import is_gui_connected, is_gui_running
from ovos_utils.log import LOG
Expand All @@ -26,11 +26,11 @@

try:
from ovos_utils.ocp import MediaType, PlaybackType, PlaybackMode, PlayerState, OCP_ID, \
MediaEntry, Playlist, MediaState, TrackState, dict2entry
MediaEntry, Playlist, MediaState, TrackState, dict2entry, PluginStream
from ovos_bus_client.apis.ocp import OCPInterface, OCPQuery
except ImportError:
from ovos_workshop.backwards_compat import MediaType, PlaybackType, PlaybackMode, PlayerState, OCP_ID, \
MediaEntry, Playlist, MediaState, TrackState, dict2entry
MediaEntry, Playlist, MediaState, TrackState, dict2entry, PluginStream
from ovos_bus_client.apis.ocp import OCPInterface as _OIF, OCPQuery as _OQ


Expand Down Expand Up @@ -982,15 +982,22 @@ def select_best(self, results: list, message: Message) -> MediaEntry:
# Legacy Audio subsystem API
def legacy_play(self, results: List[MediaEntry], phrase="",
message: Optional[Message] = None):
xtract = load_stream_extractors()
# for legacy audio service we need to do stream extraction here
# we also need to filter video results
results = [xtract.extract_stream(r.uri, video=False)["uri"]
for r in results
if r.playback == PlaybackType.AUDIO
or r.media_type in OCPQuery.cast2audio]

self.legacy_api.play(results, utterance=phrase)
res = []
for r in results:
if not (r.playback == PlaybackType.AUDIO or r.media_type in OCPQuery.cast2audio):
# we need to filter video results
continue
if isinstance(r, Playlist):
# get internal entries from the playlist
for e in r.entries:
res.append(e.uri)
elif isinstance(r, MediaEntry):
res.append(r.uri)
elif isinstance(r, PluginStream):
# for legacy audio service we need to do stream extraction here
res.append(r.extract_uri(video=False))

self.legacy_api.play(res, utterance=phrase)

player = self.get_player(message)
player.player_state = PlayerState.PLAYING
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ovos-plugin-manager<0.1.0, >=0.0.25
ovos-config~=0.0,>=0.0.13a8
ovos-lingua-franca>=0.4.7
ovos-backend-client~=0.1.0
ovos-workshop>=0.0.16a39
ovos-workshop>=0.0.16a40
# provides plugins and classic machine learning framework
ovos-classifiers<0.1.0, >=0.0.0a53

Expand Down
Loading