Expand description
§Phonetik
Phonetic analysis engine for English. Sub-millisecond rhyme detection, stress scanning, meter analysis, and syllable counting backed by a 126K-word CMU Pronouncing Dictionary embedded directly in the binary.
§Quick start
use phonetik::Phonetik;
let ph = Phonetik::new();
// Look up a word
let info = ph.lookup("extraordinary").unwrap();
println!("{}: {} syllables, {}", info.word, info.syllable_count, info.stress_display);
// Find rhymes (all types, best first)
for r in ph.rhymes("love", 10) {
println!(" {} ({:?}, {:.0}%)", r.word, r.rhyme_type, r.confidence * 100.0);
}
// Scan a line of verse
let scan = ph.scan("uneasy lies the head that wears the crown");
println!("{} — {} ({})", scan.stressed_display, scan.meter.name, scan.meter.regularity);
// Compare two words
let cmp = ph.compare("cat", "bat").unwrap();
println!("similarity: {:.0}%, rhyme: {:?}", cmp.similarity * 100.0, cmp.rhyme_type);§Architecture
All dictionary data is compiled into the binary at build time:
| Blob | Size | Contents |
|---|---|---|
cmudict.bin | 2.3 MB | 126K words, u8-encoded phonemes |
rhyme_groups.bin | 993 KB | 14K perfect rhyme tail groups |
near_neighbors.bin | 350 KB | 3.2K coda edit-distance graph |
No filesystem access required. The binary is fully self-contained.
§Feature flags
server(default): Includes the HTTP server binary (phonetik-server) and dependencies (axum, tokio, reqwest). Disable withdefault-features = falsefor library-only use.
Modules§
- mcp
- MCP (Model Context Protocol) stdio transport.
- phoneme
- Low-level phoneme encoding/decoding.
- server
- HTTP API built with Axum. Used by the
phonetik-serverbinary and unit-tested in-process.
Structs§
- Comparison
- Result of comparing two words phonetically.
- Document
Analyze Options - Options for
Phonetik::analyze_document. Suitable for JSON request bodies (camelCase). - Document
Dominant Meter - Document
Line Metadata - Document
Metadata - Full-document prosody and coverage metadata.
- Document
Summary - Line
Scan - Result of scansion — stress and meter analysis of a line of text.
- Line
Syllable Count - Syllable counts for a line of text.
- Meter
Info - Detected metrical pattern.
- Phonetik
- The phonetic analysis engine. Create one with
Phonetik::new()and call methods on it. Thread-safe and cheaply cloneable — all internal data is reference-counted, soclone()is just a handful of pointer bumps with zero allocation. Share freely across threads. - Rhyme
Match - A word that rhymes with the query.
- Word
Info - Information about a single word’s phonetic properties.
- Word
Syllable Count - Syllable count for a single word.
Enums§
- Rhyme
Type - Classification of a rhyme relationship.
- Stress
Mode - Controls whether monosyllabic function words are demoted to unstressed.
Constants§
- DOCUMENT_
METADATA_ VERSION - Schema version for
DocumentMetadata. Increment when the JSON shape changes incompatibly.