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

ocp pipeline #396

Merged
merged 1 commit into from
Feb 2, 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
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
max-parallel: 3
matrix:
python-version: [ 3.7, 3.8, 3.9]
python-version: [ 3.8, 3.9]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand Down
10 changes: 10 additions & 0 deletions mycroft/deprecated/audio/services/simple/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ def _stop_running_process(self):
self.process.kill()
self.process = None

# mandatory abstract methods
def get_track_length(self) -> int:
return 0

def get_track_position(self) -> int:
return 0

def set_track_position(self, milliseconds):
pass


def load_service(base_config, bus):
backends = base_config.get('backends', [])
Expand Down
34 changes: 25 additions & 9 deletions ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,33 @@
#
from collections import namedtuple

from ovos_config.config import Configuration
from ovos_config.locale import setup_locale, get_valid_languages, get_full_lang_code

from ovos_bus_client.message import Message
from ovos_bus_client.session import SessionManager
from ovos_bus_client.util import get_message_lang
from ovos_config.config import Configuration
from ovos_config.locale import setup_locale, get_valid_languages, get_full_lang_code
from ovos_core.intent_services.adapt_service import AdaptService
from ovos_core.intent_services.commonqa_service import CommonQAService
from ovos_core.intent_services.converse_service import ConverseService
from ovos_core.intent_services.stop_service import StopService
from ovos_core.intent_services.fallback_service import FallbackService
from ovos_core.intent_services.padacioso_service import PadaciosoService
from ovos_core.intent_services.stop_service import StopService
from ovos_core.transformers import MetadataTransformersService, UtteranceTransformersService
from ovos_workshop.intents import open_intent_envelope
from ovos_utils.log import LOG, deprecated, log_deprecation
from ovos_bus_client.util import get_message_lang
from ovos_utils.metrics import Stopwatch
from ovos_workshop.intents import open_intent_envelope

try:
from ovos_core.intent_services.padatious_service import PadatiousService, PadatiousMatcher
except ImportError:
from ovos_core.intent_services.padacioso_service import PadaciosoService as PadatiousService

try:
from ovos_core.intent_services.ocp_service import OCPPipelineMatcher
except ImportError:
LOG.warning("OCPPipelineMatcher unavailable, please install ovos-utils >= 0.1.0")
OCPPipelineMatcher = None

# Intent match response tuple containing
# intent_service: Name of the service that matched the intent
# intent_type: intent name (used to call intent handler over the message bus)
Expand Down Expand Up @@ -73,6 +78,10 @@ def __init__(self, bus):
self.converse = ConverseService(bus)
self.common_qa = CommonQAService(bus)
self.stop = StopService(bus)
if OCPPipelineMatcher is not None:
self.ocp = OCPPipelineMatcher(bus)
else:
self.ocp = None
self.utterance_plugins = UtteranceTransformersService(bus, config=config)
self.metadata_plugins = MetadataTransformersService(bus, config=config)
# connection SessionManager to the bus,
Expand Down Expand Up @@ -210,7 +219,8 @@ def get_pipeline(self, skips=None, session=None):
# TODO - from plugins
if self.padatious_service is None:
if any("padatious" in p for p in session.pipeline):
LOG.warning("padatious is not available! using padacioso in it's place")
LOG.warning("padatious is not available! using padacioso in it's place, "
"intent matching will be extremely slow in comparison")
padatious_matcher = self.padacioso_service
else:
from ovos_core.intent_services.padatious_service import PadatiousMatcher
Expand All @@ -233,8 +243,14 @@ def get_pipeline(self, skips=None, session=None):
"padatious_low": padatious_matcher.match_low,
"padacioso_low": self.padacioso_service.match_low,
"adapt_low": self.adapt_service.match_low,
"fallback_low": self.fallback.low_prio
"fallback_low": self.fallback.low_prio,
"adapt": self.adapt_service.match_medium # DEPRECATED - compat only TODO remove before stable, was only in alphas
}
if self.ocp is not None:
matchers.update({
"ocp_high": self.ocp.match_high,
"ocp_medium": self.ocp.match_medium,
"ocp_fallback": self.ocp.match_fallback})
skips = skips or []
pipeline = [k for k in session.pipeline if k not in skips]
return [matchers[k] for k in pipeline]
Expand Down Expand Up @@ -291,7 +307,7 @@ def handle_utterance(self, message):

