Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TextConverter = {
- LetterSounds = {
- ["a"] = {223757826, nil}; -- 203343899
- ["b"] = {223533700, 0.2}; -- 203344029
- ["c"] = {223533711, nil}; -- 203343994
- ["d"] = {223757910, nil}; -- 203398237
- ["e"] = {223758026, nil}; -- 203398295
- ["f"] = {223777655, nil}; -- 203398347
- ["g"] = {223777738, nil}; -- 203398372
- ["h"] = {223777757, nil}; -- 203398397
- ["i"] = {223777807, nil}; -- 203398422
- ["j"] = {223782888, nil}; -- 203398450
- ["k"] = {223533711, nil}; -- 203343994
- ["l"] = {223782961, 0.4}; -- 203398541
- ["m"] = {223782992, nil}; -- 203398578
- ["n"] = {223783063, nil}; -- 203398599
- ["o"] = {223783184, nil}; -- 203398611
- ["p"] = {223783235, nil}; -- 203398727
- ["q"] = {223783260, nil}; -- 203398755
- ["r"] = {223783305, 0.2}; -- 203398792
- ["s"] = {223783377, nil}; -- 203398806
- ["t"] = {223783446, nil}; -- 203398850
- ["u"] = {223783512, nil}; -- 203398872
- ["v"] = {223783654, nil}; -- 203398965
- ["w"] = {223783697, nil}; -- 203398984
- ["x"] = {223783796, nil}; -- 203399008
- ["y"] = {223783853, nil}; -- 203399043
- ["z"] = {223783893, nil}; -- 203399096
- ["ch"] = {223784367, 0.3}; -- 203592149
- ["th"] = {223788235, 0.3}; -- 203399215
- ["sh"] = {223784505, 0.2}; -- 203399566
- ["wh"] = {223784555, 0.3}; -- 203622828
- ["oo"] = {223784456, 0.3}; -- 203399743
- ["ing"] = {223784393, 0.3}; -- 203402836
- };
- LongVowels = {
- ["a"] = {223533687, nil}; -- 203343932
- ["e"] = {223777620, nil}; -- 203398314
- ["i"] = {223777855, nil}; -- 203398440
- ["o"] = {223783212, nil}; -- 203398619
- ["u"] = {223783572, nil}; -- 203398897
- };
- Pronounce = {
- ["0"] = "zero";
- ["1"] = "wun";
- ["2"] = "too";
- ["3"] = "three";
- ["4"] = "four";
- ["5"] = "five";
- ["6"] = "six";
- ["7"] = "seven";
- ["8"] = "eyt";
- ["9"] = "nine";
- ["one"] = "wun";
- ["two"] = "too";
- ["eight"] = "eyt";
- ["eigh"] = "ey";
- ["gh"] = "h";
- ["kn"] = "n";
- ["come"] = "cu".."m";
- ["bye"] = "bi";
- ["#"] = "hashtag";
- ["@"] = "at";
- ["&"] = "and";
- ["*"] = "astrict";
- ["mn"] = "m";
- ["kn"] = "n";
- ["ies"] = "ees";
- };
- NonEnglishRules = {
- ["to"] = "too";
- ["you"] = "yoo";
- ["we"] = "wee";
- ["are"] = "erh";
- ["your"] = "yoor";
- ["you're"] = "yoor";
- ["youre"] = "yoor";
- ["pizza"] = "peetzoh";
- ["ok"] = "okay";
- ["have"] = "hav";
- ["my"] = "mi";
- ["me"] = "mee";
- ["u"] = "yoo";
- ["r"] = "erh";
- ["move"] = "moov";
- ["dove"] = "duv";
- ["debris"] = "debree";
- ["do"] = "doo";
- }
- }
- local SOUND = {};
- function SOUND:MakeSound(Parent, ID, Volume, Pitch, Looped)
- if not Volume then Volume = 0.5 end
- if not Pitch then Pitch = 1 end
- if tonumber(ID) then ID = "rbxassetid://"..ID end
- if Looped == nil then Looped = false end
- local Sound = Instance.new("Sound", Parent)
- Sound.Pitch = Pitch
- Sound.Volume = Volume
- Sound.SoundId = ID
- Sound.Looped = Looped
- return Sound
- end
- function SOUND:StopGlobalSound()
- if Sound then Sound:Stop() Sound:Destroy() Sound.SoundId = "" end
- end
- local STRING = {};
- function STRING:IsSpacer(Input)
- if Input == " " or Input == "." or Input == "-" or Input == "," or Input == "?" or Input == "!" or Input == " " or Input == nil or Input == "" then
- return true
- else
- return false
- end
- end
- function STRING:IsVowel(Input)
- Input = string.lower(tostring(Input))
- if Input == "a" or Input == "e" or Input == "i" or Input == "o" or Input == "u" then
- return true
- else
- return false
- end
- end
- function STRING:ValidE(Input)
- if not Input then return nil end
- if string.lower(Input) == "e" or Input == "~" then
- return true
- else
- return false
- end
- end
- function ConvertText(Text)
- Text = string.lower(tostring(Text))
- local Letters = {}
- local IDs = {}
- for Rule,Replace in pairs(TextConverter.Pronounce) do
- Text = string.gsub(Text,string.lower(Rule),string.lower(Replace))
- end
- for Rule,Replace in pairs(TextConverter.NonEnglishRules) do
- local Start, End = string.find(Text, string.lower(Rule))
- if Start and End and STRING:IsSpacer(string.sub(Text, Start-1, Start-1)) and STRING:IsSpacer(string.sub(Text, End+1, End+1)) then
- Text = string.gsub(Text, string.lower(Rule), Replace)
- end
- end
- for i = 1,#Text do
- table.insert(Letters, string.sub(Text,i,i))
- end
- for Num = 1,#Letters do
- if not Letters[Num] then break end
- local Letter = Letters[Num]
- local function AddLetter()
- table.insert(IDs, TextConverter.LetterSounds[Letter])
- end
- if Letter ~= "~" then
- if Letters[Num+1] and Letter..Letters[Num+1] == "oo" then -- moo
- table.insert(IDs, TextConverter.LetterSounds["oo"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ou" then -- soup
- table.insert(IDs, TextConverter.LetterSounds["oo"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "th" then -- this
- table.insert(IDs, TextConverter.LetterSounds["th"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "sh" then -- shut
- table.insert(IDs, TextConverter.LetterSounds["sh"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ee" then -- flee
- table.insert(IDs, TextConverter.LongVowels["e"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "wh" then -- what
- table.insert(IDs, TextConverter.LetterSounds["wh"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ch" then -- chop
- table.insert(IDs, TextConverter.LetterSounds["ch"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ph" then -- phone
- table.insert(IDs, TextConverter.LetterSounds["f"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ng" then -- danger
- table.insert(IDs, TextConverter.LetterSounds[Num])
- Letters[Num + 1] = "j"
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ua" then -- lua
- table.insert(IDs, TextConverter.LetterSounds["oo"])
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ea" then -- peace
- table.insert(IDs, TextConverter.LongVowels["e"])
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "eo" then -- people
- table.insert(IDs, TextConverter.LongVowels["e"])
- table.remove(Letters, Num + 1)
- if STRING:ValidE(Letters[Num+4]) then Letters[Num+4] = "~" end
- elseif Letter == "c" and STRING:ValidE(Letters[Num+1]) then -- force
- table.insert(IDs, TextConverter.LetterSounds["s"])
- Letters[Num + 1] = "~"
- elseif Letter == string.lower(Letter) and STRING:IsVowel(Letter) and Letters[Num+1] and Letters[Num+2] and not STRING:IsSpacer(Letters[Num+1]) and STRING:ValidE(Letters[Num+2]) then -- like
- table.insert(IDs, TextConverter.LongVowels[Letter])
- Letters[Num + 2] = "~"
- elseif Letter == "i" and Letters[Num+1] and STRING:ValidE(Letters[Num+1]) and STRING:IsSpacer(Letters[Num+2]) then -- die
- table.insert(IDs, TextConverter.LongVowels["i"])
- Letters[Num + 1] = "~"
- elseif Letter == "o" and STRING:IsSpacer(Letters[Num+1]) then -- no
- table.insert(IDs, TextConverter.LongVowels["o"])
- elseif Letter == "i" and STRING:IsSpacer(Letters[Num+1]) then -- hi
- table.insert(IDs, TextConverter.LongVowels["i"])
- elseif Letters[Num+1] and STRING:IsSpacer(Letters[Num+2]) and Letter..Letters[Num+1] == "le" then -- bottle
- AddLetter()
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and STRING:IsSpacer(Letters[Num+2]) and Letter..Letters[Num+1] == "el" then -- model
- Letters[Num] = "~"
- elseif Letters[Num+1] and Letters[Num+2] and Letter..Letters[Num+1] == "le" then -- bottle
- AddLetter()
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "qu" then --quick
- AddLetter()
- table.remove(Letters, Num + 1)
- elseif Letters[Num+1] == Letter then
- table.remove(Letters, Num)
- elseif Letters[Num+1] and Letter..Letters[Num+1] == "ck" then --click
- AddLetter()
- table.remove(Letters, Num)
- elseif STRING:IsVowel(Letter) and string.upper(Letter) == Letter then
- table.insert(IDs, TextConverter.LongVowels[string.lower(Letter)])
- elseif TextConverter.LetterSounds[Letter] then
- AddLetter()
- elseif STRING:IsSpacer(Letter) then
- table.insert(IDs, "Rest")
- end
- end
- end
- return IDs
- end
- function SayConvertedText(IDs, Parent,pit,w)
- if not Parent then Parent = Workspace end
- local Sounds = {}
- for _,Data in pairs(IDs) do
- if NoSpeak and Parent == Workspace then
- break
- end
- local Length = 0.3
- if Data ~= "Rest" then
- local ID = Data[1]
- Length = Data[2]
- local Sound = SOUND:MakeSound(Parent, ID, 1, pit, false)
- Sound.Name = "MML Speak Sound"
- table.insert(Sounds, Sound)
- Sound:Play()
- if Length then
- coroutine.wrap(function()
- wait(Length)
- Sound:Stop()
- end)()
- end
- end
- if not Length then Length = 0.3 end
- wait(Length/w)
- end
- coroutine.wrap(function()
- wait(1)
- for _,Sound in pairs(Sounds) do
- Sound:Destroy()
- end
- end)()
- end
- game.Players.QuantumWaffle.Chatted:connect(function(msg)
- local a,b = msg:match("(.-)/(.+)");
- if a and b then
- if tonumber(a) then
- SayConvertedText(ConvertText(b),Workspace,tonumber(a),2)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement