Skip to main content

SpeechSynth

Types

DictionaryFolder

type DictionaryFolder = Folder

A DictionaryFolder consists of a folder, wtih a modulescript with the name that is exactly ~.

Within this ~ module, the layout must consist of;

return {
	language = "~"	-- the name of the dictionary language
	inherits = "en"	-- language code that the dictionary should inherit
	dictionary = {
		["WORD"] = {phonemes = {"W", "O", "R", "D"}, mode = "arpa"}
	}
}

or as a .json. file;

{
	"language": "fr",
	"inherits": "~",
	"dictionary": {
		"WORD": { "phonemes": ["W", "O", "R", "D"], "mode": "arpa"}
	}
}

The folder can have as many other modulescripts, provided they are a descendant of the folder. Each modulescript should follow this pattern;

return {
	["WORD"] = {phonemes = {"W", "O", "R", "D"}, mode = "arpa"}
}
{
	"WORD": { "phonemes": ["W", "O", "R", "D"], "mode": "arpa"}
}

SpeechMode

type SpeechMode = 'ipa' | 'arpa' | 'word' | 'simple' | 'muon' | 'reverse'

SpeechSettings

interface SpeechSettings {
voicestring?--

defaults to nil

modeSpeechMode?--

defaults to nil

pitchnumber?--

defaults to 1

speednumber?--

defaults to 1

volumenumber?--

defaults to 0.5

effectsSoundEffects.Settings?--

effects settings

}

Conversion

type Conversion = V | number | {V | number}

ConversionTable<I,V>

type ConversionTable<I,V> = {[I]Conversion<V>}

Pattern<V>

type Pattern<V> = {
patternstring,
subConversion<V>,
modeSpeechMode,
skipboolean?
}

Used to define rules for specific speech modes, if the pattern is detected, then the sub will be converted into ipa using the mode.

If skip is either false or not included, then the next character will skip to the next one not included in the pattern, however if skip is true then it will continue to the next letter.

PatternTable<V>

type PatternTable<V> = {Pattern<V>}

PermissionLevel

interface PermissionLevel {
voice{}?
mode{modes{SpeechMode}}?
speech{
minnumber,
maxnumber
}?
volume{
minnumber,
maxnumber
}?
reset{}?
effectsPermissions?
}

Settings

interface Settings {
LOG{
VOICEPACK_LOADEDboolean?,
REJECTED_AUDIOboolean?
}?
}

Properties

None

This item is read only and cannot be modified. Read Only
SpeechSynth.None: userdata

Should be used when changing a setting to nil in the moduleSettings for the .Init() function.

Functions

Init

SpeechSynth.Init(moduleSettingsSettings) → ()
caution

This must be called first!

This sets up SpeechSynth before any other functions can be called.

loadVoicepack

SpeechSynth.loadVoicepack(voicepackVoicepack) → ()

Loads a voicepack into SpeechSynth

loadDictionary

SpeechSynth.loadDictionary(dictionaryPronunciationDictionary | DictionaryFolder) → ()

Loads a pronunciation dictionary into SpeechSynth.

dictionary must either be a PronunciationDictionary, or alternatively must be a folder that follows the layout of the DictionaryFolder type.

loadBlacklist

SpeechSynth.loadBlacklist(blacklistBlacklist) → number--

amount of new additions

Loads a blacklist into SpeechSynth.

Each blacklist is an array of string patterns, that is merged with any existing blacklist. If UseBlacklist is true when generating a speech object, then the string will be filtered using the blacklist.

generateSpeech

SpeechSynth.generateSpeech(speechDataSpeechData) → Promise → SpeechObject

Types

interface SpeechData {
ModeSpeechMode
Voicepackstring
Messagestring
UseBlacklistboolean?
SettingsSpeechSettings?
PermissionLevelstring?
ValidVoicepacks{string}?
}

Returns a promise, that will be resolved with the generated speech object.

playSpeech

SpeechSynth.playSpeech(
parentInstance,
speechObjectSpeechObject,
playSettingsPlaySettings?
) → Promise

Returns a promise that is resolved upon the speech object has been played.

highlightText

SpeechSynth.highlightText(
textstring,
permissionLevelstring?,
availableVoicepacks{string}?
) → string

Returns a string with any speech modifiers highlighted using rich text.

If permissionLevel is provided, then the highlighted text will be based on what commands is currently loaded at that permission level.

If availableVoicepacks is provided, then it will highlight any voicepack changes according to the list.

