Swift port of Misaki G2P (grapheme-to-phoneme) library that can be used e.g. to generate phonemization for Kokoro text-to-speech engine
32
stars
38
commits
Swift
primary language
Jun 30, 2026
updated
A Swift port of the Misaki grapheme-to-phoneme (G2P) library for converting English text to phonetic representations suitable for text-to-speech (TTS) engines.
Add MisakiSwift to your Swift Package Manager dependencies:
dependencies: [
.package(url: "https://github.com/mlalma/MisakiSwift", from: "1.0.1")
]
import MisakiSwift
// Create G2P converter (british = false for American English)
let g2p = EnglishG2P(british: false)
// Convert text to phonemes
let (phonemes, tokens) = g2p.phonemize(text: "Hello world!")
print(phonemes) // "həlˈO wˈɜɹld!"
Use Markdown-like syntax to specify exact pronunciations in case you don't want to use fallback network:
let g2p = EnglishG2P(british: false)
let text = "[Misaki](/misˈɑki/) is a G2P engine designed for [Kokoro](/kˈOkəɹO/) models."
let (phonemes, _) = g2p.phonemize(text: text)
// "misˈɑki ɪz ɐ ʤˈitəpˈi ˈɛnʤən dəzˈInd fɔɹ kˈOkəɹO mˈɑdᵊlz."
MisakiSwift is a high-quality English G2P conversion library that transforms written text into phonemes using both dictionary-based lookup and neural network fallback. It supports British and American English pronunciations and includes advanced features like stress pattern handling and custom phoneme overrides.
[word](/phonemes/)MisakiSwift consists of several key components:
EnglishG2P: Main conversion pipeline that orchestrates tokenization, lexicon lookup, and neural network fallbackLexicon: Dictionary-based pronunciation lookup using gold and silver dictionariesEnglishFallbackNetwork: Transformer-based model (ported to run on MLX) for phoneme prediction for out-of-vocabulary wordsNaturalLanguage framework instead of SpaCy for part-of-speech taggingMToken, used also in other parts of the ML stackThe package includes pre-trained models and dictionaries:
These resources are automatically bundled with the package and loaded at runtime.
37 commits
1 commits
Swift
100.0%
Swift port of Misaki G2P (grapheme-to-phoneme) library that can be used e.g. to generate phonemization for Kokoro text-to-speech engine
32
stars
38
commits
Swift
primary language
Jun 30, 2026
updated
A Swift port of the Misaki grapheme-to-phoneme (G2P) library for converting English text to phonetic representations suitable for text-to-speech (TTS) engines.
Add MisakiSwift to your Swift Package Manager dependencies:
dependencies: [
.package(url: "https://github.com/mlalma/MisakiSwift", from: "1.0.1")
]
import MisakiSwift
// Create G2P converter (british = false for American English)
let g2p = EnglishG2P(british: false)
// Convert text to phonemes
let (phonemes, tokens) = g2p.phonemize(text: "Hello world!")
print(phonemes) // "həlˈO wˈɜɹld!"
Use Markdown-like syntax to specify exact pronunciations in case you don't want to use fallback network:
let g2p = EnglishG2P(british: false)
let text = "[Misaki](/misˈɑki/) is a G2P engine designed for [Kokoro](/kˈOkəɹO/) models."
let (phonemes, _) = g2p.phonemize(text: text)
// "misˈɑki ɪz ɐ ʤˈitəpˈi ˈɛnʤən dəzˈInd fɔɹ kˈOkəɹO mˈɑdᵊlz."
MisakiSwift is a high-quality English G2P conversion library that transforms written text into phonemes using both dictionary-based lookup and neural network fallback. It supports British and American English pronunciations and includes advanced features like stress pattern handling and custom phoneme overrides.
[word](/phonemes/)MisakiSwift consists of several key components:
EnglishG2P: Main conversion pipeline that orchestrates tokenization, lexicon lookup, and neural network fallbackLexicon: Dictionary-based pronunciation lookup using gold and silver dictionariesEnglishFallbackNetwork: Transformer-based model (ported to run on MLX) for phoneme prediction for out-of-vocabulary wordsNaturalLanguage framework instead of SpaCy for part-of-speech taggingMToken, used also in other parts of the ML stackThe package includes pre-trained models and dictionaries:
These resources are automatically bundled with the package and loaded at runtime.
37 commits
1 commits
Swift
100.0%