Skip to main content

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 extractioncolor_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 naminglookup_name(color, lang) returns the name of a known color.
  • Color modelssRGBAColor, HLSColor, HSVColor and SpectralColor (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-GBen-US). The per-language feature matrix is in docs/languages.md.

Documentation

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ovos_color_parser-0.4.0a2.tar.gz (781.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ovos_color_parser-0.4.0a2-py3-none-any.whl (837.3 kB view details)

Uploaded Python 3

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

Hashes for ovos_color_parser-0.4.0a2.tar.gz
Algorithm Hash digest
SHA256 c23a84d7ff2b30986b3f4b1a92854294f61e043cbb29f4cf352ecc4fbb33a94e
MD5 c6667160932e564f4e27d18076f9fcd4
BLAKE2b-256 c9af1998e1ca7e3106adc363e580e2fb785d696848885fd190478a92ffd8b2ec

See more details on using hashes here.

File details

Details for the file ovos_color_parser-0.4.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for ovos_color_parser-0.4.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b4534e9adbd25a87c9d63c11c91a76874ae199a5a77922b932a53ee9b65cec9
MD5 8098d2b021b8937066090198d46fd4a2
BLAKE2b-256 037473e77431c0a0a2afd77424129aaaef70b951d4989b6add71bd7fe0b8e4af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page