Phonetic respelling that spells foreign words like English words. No hyphens, no caps — looks like English, reads as an approximation of the foreign word.
JS port of chunky-metro/respelling (Ruby). Two implementations, one canonical data shape, parity-tested.
The dictionary-style transliteration mah-NYAH-nah has existed forever — every Merriam-Webster entry has one. That's not what this is. This library writes manyana — a respelling that looks like an English word an English reader naturally pronounces (and which approximates the Spanish). No hyphens marking syllable boundaries, no uppercase marking stress. English orthography does the work.
| Spanish | Dictionary style | This library (v0.3) |
|---|---|---|
| Buenos días | BWAY-nohs DEE-ahs |
bwaynose deeyus |
| Mañana | mah-NYAH-nah |
manyana |
| Gracias | GRAH-syahs |
grasseeus |
| Por favor | por fah-VOHR |
porfavore |
| Hola | OH-lah |
ohla |
npm install respelling
# or directly from GitHub:
npm install github:chunky-metro/respelling-jsimport { respell } from 'respelling';
respell({ ipa: 'ˈbwe.no̞s ˈði.as', source: 'es', target: 'en' });
// → 'BWAY-nohs DEE-ahs'
respell({ ipa: 'ˈgɾa.sjas' });
// → 'GRAH-syahs' (defaults: source: 'es', target: 'en')Lower-level constructor for repeated calls:
import { Converter, Spanish } from 'respelling';
const c = new Converter(Spanish.forTarget('en'));
c.respell('ˈko.mo es.ˈtas'); // → 'KOH-moh ays-TAHS'
c.warnings; // → [] (any unknown phonemes accumulate here)npx respelling 'ˈbwe.nos ˈði.as'
# → BWAY-nohs DEE-ahs
echo 'poɾ fa.ˈβoɾ' | npx respelling
# → por fah-BOR
npx respelling --source es --target en 'ˈna.ða'
# → NAH-dahGiven an IPA transcription of a phrase in some source language (Spanish, Korean, French, ...), produce a respelling in the target language's orthography that an English (or French, or whatever target) reader can read aloud and pronounce passably.
Reader-perception-driven, not phoneme-rigor-driven. Real example: Spanish /ˈbwe.no̞s ˈði.as/ becomes BWAY-nohs DEE-ahs, not BWEH-nohs THEE-ahs. An English speaker reading BWEH says "bweh" (like "bed"), not the diphthong they should produce; BWAY pushes them toward the right sound. Same for ð→d instead of ð→th — English speakers don't natively produce intervocalic /ð/ before a vowel here, and reading THEE makes them say "thee" (like the pronoun) instead of the soft d-ish flap that's actually closer.
Each source language exposes a per-target table:
src/data/spanish-en.json # Spanish IPA → English orthography
src/data/spanish-pt.json # Spanish IPA → Portuguese orthography (future)
src/data/korean-en.json # Korean IPA → English orthography (future)
To add a new source language:
- Drop a JSON file at
src/data/{source}-{target}.jsonwith the schema below. - Register the source module (mirror
src/spanish.js) and add a case insrc/index.js'sREGISTRY.
Schema (v2):
{
"schema_version": 2,
"source_language": "es",
"source_dialect": "latin-american",
"target_orthography": "en",
"stress_marker": "uppercase",
"syllable_separator": "-",
"entries": [
{ "ipa": "a", "respelling": "ah" },
{ "ipa": "bwe", "respelling": "bway" },
...
]
}The converter is a longest-match-first walker, language-agnostic. All language-specific knowledge lives in the JSON.
1. Hand-curated corpus (src/data/spanish-en-corpus.json) — 50 phrases respelled with the novel English-word-shape style. The v1 craft-curated layer — what the parrot-lab demo serves.
2. LLM-respelling for ANY phrase — respellViaLLM({ phrase, source, target }) — calls Gemma3-27b on OpenRouter with a few-shot prompt anchored on the corpus style. Works on phrases that aren't in the corpus.
import { respellViaLLM } from 'respelling';
await respellViaLLM({ phrase: 'Estoy bien' });
// → 'estoy byen'
await respellViaLLM({ phrase: 'Me llamo Carlos' });
// → 'may yaamo carlos'
// Pass api key explicitly if not in env:
await respellViaLLM({ phrase: 'Tengo hambre', apiKey: '...' });
// Defaults: source='es', target='en', model='google/gemma-4-26b-a4b-it'Requires OPENROUTER_API_KEY in env. Uses google/gemma-4-26b-a4b-it by default — small, fast, follows the few-shot orthography rules well. Cost is fractions of a cent per phrase.
3. Algorithmic IPA fallback (src/data/spanish-en.json) — static IPA→respelling table. Currently emits dictionary style (BWAY-nohs DEE-ahs) — kept as a deterministic fallback when LLM is unavailable.
Novel English-word-shape (v0.3, hand-curated):
- No hyphens, no uppercase. Single English-looking word per Spanish word.
- Standard English vowel orthography:
eefor /i/,ohfor /o/,ayfor /e/,oofor /u/,ah/afor /a/. manyananotmah-NYAH-nah.bwaynosenotBWAY-nohs.grasseeusnotGRAH-syahs.- Where a real English word approximates the sound, prefer it (e.g.,
boyfor "voy",saynotsehfor "sé"). - Capitalization comes from sentence-initial / proper-noun rules, NOT from stress.
Four guiding principles (v0.3.2):
- Drop silent letters from the source. Spanish silent H is the canonical case — "Hasta" →
asta. An English reader who sees "Hasta" pronounces the H; dropping it removes the misvoicing. - Use natural English orthography combinations — never transliteration markers (no schwa, no IPA, no diacritics).
- For sound clusters with no single English-word analog, fuse fragments of multiple English words. Spanish "luego" has the cluster "lwe" with no clean English-word match —
lawaygofuseslaw+way+go, three English-word fragments an English reader naturally reads in sequence. - Real-English-word base. When a foreign word sounds and spells close to a real English word, base the respelling on that English word with a minor twist. Spanish "Gracias" →
grassious(real Englishgracious+ extras, reads "GRASS-yus" ≈ Spanish "GRAH-syahs").
So "Hasta luego" → asta lawaygo, not asta lwaygo (lwa is not English) and not ahsta lwehgo (transliteration markers). And "Gracias" → grassious, not grasseeus (the ee-us tail is awkward).
Algorithmic v0.2 (still in IPA fallback table):
/a/→ah,/e/→ay,/i/→ee,/o/→oh,/u/→oo/ð/→d,/x/→h,/ɲ/→ny,/ʝ/ʎ/→y,/ɾ/→r,/r/→rr- Stressed syllable → uppercase; syllables joined with
-
npm test21 tests cover the canonical examples, vowel rules, consonant edge cases, longest-match-first behavior, error handling. Parity-aligned with the Ruby gem's spec suite.
MIT — see LICENSE.
- chunky-metro/respelling — Ruby canonical
- chunky-metro/parrot-lab — language-learning playground that consumes this package