# Get utterance utterance_plugins additional context
message = self._handle_transformers(message)

if message.context.get("canceled"):
# TODO - play dedicated sound
LOG.info("utterance canceled, cancel_word:" + message.context.get("cancel_word"))
Expand Down
4 changes: 4 additions & 0 deletions ovos_core/intent_services/locale/en-us/Play.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
search
read
play
start
3 changes: 3 additions & 0 deletions ovos_core/intent_services/locale/en-us/Resume.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

resume
unpause
5 changes: 5 additions & 0 deletions ovos_core/intent_services/locale/en-us/audio_only.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
audio only
no video
only audio
only sound
sound only
3 changes: 3 additions & 0 deletions ovos_core/intent_services/locale/en-us/cant.play.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

I'm not sure how to play {{phrase}}
Sorry, I don't know how to play {{phrase}}
2 changes: 2 additions & 0 deletions ovos_core/intent_services/locale/en-us/featured.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(open|show|display) (featured|) {media} (catalog|collection|playlist)
(open|show|display) featured {media}
3 changes: 3 additions & 0 deletions ovos_core/intent_services/locale/en-us/just.one.moment.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Give me a moment
Just a second
Just one moment while I look for that
4 changes: 4 additions & 0 deletions ovos_core/intent_services/locale/en-us/like_song.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
i like (that|this|it)
i like (that|this)(song|music|track|jam|sound)
(good|nice|great|amazing|awesome|cool) (song|music|track|jam|sound)
(that|this|it) is a (good|nice|great|amazing|awesome|cool) (song|music|track|jam|sound)
3 changes: 3 additions & 0 deletions ovos_core/intent_services/locale/en-us/media_stop.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stop
stop (playback|media|media playback|music|movie|movies|noise)
stop everything
6 changes: 6 additions & 0 deletions ovos_core/intent_services/locale/en-us/next.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(next|skip)
(next|skip) (music|song|track|video|media)
(play|go to) next (music|song|track|video|media)
play next
next
next (song|track|music|movie|video|tune)
4 changes: 4 additions & 0 deletions ovos_core/intent_services/locale/en-us/open.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
open (OCP|O C P|common|ovos|open voice os) (player|media player)
open (OCP|O C P|ovos common play|common play|ovos media player|open voice os player) (home screen|home page|homescreen|homepage|menu)
open (OCP|O C P|ovos common play|open voice os common play|common play)
open (media|music|gui|video) (player|catalog|skills|menu|playback)
2 changes: 2 additions & 0 deletions ovos_core/intent_services/locale/en-us/pause.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pause
pause (music|song|track|video|media|playback)
5 changes: 5 additions & 0 deletions ovos_core/intent_services/locale/en-us/play.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(play|start) {{query}}
search (common play|ocp|ovos common play|O C P) for {{query}}
search (ovos|open voice os) media for {{query}}
search {{query}} (in|on) (common play|ocp|ovos common play|O C P)
search {{query}} (in|on) (ovos|open voice os) media
2 changes: 2 additions & 0 deletions ovos_core/intent_services/locale/en-us/play.what.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

