Skip to main content

A bijective 8-bit RGB encoding library that generates phonotactically plausible appellations.

Project description

Phonochrome

Phonochrome is a bijective 8-bit RGB encoding library that generates phonotactically plausible appellations. The library constructs a unique string for each of the 16.7 million possible 8-bit RGB tuple permutations ($256^3 = 16,777,216$).

Each RGB component is first converted to base 16, which allows us to derive values from a more compact set of characters, represented as $S$. Let $x^1$ and $x^2$ represent the two hexadecimal digits (since the range 0-255 only comprises up to FF). If a component is less than 16, its hexadecimal string will be zero-padded to a length of two. Each hexadecimal character is then reconverted into decimal to serve as an index. $x^1$ maps to $C \subsetneq S$, and $x^2$ maps to $V \subsetneq S$, where $C$ and $V$ are lists of consonants and vowels (or vowel-like phonetics), meticulously curated to ensure phonotactic plausibility. The order of these lists changes based on the index of the enumerated RGB tuple. This is done for each component before the generated parts are concatenated and returned as an appellation.

Example Usage

The library is extremely easy to use, and comes with two functions: encode and decode.

>>> import phonochrome

>>> black_rgb = (0, 0, 0) # define our RGB tuple
>>> phonochrome.encode(black_rgb) # encode the RGB into a phonochrome appellation
'bacedi'
>>> import phonochrome

>>> phonochrome.decode('bacedi') # encode the RGB into a phonochrome appellation
(0, 0, 0)

Command Line Interface

Phonochrome comes with a command line interface which is automatically added to your environment's scripts upon installation. You can invoke it like this:

$ phonochrome encode 122 16 14
'kusdeda'
$ phonochrome decode kusdeda
(122, 16, 14)
$ phonochrome --help

usage: phonochrome [-h] {encode,decode} ...

Phonochrome: A bijective 8-bit RGB encoding library that generates phonotactically plausible appellations.

options:
  -h, --help       show this help message and exit

Commands:
  {encode,decode}
    encode         Encode an 8-bit RGB tuple into a phonochrome appellation.
    decode         Decode a phonochrome appellation into an 8-bit RGB tuple.

In the event that an invalid argument was passed to encode/decode, the script will terminate with exit code 2, otherwise code 0.

$ phonochrome encode 295 543 712
Error: Invalid 8-bit RGB tuple: (295, 543, 712)
$ phonochrome decode invalid
Error: Invalid appellation: 'invalid'

Installation

Install from pip:

pip install phonochrome

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

phonochrome-1.0.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

phonochrome-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file phonochrome-1.0.0.tar.gz.

File metadata

  • Download URL: phonochrome-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for phonochrome-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1e88ffb679adb26f1c38480df618747bfe6f0726286b92a64468c981bc9498fb
MD5 da492fadc4c3c99a9976d40f7acba35f
BLAKE2b-256 22cc808b2f8eda713e72180a32f67e2998967cf333e8249319838fed4d0dfba4

See more details on using hashes here.

File details

Details for the file phonochrome-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: phonochrome-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for phonochrome-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d17818e487484400ed5b772afe64126c1217561ca2c78311434ff9700b3164c
MD5 2fe00de5a95b7d54900a1d9ce2c5f4e4
BLAKE2b-256 bf9e912d01f89704bd0ea20d5c1aa132e706d93b33e7c21078648c2b4174f1e3

See more details on using hashes here.

Supported by

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