Table of Contents

Class TtsPreprocessor

Namespace
AiDotNet.Audio.TextToSpeech
Assembly
AiDotNet.dll

Preprocesses text for text-to-speech synthesis.

public class TtsPreprocessor
Inheritance
TtsPreprocessor
Inherited Members

Remarks

This class handles text normalization and grapheme-to-phoneme (G2P) conversion to prepare text for acoustic model input.

For Beginners: Before TTS can synthesize speech, we need to convert written text into phonemes (speech sounds). This involves:

  • Normalizing text (expanding abbreviations, numbers)
  • Converting graphemes (letters) to phonemes (sounds)
For example: "Dr. Smith, 123 Main St." becomes phonemes like "D AH K T ER S M IH TH..."

Fields

EndPhoneme

public const int EndPhoneme = 101

Field Value

int

PadPhoneme

Special phoneme IDs.

public const int PadPhoneme = 0

Field Value

int

SilencePhoneme

public const int SilencePhoneme = 102

Field Value

int

StartPhoneme

public const int StartPhoneme = 100

Field Value

int

Methods

NormalizeText(string)

Normalizes text for TTS processing.

public string NormalizeText(string text)

Parameters

text string

The text to normalize.

Returns

string

Normalized text.

SplitIntoSentences(string)

Splits text into sentences for chunked synthesis.

public List<string> SplitIntoSentences(string text)

Parameters

text string

The text to split.

Returns

List<string>

List of sentences.

TextToPhonemes(string)

Converts text to phoneme IDs.

public int[] TextToPhonemes(string text)

Parameters

text string

The text to convert.

Returns

int[]

Array of phoneme IDs.