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.2.tar.gz (23.0 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.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: atciparotajs-0.1.2.tar.gz
  • Upload date:
  • Size: 23.0 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.2.tar.gz
Algorithm Hash digest
SHA256 8cd2d43444e8fc2b5b230b68c3735e33ab0821df1f134edc3427378145f9a845
MD5 5c88ef15f8ce575eaf96ed6a9951800d
BLAKE2b-256 f86f428a1c12856a1b136a8309b7d8ee261c1bb6df66be234e170c86b0ac056d

See more details on using hashes here.

Provenance

The following attestation bundles were made for atciparotajs-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: atciparotajs-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6c19abc555b5cbfae45ae1239afe79d6585703d2e45255eeae563add465fece1
MD5 dd6ec62dc46d982d2f2008d9c44d508b
BLAKE2b-256 9d2e1ed70bbb0d7c361ec62eab5d338a1f45259cce0d55f4bc9d1078e6a4db60

See more details on using hashes here.

Provenance

The following attestation bundles were made for atciparotajs-0.1.2-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