OVOS skills ship plain-text resource files — sentence templates, vocabularies,
spoken-response phrases — grouped by language under a locale/ folder. Several
OVOS components each grew their own code to parse and expand those files, and
the copies drifted: the same template could expand differently depending on
which copy ran.
ovos-spec-tools is the one conformant implementation of that machinery,
matching the formal specifications. Depend on it instead of rolling your own.
pip install ovos-spec-tools # core — no dependencies
pip install ovos-spec-tools[langcodes] # adds the smart language fallbackThe core package has no dependencies. The optional langcodes extra
improves only one thing — how a missing language falls back to a near one
(see Language matching); everything else works without
it.
Requires Python 3.8 or newer.
Every tool is one import away. The four snippets below are the whole package in miniature; the later chapters go deep on each.
A template describes many sentences at once. expand() enumerates them:
from ovos_spec_tools import expand
expand("(turn|switch) [the] (light|fan)")
# ['turn the light', 'switch the light', 'turn light', 'switch light',
# 'turn the fan', 'switch the fan', 'turn fan', 'switch fan']LocaleResources reads the resource files under locale/<lang>/:
from ovos_spec_tools import LocaleResources
res = LocaleResources("my-skill/locale")
res.load_intent("play", "en-US") # the expanded training samples
res.load_dialog("weather", "en-US") # the spoken-response phrasesrender() picks one phrase from a .dialog and fills its slots:
from ovos_spec_tools import render
render(res.load_dialog("weather", "en-US"), slots={"temperature": 21})
# 'It is 21 degrees.'→ Dialog
closest_lang() finds the nearest available language:
from ovos_spec_tools import closest_lang
closest_lang("en-AU", ["pt-BR", "en-US", "de-DE"]) # 'en-US'Message is the JSON envelope OVOS components exchange:
from ovos_spec_tools import Message
m = Message("ovos.intent.list", {}, {"source": "skill.id"})
res = m.response({"intents": ["..."]}) # 'ovos.intent.list.response'From the command line:
ovos-spec-lint my-skill/locale→ Linting
Continue with Sentence templates — the grammar is the foundation the resource loader and the dialog renderer both build on.