Gruut Spanish Language Data
raw JSON → 2.0.1 verified Mon Apr 27 auth: no python
Spanish language data files for the gruut tokenizer and phonemizer. This package provides Spanish-specific lexicons, phoneme mappings, and grammar rules necessary for tokenizing and phonemizing Spanish text. Version 2.0.1 is the latest stable release.
pip install gruut-lang-es Common errors
error ModuleNotFoundError: No module named 'gruut_lang_es' ↓
cause Attempting to import the lang data package directly, which is not intended.
fix
Use 'from gruut import Gruut' and specify lang='es'; the data is auto-loaded.
error gruut.data.DataError: No data for language 'es' ↓
cause The gruut-lang-es package is not installed or not discovered.
fix
Install the package: pip install gruut-lang-es
error AttributeError: 'Sentence' object has no attribute 'words' ↓
cause Old API used 'sentence.words', but in v2.0+ sentences are iterable of Word objects directly.
fix
Iterate over the sentence object directly or use 'for word in sentence'.
Warnings
breaking Version 2.0.0 introduced major API changes; the old sentence pattern and inline pronunciation system were removed. ↓
fix Update to use 'gruut.sentences' API and SSML for custom pronunciations.
deprecated The 'gruut_lang_es' module is not intended for direct import; always use 'gruut.Gruut' with lang='es'. ↓
fix Import Gruut from gruut core instead of attempting to import lang data directly.
gotcha The Spanish lang data package must be installed separately from gruut core. Many users forget to install it. ↓
fix Run 'pip install gruut-lang-es' after installing gruut.
Imports
- Gruut
from gruut import Gruut
Quickstart
from gruut import Gruut
text = "Hola, ¿cómo estás?"
gruut = Gruut(lang="es")
sentences = list(gruut.tokenize(text))
for sentence in sentences:
for word in sentence:
print(f"{word.text} -> {word.phonemes}")