What should i play next?
2 changes: 2 additions & 0 deletions ovos_core/intent_services/locale/en-us/play_favorites.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(play|start) my (favorite|liked) (tracks|song|songs|music|jam|jams)
(play|start) (favorite|liked) (tracks|song|songs|music|jam|jams)
5 changes: 5 additions & 0 deletions ovos_core/intent_services/locale/en-us/prev.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(play previous|go back one) (music|song|track|video|media)
(play previous|previous) (music|song|track|video|media)
(play previous|previous|go back)
previous
previous (song|track|music|movie|video|tune)
3 changes: 3 additions & 0 deletions ovos_core/intent_services/locale/en-us/read.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
read (book|audiobook|audio book) {{query}}
read {{query}}
read {{query}} (book|audiobook|audio book)
3 changes: 3 additions & 0 deletions ovos_core/intent_services/locale/en-us/resume.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(unpause|resume)
(unpause|resume|continue|restart) (music|song|track|video|media|playback)
play
5 changes: 5 additions & 0 deletions ovos_core/intent_services/locale/en-us/video_only.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
do not cast to audio
don't cast to audio
no audio player
only video
video only
38 changes: 38 additions & 0 deletions ovos_core/intent_services/models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Binary Classifier

labels: OCP, other

| pipeline | language | accuracy | params | size (MB) |
|----------------------------|----------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| binary_ocp_cv2_kw_medium * | en | 0.9931496867494176 | {'penalty': None, 'l1_ratio': 0.15, 'early_stopping': False, 'alpha': 0.07} | 0.01 |
| binary_ocp_cv2_small | en | 0.9888979130544839 | {'penalty': None, 'l1_ratio': 0.9, 'early_stopping': False, 'alpha': 0.005} | 2.166 |
| binary_ocp_kw_small | all | 0.9326234280627232 | {'solver': 'adam', 'learning_rate': 'invscaling', 'hidden_layer_sizes': (120, 20, 80), 'early_stopping': True, 'alpha': 0.006, 'activation': 'tanh'} | 2.373 |
| binary_ocp_kw_tiny | all | 0.8919135638508334 | {'penalty': None, 'l1_ratio': 0.7, 'early_stopping': True, 'alpha': 0.02} | 0.01 |

`*` requires `binary_ocp_cv2_small`

# Playback Classifier

labels: audio, video, external

| pipeline | language | accuracy | params | size (MB) |
|------------------------------|----------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| playback_ocp_cv2_kw_medium * | en | 0.9491247659281933 | {'penalty': None, 'l1_ratio': 0.5, 'early_stopping': False, 'alpha': 0.07} | 0.021 |
| playback_ocp_kw_small | all | 0.9017183438359262 | {'solver': 'adam', 'learning_rate': 'invscaling', 'hidden_layer_sizes': (114, 101, 36), 'early_stopping': False, 'alpha': 0.0485, 'activation': 'tanh'} | 3.904 |
| playback_ocp_kw_tiny | all | 0.8325265234776467 | {'penalty': None, 'l1_ratio': 0.9, 'early_stopping': False, 'alpha': 0.0001} | 0.021 |

`*` requires `playback_ocp_cv2_small`

# Media Classifier

labels: movie, music, audiobook, podcast ....

| pipeline | language | accuracy | params | size (MB) |
|---------------------------|----------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| media_ocp_cv2_kw_medium * | en | 0.9054523222627585 | {'penalty': None, 'l1_ratio': 0.3, 'early_stopping': False, 'alpha': 0.05} | 0.186 |
| media_ocp_cv2_medium | en | 0.8683117027695156 | {'penalty': None, 'l1_ratio': 0.5, 'early_stopping': False, 'alpha': 0.01} | 54.841 |
| media_ocp_kw_small | all | 0.8558702042868357 | {'solver': 'adam', 'learning_rate': 'constant', 'hidden_layer_sizes': (63, 38), 'early_stopping': False, 'alpha': 0.006, 'activation': 'relu'} | 1.468 |
| media_ocp_kw_tiny | all | 0.8136730385986041 | {'penalty': None, 'l1_ratio': 0.5, 'early_stopping': False, 'alpha': 0.005} | 0.154 |

`*` requires `media_ocp_cv2_medium`

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading