Skip to main content

Crate shabda

Crate shabda 

Source
Expand description

§shabda — Grapheme-to-Phoneme Conversion

shabda (Sanskrit: word / sound) provides text-to-phoneme conversion for vocal synthesis. It bridges the gap between text input and svara’s phoneme sequences — turning “hello world” into synthesizable phoneme events.

§Architecture

Input text
    |
    v
Normalizer (lowercase, expand numbers, handle punctuation)
    |
    v
Tokenizer (split into words, detect sentence boundaries)
    |
    v
G2P Engine (dictionary lookup → rule-based fallback)
    |
    v
Prosody Mapper (stress, intonation from punctuation/syntax)
    |
    v
Vec<PhonemeEvent> (ready for svara)

§Quick Start

use shabda::prelude::*;

let g2p = G2PEngine::new(Language::English);
let events = g2p.convert("hello world").unwrap();
// events is a Vec<svara::sequence::PhonemeEvent> ready for rendering

§Feature Flags

FeatureDefaultDescription
stdYesStandard library. Disable for no_std + alloc
loggingNoStructured logging via tracing-subscriber
jsonNoJSON serialization via serde_json
varnaNoPhoneme inventory validation and language detection via varna
fullNoAll of the above

Modules§

arpabet
ARPABET-to-svara phoneme mapping.
dictionary
Pronunciation dictionary for common/irregular words.
engine
The G2P engine — ties normalization, dictionary, rules, and prosody together.
error
Error types for the shabda crate.
heteronym
Heteronym disambiguation using preceding-word context.
normalize
Text normalization: lowercasing, punctuation handling, number expansion.
prelude
Convenience re-exports for common usage.
prosody
Prosody assignment from text features.
rules
Rule-based grapheme-to-phoneme conversion for English.
ssml
SSML subset parser for speech synthesis markup.
syllable
Syllabification of phoneme sequences.