OpenVoiceOS's multilingual color parsing and formatting library
Project description
OVOS Color Parser
Parse natural-language color descriptions into color objects, and name colors, in 13 languages.
from ovos_color_parser import color_from_description
c = color_from_description("dark red", lang="en")
print(c.hex_str) # "#371013"
print(c.as_hls) # HLSColor(h=352, l=0.145..., s=0.522..., ...)
Designed for voice interfaces:
- "change the lamp color to moss green"
- "make it darker"
- "a warmer white"
Installation
pip install ovos-color-parser
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. - Color naming —
lookup_name(color, lang)returns the name of a known color. - Color models —
sRGBAColor,HLSColor,HSVColorandSpectralColor(wavelength) dataclasses with conversions, stable hex round-trips and validation. - Utilities — perceptual color distance (CIECAM02 deltaE), weighted color averaging with circular hue mean, Kelvin color temperature to RGB, CMYK conversion, contrasting black/white text color and hex validation.
Supported languages
Basque, Catalan, Czech, Danish, Dutch, English, French, German, Italian, Polish, Portuguese, Russian
and Spanish. Any BCP-47 tag resolves to the closest bundled locale (for example en-GB → en-US).
The per-language feature matrix is in docs/languages.md.
Documentation
- Usage guide — extraction, impossible colors, comparing colors
- Color description semantics — how hue, saturation, brightness, temperature and opacity keywords map to color math
- Color, language and color spaces — how languages carve up color space, and the color models used
- API reference
- Language support
Usage notes
Color names are ambiguous — the same name can map to several hex values across wordlists. When several entries match, the parser averages them, weighted by match confidence. 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. "Fire engine red"
When nothing matches, color_from_description returns None.
Descriptions of impossible colors ("reddish green") still produce an output — the parser averages whatever it matches, which may not be meaningful.
Runnable scripts live in examples/ and the full API reference in docs/api.md.
Related projects
- ovos-number-parser — numbers
- ovos-date-parser — dates and times
- ovos-lang-parser — languages
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ovos_color_parser-0.4.0a2.tar.gz.
File metadata
- Download URL: ovos_color_parser-0.4.0a2.tar.gz
- Upload date:
- Size: 781.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c23a84d7ff2b30986b3f4b1a92854294f61e043cbb29f4cf352ecc4fbb33a94e
|
|
| MD5 |
c6667160932e564f4e27d18076f9fcd4
|
|
| BLAKE2b-256 |
c9af1998e1ca7e3106adc363e580e2fb785d696848885fd190478a92ffd8b2ec
|
File details
Details for the file ovos_color_parser-0.4.0a2-py3-none-any.whl.
File metadata
- Download URL: ovos_color_parser-0.4.0a2-py3-none-any.whl
- Upload date:
- Size: 837.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b4534e9adbd25a87c9d63c11c91a76874ae199a5a77922b932a53ee9b65cec9
|
|
| MD5 |
8098d2b021b8937066090198d46fd4a2
|
|
| BLAKE2b-256 |
037473e77431c0a0a2afd77424129aaaef70b951d4989b6add71bd7fe0b8e4af
|