Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OVOS Color Parser

Turn natural-language color descriptions into color objects, and color objects back into names, in 45 languages. It is pure Python, needs no network access and no ML model. It uses bundled wordlists and color math.

from ovos_color_parser import color_from_description

c = color_from_description("dark red", lang="en")
print(c.hex_str)   # "#400E10"
print(c.as_hls)    # HLSColor(h=357.59..., l=0.152..., s=0.641..., ...)

It ships as part of the OpenVoiceOS voice stack, but it is a standalone library first: nothing here imports OVOS. It is equally useful for NER over free text, describing colors for text-to-speech, and mapping color descriptions to hex for UI theming or LED control.

Installation

pip install ovos-color-parser
# or, with uv:
uv pip install ovos-color-parser

rapidfuzz is a required dependency: fuzzy color-description matching relies on it for speed, and installing without it makes matching orders of magnitude slower.

30-second quickstart

from ovos_color_parser import color_from_description, lookup_name, sRGBAColor

# text -> color
c = color_from_description("warm mustard yellow", lang="en")
print(c.hex_str, (c.r, c.g, c.b))     # #FFDA3E (255, 218, 62)

# color -> text (any supported language)
print(lookup_name(sRGBAColor.from_hex_str("#1E90FF"), lang="pt"))  # "Azul furtivo"

# nothing matches -> None
print(color_from_description("qzxwv", lang="en"))  # None

Features

  • Color extraction: color_from_description("light blue", lang="fr") matches bundled color wordlists (web colors, xkcd survey, crayola, RAL, Pantone, ISCC-NBS, traditional Japanese colors, ...) and object colors ("carrot", "banana"), then applies modifiers such as light/dark, vivid/muted, warm/cool and transparent/opaque. Names are matched on word boundaries and weighted by specificity, so "moss green" outweighs a bare "green" and "green" is never matched inside "evergreen".

  • Color naming and namespaces: lookup_name(color, lang) returns a color's name. Every wordlist is an addressable namespace. Ask for the name in a specific palette (namespace="RAL_classic"), or fall back to the perceptually nearest named color (nearest=True).

  • Color models: sRGBAColor, HLSColor, HSVColor and SpectralColor (wavelength) dataclasses with conversions, stable hex round-trips and validation. SpectralColor.is_visible separates real colors from infrared, ultraviolet and beyond.

  • Gamut handling: choose how a computed color that leaves the sRGB gamut is resolved. Clamp each channel, map towards grey while preserving hue, or reject it (gamut=GamutPolicy.MAP).

  • Utilities: perceptual color distance (CIEDE2000), linear-light color averaging, Kelvin color temperature to RGB, CMYK conversion, contrasting black/white text color and hex validation.

Use it anywhere

Every snippet below is plain Python. Run pip install ovos-color-parser, then run it. Each has a matching runnable script in examples/.

Extract colors from free text (NER)

Pull color references out of a sentence and resolve each to a structured color, with no ML model and no network access. This is useful for tagging product copy, design briefs or support tickets.

from ovos_color_parser import color_from_description

text = "Paint the fence dark forest green and the door navy blue"
for phrase in ("dark forest green", "navy blue"):
    c = color_from_description(phrase, lang="en", fuzzy=False)
    print(phrase, "->", c.hex_str)   # dark forest green -> #162914 ; navy blue -> #0F43BE

Full sliding-window extractor with span offsets: examples/ner_colors.py.

Describe a color out loud (TTS-adjacent)

Go the other way. A raw RGB/hex value from a color picker, sensor or smart bulb becomes a speakable name.

from ovos_color_parser import sRGBAColor, lookup_name

c = sRGBAColor.from_hex_str("#2E8B57")
print(f"The color is {lookup_name(c, lang='en').lower()}.")   # "The color is sea green."

See examples/describe_rgb.py.

Map descriptions to hex for UI, theming and LEDs

from ovos_color_parser import color_from_description

theme = {var: color_from_description(desc, lang="en").hex_str.lower()
         for var, desc in {"--accent": "vivid teal", "--bg": "very dark blue"}.items()}
print(theme)   # {'--accent': '#38bfc4', '--bg': '#121a34'}

CSS variables, NeoPixel/WLED tuples and Kelvin white-balance in examples/ui_theming.py.

In an OVOS skill vs. standalone

The same call powers a voice intent and a plain script. Only the surrounding code differs:

# standalone color utility
from ovos_color_parser import color_from_description
hex_str = color_from_description("moss green", lang="en").hex_str

# inside an OVOS skill handler
def handle_set_color(self, message):
    utterance = message.data["utterance"]
    color = color_from_description(utterance, lang=self.lang)
    if color:
        self.set_lamp(color.hex_str)

Supported languages

45 locales: Aragonese, Arabic, Asturian, Azerbaijani, Basque, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, Galician, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Italian, Japanese, Kabyle, Korean, Malay, Mirandese, Norwegian Bokmål, Norwegian Nynorsk, Occitan, Persian, Polish, Portuguese, Romanian, Russian, Slovak, Slovenian, Spanish, Swedish, Turkish, Ukrainian, Vietnamese and West Frisian. Any BCP-47 tag resolves to the closest bundled locale, for example en-GB resolves to en-US. The per-language feature matrix, with entry counts and modifier and object support, is in docs/languages.md.

Documentation

Runnable examples

Usage notes

Color names are ambiguous. The same name can map to several hex values across wordlists. When several entries match, the parser blends them in linear light, weighted by match specificity. To force a known, named color from the matched candidates instead:

color = color_from_description("red", lang="en", cast_to_palette=True)
print(color.name)  # a named wordlist color, e.g. "Dusty Red"

When nothing matches, color_from_description returns None.

Descriptions of impossible colors ("reddish green") still produce an output. The parser blends whatever it matches, and the result may not be meaningful.

Runnable scripts live in examples/ and the full API reference in docs/api.md.

Credits

Color wordlists include data derived from the xkcd color survey, crayola, RAL, Pantone, ISCC-NBS, traditional Japanese colors and Wikipedia color lists. Spectral color terms follow Wikipedia's spectral color tables.

Metadata

Release files for ovos-color-parser 0.12.7a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ovos-color-parser 0.12.7a1
File Size Uploaded Provenance Actions
ovos_color_parser-0.12.7a1.tar.gz 857.4 kB Without provenance Details for ovos_color_parser-0.12.7a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ovos-color-parser 0.12.7a1
File Interpreter ABI Platform Actions
ovos_color_parser-0.12.7a1-py3-none-any.whl Python 3 none any Details for ovos_color_parser-0.12.7a1-py3-none-any.whl

Total release size: 1.8 MB

Release files / ovos_color_parser-0.12.7a1.tar.gz

Download URL ovos_color_parser-0.12.7a1.tar.gz
Size 857.4 kB
Tags Source
SHA-256 checksum
How to use checksums
23426a8a8cb09fa46f8eca755606a162b3faf90781a23882ad4f36c787629529
BLAKE2b-256 checksum
How to use checksums
bd5abbc7be228fc7ecc00998f2f22121d2c3b7ef2b1039941b2a621941a8aa07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ovos_color_parser-0.12.7a1-py3-none-any.whl

Download URL ovos_color_parser-0.12.7a1-py3-none-any.whl
Size 902.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b9af29f1bb165d74ba9284060efc0a634399a97fed0ae134c0538cdfccc13e6
BLAKE2b-256 checksum
How to use checksums
95bc75d22ce739ab95a2ecbd30b3eea9dc143d9dbeac50f3ac8e363c079d0e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ovos-color-parser 0.12.7a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page