Skip to main content

pycotovia

Pure-Python G2P (grapheme-to-phoneme) phonemizer for Galician and Spanish, based on the Cotovia TTS system.

Features

  • Two languages — Galician (gl) and Spanish (es) with language-specific exception lists and rewrite rules.
  • Zero dependencies — pure Python, no C extensions, no heavy ML models.
  • Fast enough — single-word latency is well under 1 ms on modern hardware.
  • Parity-tested — verified against the original Cotovia C binary for Galician (see docs/parity.md).
  • IPA output — optional mapping from Cotovia phoneme symbols to IPA.

Installation

pip install pycotovia

Requires Python >= 3.11.

Quick start

import pycotovia

# Galician (default)
print(pycotovia.phonemize("Ola, como estás?"))      # → "ola komo estajs"
print(pycotovia.phonemize("guerra", lang="gl"))      # → "gerra"

# Spanish
print(pycotovia.phonemize("México", lang="es"))      # → "meksiko"
print(pycotovia.phonemize("México", lang="gl"))      # → "meSiko"

# IPA mapping
print(pycotovia.cotovia_to_ipa("gerra"))              # → "ɣɛra"

CLI

# Galician
echo "Ola mundo" | pycotovia

# Spanish
echo "Hola mundo" | pycotovia -l es

# From file
cat words.txt | pycotovia -l gl > phonemes.txt

Differences from the Cotovia binary

Aspect pycotovia Cotovia C binary
Timbre (open/closed e/o) Not applied in transcription mode Same — only used for voice-building
Stress in bui, fui, cuido Correctly shifts to u (buj, fuj, kujDo) Bug: keeps stress on i (bwi, fwi, kwiDo) due to a precedence error in aguda() / grave()

See docs/parity.md for the full parity test results and the deliberate divergences.

Documentation

Examples

See the examples/ directory for:

  • basic_usage.py — single words, phrases, and IPA
  • spanish_usage.py — Spanish-specific examples
  • phrase_processing.py — batch processing from a file

License

Apache-2.0 — this is a clean-room reimplementation in Python, not a derivative of the C++ source.

Acknowledgements

This is a clean-room port of the Cotovia G2P subsystem (transcription rules, syllabification, stress assignment, and exception lists) from C++ to Python. Cotovia was developed by the Multimedia Technologies Group at the University of Vigo and the Centro Ramón Piñeiro for Research in Humanities.

Metadata

Release files for pycotovia 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycotovia 0.1.0
File Size Uploaded
pycotovia-0.1.0.tar.gz 32.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycotovia 0.1.0
File Interpreter ABI Platform
pycotovia-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.4 kB

Release files / pycotovia-0.1.0.tar.gz

Download URL pycotovia-0.1.0.tar.gz
Size 32.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b22ca4bf8704c0d59ec8ffae217fb8c7e62d7616aa6093cbde6b1ab20c4d1c3f
BLAKE2b-256 checksum
How to use checksums
64369b83213edea54d45ad5ff6183db1cef6a881f51152e0b3521576e7f87352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / pycotovia-0.1.0-py3-none-any.whl

Download URL pycotovia-0.1.0-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e60b8426a5a73e0c84b137256dad71ffed0db4d5e72407fbd0689199cddcc882
BLAKE2b-256 checksum
How to use checksums
7e6c71fb0c8da1d30ed5ca000d426c1311bf5db85b34d0c1c5fdfa31b9fa6a21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page