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 numbers —
5 grami→pieci grami - Ordinal numbers —
5. maijs→piektais maijs - Roman numerals —
XIV gs.→četrpadsmitais gadsimts - Decimals/fractions —
21,5 grami→divdesmit viens komats pieci grami - Abbreviation expansion —
gs.→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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64faf08f1e6db90e966ed1d82fddab415eb3f126ec620191c9ee8cc790516e8
|
|
| MD5 |
58d73891b08e7bd548035d633cc0c847
|
|
| BLAKE2b-256 |
f63cb7de2c6fedc993956621f3aa748012069b3012d4206bbe42f9e39ae71e78
|
Provenance
The following attestation bundles were made for atciparotajs-0.1.3.tar.gz:
Publisher:
publish.yml on raivisdejus/atciparotajs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
atciparotajs-0.1.3.tar.gz -
Subject digest:
e64faf08f1e6db90e966ed1d82fddab415eb3f126ec620191c9ee8cc790516e8 - Sigstore transparency entry: 1965266766
- Sigstore integration time:
-
Permalink:
raivisdejus/atciparotajs@7c784c13cad33b6692915ef0a8168665887c376e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/raivisdejus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c784c13cad33b6692915ef0a8168665887c376e -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72bf0e4c8ae01549ccf2f2f6216fed1840f9b5be569bdbb460df959d4d8c6efb
|
|
| MD5 |
8fa36731ea31bf3821c54b4be89f274c
|
|
| BLAKE2b-256 |
7e64b7b45736ab11792acf3445d1d05b269e6f14d24b7bf562a4fcf64741cdc2
|
Provenance
The following attestation bundles were made for atciparotajs-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on raivisdejus/atciparotajs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
atciparotajs-0.1.3-py3-none-any.whl -
Subject digest:
72bf0e4c8ae01549ccf2f2f6216fed1840f9b5be569bdbb460df959d4d8c6efb - Sigstore transparency entry: 1965266887
- Sigstore integration time:
-
Permalink:
raivisdejus/atciparotajs@7c784c13cad33b6692915ef0a8168665887c376e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/raivisdejus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c784c13cad33b6692915ef0a8168665887c376e -
Trigger Event:
push
-
Statement type: