Skip to main content

Latvian number-to-words converter for TTS preprocessing

Project description

Atciparotājs

Latvian text preprocessor for TTS engines. Converts digits, numbers, and abbreviations to spoken Latvian words.

Numbers are inflected to agree in gender and grammatical case with the following noun.

Features

  • Cardinal numbers5 gramipieci grami
  • Ordinal numbers5. maijspiektais maijs
  • Roman numeralsXIV gs.četrpadsmitais gadsimts
  • Decimals/fractions21,5 gramidivdesmit viens komats pieci grami
  • Abbreviation expansiongs.gadsimts, km.kilometrs, and more
  • Phone numbers — spelled out digit by digit {phone:67030638}seši septiņi nulle trīs nulle seši trīs astoņi

Installation

pip install atciparotajs

Usage

Python API

from atciparotajs import convert

convert("5. maijs")          # → "piektais maijs"
convert("2 draugiem")        # → "diviem draugiem"
convert("XIV gs.")           # → "četrpadsmitais gadsimts"
convert("21,5 grami")        # → "divdesmit viens komats pieci grami"

# Disable abbreviation expansion
convert("14. gs.", expand_abbr=False)  # → "četrpadsmitais gs."

Command line

# Direct argument
atciparotajs "5. maijs"

# Piped input
echo "2 draugiem" | atciparotajs

# Disable abbreviation expansion
atciparotajs --no-expand-abbr "14. gs."

Phone numbers

Phone numbers are detected automatically and read digit by digit:

atciparotajs "tel. 67 030 638"      # → "seši septiņi nulle trīs nulle seši trīs astoņi"
atciparotajs "mob: 67030638"        # → "seši septiņi nulle trīs nulle seši trīs astoņi"
atciparotajs "+371 67 030 638"      # → "seši septiņi nulle trīs nulle seši trīs astoņi"

Recognized prefixes: tel, tel., tel:, mob, mob., mob:, and +371.

For plain digit strings that should be read as phone numbers rather than as a number, use the explicit {phone:…} markup:

atciparotajs "{phone:67030638}"     # → "seši septiņi nulle trīs nulle seši trīs astoņi"

Without the markup, a bare 67030638 would be read as the cardinal number. Use {phone:…} whenever you want digit-by-digit pronunciation for a number that has no recognizable phone prefix.

Running tests

pytest tests/test_numbers.py -v

For test cases covered see test list

Testing with TTS

For real life TTS testing go to Latvian-Piper-TTS

License

MIT

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

atciparotajs-0.1.3.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

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

atciparotajs-0.1.3-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file atciparotajs-0.1.3.tar.gz.

File metadata

  • Download URL: atciparotajs-0.1.3.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atciparotajs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e64faf08f1e6db90e966ed1d82fddab415eb3f126ec620191c9ee8cc790516e8
MD5 58d73891b08e7bd548035d633cc0c847
BLAKE2b-256 f63cb7de2c6fedc993956621f3aa748012069b3012d4206bbe42f9e39ae71e78

See more details on using hashes here.

Provenance

The following attestation bundles were made for atciparotajs-0.1.3.tar.gz:

Publisher: publish.yml on raivisdejus/atciparotajs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atciparotajs-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: atciparotajs-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atciparotajs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72bf0e4c8ae01549ccf2f2f6216fed1840f9b5be569bdbb460df959d4d8c6efb
MD5 8fa36731ea31bf3821c54b4be89f274c
BLAKE2b-256 7e64b7b45736ab11792acf3445d1d05b269e6f14d24b7bf562a4fcf64741cdc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for atciparotajs-0.1.3-py3-none-any.whl:

Publisher: publish.yml on raivisdejus/atciparotajs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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