diff --git a/ovos_audio/audio.py b/ovos_audio/audio.py index 86927e2..7fec871 100644 --- a/ovos_audio/audio.py +++ b/ovos_audio/audio.py @@ -385,6 +385,17 @@ def restore_volume(msg=message): else: LOG.debug("No audio service to restore volume of") + def _extract(self, tracks: List[Union[str, Tuple[str,str]]]) -> List[str]: + """convert uris into real streams that can be played, eg. handle youtube urls""" + xtracted = [] + xtract = load_stream_extractors() # @lru_cache, its a lazy loaded singleton + for t in tracks: + if isinstance(t, str): + xtracted.append(xtract.extract_stream(t, video=False)) + else: # (uri, mime) + xtracted.append(xtract.extract_stream(t[0], video=False)) + return xtracted + def play(self, tracks, prefered_service, repeat=False): """ play starts playing the audio on the prefered service if it @@ -405,6 +416,8 @@ def play(self, tracks, prefered_service, repeat=False): LOG.debug(f"track uri type: {uri_type}") + tracks = self._extract(tracks) # ensure playable streams + # check if user requested a particular service if prefered_service and uri_type in prefered_service.supported_uris(): selected_service = prefered_service diff --git a/requirements/extras.txt b/requirements/extras.txt index 4331a80..b9a7908 100644 --- a/requirements/extras.txt +++ b/requirements/extras.txt @@ -1,5 +1,9 @@ +# TTS Plugins ovos-tts-plugin-server>=0.0.2, <1.0.0 + +# Media Playback plugins ovos_audio_plugin_simple>=0.1.0, <1.0.0 +ovos-audio-plugin-mpv>=0.0.1, <1.0.0 ovos_plugin_common_play>=0.0.7, <1.0.0 # OCP plugins