The hightlight settings can be customised using SETTINGS.HIGHLIGHT.

  • HIGHLIGHT.COLOR

    This dictionary allows us to specify the different colours for the different modifer parts.

    • VALID Color3
    • INVALID Color3
    • IGNORED Color3
    • CONSTRAINED Color3
    • MISC Color3
    • UNKNOWN Color3
  • HIGHTLIGHT.STYLE

    This relates to the stylization of the modifiers.

    • ITALIC_MODIFIER boolean
  • HIGHLIGHT.FONT

    Allows us to change the font for different parts of the highlighted modifier.

    • MODIFIER Font

clearCache

SpeechSynth.clearCache() → ()

Used to clear all messages from the speech cache

Show raw api
{
    "functions": [
        {
            "name": "Init",
            "desc": ":::caution\nThis must be called first!\n:::\n\nThis sets up SpeechSynth before any other functions can be called.",
            "params": [
                {
                    "name": "moduleSettings",
                    "desc": "",
                    "lua_type": "Settings"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 43,
                "path": "src/init.luau"
            }
        },
        {
            "name": "loadVoicepack",
            "desc": "Loads a voicepack into SpeechSynth",
            "params": [
                {
                    "name": "voicepack",
                    "desc": "",
                    "lua_type": "Voicepack"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 52,
                "path": "src/init.luau"
            }
        },
        {
            "name": "loadDictionary",
            "desc": "Loads a pronunciation dictionary into SpeechSynth.\n\n`dictionary` must either be a PronunciationDictionary, or alternatively\nmust be a folder that follows the layout of the `DictionaryFolder` type.",
            "params": [
                {
                    "name": "dictionary",
                    "desc": "",
                    "lua_type": "PronunciationDictionary | DictionaryFolder"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "src/init.luau"
            }
        },
        {
            "name": "loadBlacklist",
            "desc": "Loads a blacklist into SpeechSynth.\n\nEach blacklist is an array of string patterns, that is merged with any\nexisting blacklist. If `UseBlacklist` is true when generating a speech\nobject, then the string will be filtered using the blacklist.",
            "params": [
                {
                    "name": "blacklist",
                    "desc": "",
                    "lua_type": "Blacklist"
                }
            ],
            "returns": [
                {
                    "desc": "amount of new additions",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 84,
                "path": "src/init.luau"
            }
        },
        {
            "name": "generateSpeech",
            "desc": "Returns a promise, that will be resolved with the generated speech object.",
            "params": [
                {
                    "name": "speechData",
                    "desc": "",
                    "lua_type": "SpeechData"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise -> SpeechObject"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 95,
                "path": "src/init.luau"
            }
        },
        {
            "name": "playSpeech",
            "desc": "Returns a promise that is resolved upon the speech object has been played.",
            "params": [
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "speechObject",
                    "desc": "",
                    "lua_type": "SpeechObject"
                },
                {
                    "name": "playSettings",
                    "desc": "",
                    "lua_type": "PlaySettings?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 108,
                "path": "src/init.luau"
            }
        },
        {
            "name": "highlightText",
            "desc": "Returns a string with any speech modifiers highlighted using rich text.\n\nIf `permissionLevel` is provided, then the highlighted text will be based\non what commands is currently loaded at that permission level.\n\nIf `availableVoicepacks` is provided, then it will highlight any voicepack\nchanges according to the list.\n\nThe hightlight settings can be customised using `SETTINGS.HIGHLIGHT`.\n\n* HIGHLIGHT.COLOR\n\n\tThis dictionary allows us to specify the different colours for the\n\tdifferent modifer parts.\n\n\t* VALID Color3\n\t* INVALID Color3\n\t* IGNORED Color3\n\t* CONSTRAINED Color3\n\t* MISC Color3\n\t* UNKNOWN Color3\n\n* HIGHTLIGHT.STYLE\n\n\tThis relates to the stylization of the modifiers.\n\n\t* ITALIC_MODIFIER boolean\n\n* HIGHLIGHT.FONT\n\n\tAllows us to change the font for different parts of the highlighted\n\tmodifier.\n\n\t* MODIFIER Font",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "permissionLevel",
                    "desc": "",
                    "lua_type": "string?"
                },
                {
                    "name": "availableVoicepacks",
                    "desc": "",
                    "lua_type": "{string}?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 154,
                "path": "src/init.luau"
            }
        },
        {
            "name": "previewMessageForBlacklist",
            "desc": "This function is used to preview what a message will look like just after\nthe blacklist has been applied.\n\nIt is to be used to preview what a message would look like if so it can be\npotentially added to a blacklist.",
            "params": [
                {
                    "name": "message",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "private": true,
            "ignore": true,
            "source": {
                "line": 171,
                "path": "src/init.luau"
            }
        },
        {
            "name": "clearCache",
            "desc": "Used to clear all messages from the speech cache",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 178,
                "path": "src/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "None",
            "desc": "Should be used when changing a setting to nil in the moduleSettings for the\n`.Init()` function.",
            "lua_type": "userdata",
            "readonly": true,
            "source": {
                "line": 32,
                "path": "src/init.luau"
            }
        }
    ],
    "types": [
        {
            "name": "DictionaryFolder",
            "desc": "A `DictionaryFolder` consists of a folder, wtih a modulescript with the\nname that is **exactly** `~`.\n\nWithin this `~` module, the layout must consist of;\n```lua\nreturn {\n\tlanguage = \"~\"\t-- the name of the dictionary language\n\tinherits = \"en\"\t-- language code that the dictionary should inherit\n\tdictionary = {\n\t\t[\"WORD\"] = {phonemes = {\"W\", \"O\", \"R\", \"D\"}, mode = \"arpa\"}\n\t}\n}\n```\n\nor as a `.json.` file;\n\n```json\n{\n\t\"language\": \"fr\",\n\t\"inherits\": \"~\",\n\t\"dictionary\": {\n\t\t\"WORD\": { \"phonemes\": [\"W\", \"O\", \"R\", \"D\"], \"mode\": \"arpa\"}\n\t}\n}\n```\n\nThe folder can have as many other modulescripts, provided they are a\ndescendant of the folder. Each modulescript should follow this pattern;\n```lua\nreturn {\n\t[\"WORD\"] = {phonemes = {\"W\", \"O\", \"R\", \"D\"}, mode = \"arpa\"}\n}\n```\n\n```json\n{\n\t\"WORD\": { \"phonemes\": [\"W\", \"O\", \"R\", \"D\"], \"mode\": \"arpa\"}\n}\n```",
            "lua_type": "Folder",
            "source": {
                "line": 116,
                "path": "src/Functions/Dictionary.luau"
            }
        },
        {
            "name": "SpeechData",
            "desc": "",
            "fields": [
                {
                    "name": "Mode",
                    "lua_type": "SpeechMode",
                    "desc": ""
                },
                {
                    "name": "Voicepack",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "Message",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "UseBlacklist",
                    "lua_type": "boolean?",
                    "desc": ""
                },
                {
                    "name": "Settings",
                    "lua_type": "SpeechSettings?",
                    "desc": ""
                },
                {
                    "name": "PermissionLevel",
                    "lua_type": "string?",
                    "desc": ""
                },
                {
                    "name": "ValidVoicepacks",
                    "lua_type": "{string}?",
                    "desc": ""
                }
            ],
            "source": {
                "line": 786,
                "path": "src/Functions/Generate.luau"
            }
        },
        {
            "name": "SpeechMode",
            "desc": "",
            "lua_type": "'ipa'|'arpa'|'word'|'simple'|'muon'|'reverse'",
            "source": {
                "line": 13,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "Command",
            "desc": "",
            "lua_type": "'voice'|'mode'|'speed'|'volume'|'reset'",
            "ignore": true,
            "source": {
                "line": 21,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "PhonemeIPA",
            "desc": "",
            "lua_type": "'æ'|'ɐ'|'ɑ'|'ɒ'|'α'|'β'|'ɓ'|'ç'|'č'|'ɕ'|'ð'|'ɖ'|'ḍ'|'ɗ'|'ə'|'ε'|'ɛ'|'ẹ'|'ɜ'|'ɚ'|'ɘ'|'φ'|'ɸ'|'ɟ'|'γ'|'ɣ'|'ɠ'|'ħ'|'ɦ'|'h'|'ʰ'|'ɥ'|'ḥ'|'ɧ'|'ɪ'|'i'|'ɨ'|'ǰ'|'ʝ'|'ʲ'|'ɟ'|'ɫ'|'l'|'λ'|'ʎ'|'ɭ'|'ḷ'|'ɬ'|'ɮ'|'ɱ'|'ɯ'|'ɰ'|'ñ'|'ŋ'|'ɲ'|'ɳ'|'ṇ'|'ø'|'œ'|'ö'|'ɔ'|'ọ'|'ɵ'|'ɹ'|'ʁ'|'ř'|'ɾ'|'ɽ'|'ṛ'|'ɻ'|'š'|'ʃ'|'ʄ'|'ś'|'ṣ'|'ʂ'|'θ'|'þ'|'ʈ'|'ṭ'|'ʊ'|'ü'|'u'|'ʉ'|'ɞ'|'ʌ'|'ʋ'|'ʍ'|'w'|'ʷ'|'ŵ'|'ɯ'|'ɰ'|'χ'|'ɥ'|'ŷ'|'y'|'ɰ'|'ž'|'ʒ'|'ẓ'|'ʑ'|'ʐ'|'ʔ'|'ʕ'|'ʡ'|'ʢ'|'ʘ'|'ː'|'ˑ'",
            "ignore": true,
            "source": {
                "line": 29,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "PhonemeARPA",
            "desc": "",
            "lua_type": "\"AO'|'AE'|'AH'|'AA'|'AW'|'AX'|'AXR'|'AY'|'B'|'CH'|'D'|'DH'|'DX'|'EH'|'EL'|'EM'|'EN'|'ER'|'EY'|'F'|'G'|'HH'|'IH'|'IX'|'IY'|'JH'|'K'|'L'|'M'|'N'|'NG'|'NX'|'OW'|'OY'|'P'|'Q'|'R'|'S'|'SH'|'T'|'TH'|'UH'|'UW'|'UX'|'V'|'W'|'WH'|'Y'|'Z'|'ZH\"",
            "ignore": true,
            "source": {
                "line": 37,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "SpeechSettings",
            "desc": "",
            "fields": [
                {
                    "name": "voice",
                    "lua_type": "string?",
                    "desc": "defaults to nil"
                },
                {
                    "name": "mode",
                    "lua_type": "SpeechMode?",
                    "desc": "defaults to nil"
                },
                {
                    "name": "pitch",
                    "lua_type": "number?",
                    "desc": "defaults to 1"
                },
                {
                    "name": "speed",
                    "lua_type": "number?",
                    "desc": "defaults to 1"
                },
                {
                    "name": "volume",
                    "lua_type": "number?",
                    "desc": "defaults to 0.5"
                },
                {
                    "name": "effects",
                    "lua_type": "SoundEffects.Settings?",
                    "desc": "effects settings"
                }
            ],
            "source": {
                "line": 51,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "Conversion",
            "desc": "",
            "lua_type": "V|number|{V|number}",
            "source": {
                "line": 64,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "ConversionTable<I,V>",
            "desc": "",
            "lua_type": "{[I]: Conversion<V>}",
            "source": {
                "line": 71,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "Pattern<V>",
            "desc": "Used to define rules for specific speech modes, if the pattern is detected,\nthen the sub will be converted into ipa using the mode.\n\nIf `skip` is either `false` or not included, then the next character will\nskip to the next one not included in the pattern, however if skip is `true`\nthen it will continue to the next letter.",
            "lua_type": "{pattern: string, sub: Conversion<V>, mode: SpeechMode, skip: boolean?}",
            "source": {
                "line": 85,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "PatternTable<V>",
            "desc": "",
            "lua_type": "{Pattern<V>}",
            "source": {
                "line": 92,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "PermissionLevel",
            "desc": "",
            "fields": [
                {
                    "name": "voice",
                    "lua_type": "{}?",
                    "desc": ""
                },
                {
                    "name": "mode",
                    "lua_type": "{ modes: {SpeechMode} }?",
                    "desc": ""
                },
                {
                    "name": "speech",
                    "lua_type": "{ min: number, max: number }?",
                    "desc": ""
                },
                {
                    "name": "volume",
                    "lua_type": "{ min: number, max: number }?",
                    "desc": ""
                },
                {
                    "name": "reset",
                    "lua_type": "{}?",
                    "desc": ""
                },
                {
                    "name": "effects",
                    "lua_type": "Permissions?",
                    "desc": ""
                }
            ],
            "source": {
                "line": 107,
                "path": "src/Utility/Settings.luau"
            }
        },
        {
            "name": "Settings",
            "desc": "",
            "fields": [
                {
                    "name": "LOG",
                    "lua_type": "{ VOICEPACK_LOADED: boolean?, REJECTED_AUDIO: boolean?}?",
                    "desc": ""
                }
            ],
            "source": {
                "line": 124,
                "path": "src/Utility/Settings.luau"
            }
        }
    ],
    "name": "SpeechSynth",
    "desc": "",
    "source": {
        "line": 5,
        "path": "src/init.luau"
    }
}