View difference between Paste ID: 5yMwv5iy and MpwUtMPY
SHOW: | | - or go back to the newest paste.
1
local TextConverter = {
2
	LetterSounds = {
3
		["a"] = {223757826, nil}; -- 203343899
4
		["b"] = {223533700, 0.2}; -- 203344029
5
		["c"] = {223533711, nil}; -- 203343994
6
		["d"] = {223757910, nil}; -- 203398237
7
		["e"] = {223758026, nil}; -- 203398295
8
		["f"] = {223777655, nil}; -- 203398347
9
		["g"] = {223777738, nil}; -- 203398372
10
		["h"] = {223777757, nil}; -- 203398397
11
		["i"] = {223777807, nil}; -- 203398422
12
		["j"] = {223782888, nil}; -- 203398450
13
		["k"] = {223533711, nil}; -- 203343994
14
		["l"] = {223782961, 0.4}; -- 203398541
15
		["m"] = {223782992, nil}; -- 203398578
16
		["n"] = {223783063, nil}; -- 203398599
17
		["o"] = {223783184, nil}; -- 203398611
18
		["p"] = {223783235, nil}; -- 203398727
19
		["q"] = {223783260, nil}; -- 203398755
20
		["r"] = {223783305, 0.2}; -- 203398792
21
		["s"] = {223783377, nil}; -- 203398806
22
		["t"] = {223783446, nil}; -- 203398850
23
		["u"] = {223783512, nil}; -- 203398872
24
		["v"] = {223783654, nil}; -- 203398965
25
		["w"] = {223783697, nil}; -- 203398984
26
		["x"] = {223783796, nil}; -- 203399008
27
		["y"] = {223783853, nil}; -- 203399043
28
		["z"] = {223783893, nil}; -- 203399096
29
		
30
		["ch"] = {223784367, 0.3}; -- 203592149
31
		["th"] = {223788235, 0.3}; -- 203399215
32
		["sh"] = {223784505, 0.2}; -- 203399566
33
		["wh"] = {223784555, 0.3}; -- 203622828
34
		["oo"] = {223784456, 0.3}; -- 203399743
35
		["ing"] = {223784393, 0.3}; -- 203402836
36
	};
37
	
38
	LongVowels = {
39
		["a"] = {223533687, nil}; -- 203343932
40
		["e"] = {223777620, nil}; -- 203398314
41
		["i"] = {223777855, nil}; -- 203398440
42
		["o"] = {223783212, nil}; -- 203398619
43
		["u"] = {223783572, nil}; -- 203398897
44
	};
45
	
46
	Pronounce = {
47
		["0"] = "zero";
48
		["1"] = "wun";
49
		["2"] = "too";
50
		["3"] = "three";
51
		["4"] = "four";
52
		["5"] = "five";
53
		["6"] = "six";
54
		["7"] = "seven";
55
		["8"] = "eyt";
56
		["9"] = "nine";
57
		["one"] = "wun";
58
		["two"] = "too";
59
		["eight"] = "eyt";
60
		["eigh"] = "ey";
61
		["gh"] = "h";
62
		["kn"] = "n";
63
		["come"] = "cu".."m";
64
		["bye"] = "bi";
65
		["#"] = "hashtag";
66
		["@"] = "at";
67
		["&"] = "and";
68
		["*"] = "astrict";
69
		["mn"] = "m";
70
		["kn"] = "n";
71
		["ies"] = "ees";
72
	};
73
	
74
	NonEnglishRules = {
75
		["to"] = "too";
76
		["you"] = "yoo";
77
		["we"] = "wee";
78
		["are"] = "erh";
79
		["your"] = "yoor";
80
		["you're"] = "yoor";
81
		["youre"] = "yoor";
82
		["pizza"] = "peetzoh";
83
		["ok"] = "okay";
84
		["have"] = "hav";
85
		["my"] = "mi";
86
		["me"] = "mee";
87
		["u"] = "yoo";
88
		["r"] = "erh";
89
		["move"] = "moov";
90
		["dove"] = "duv";
91
		["debris"] = "debree";
92
		["do"] = "doo";
93
	}
94
}
95
96
local SOUND = {};
97
function SOUND:MakeSound(Parent, ID, Volume, Pitch, Looped)
98
	if not Volume then Volume = 0.5 end
99
	if not Pitch then Pitch = 1 end
100
	if tonumber(ID) then ID = "rbxassetid://"..ID end
101
	if Looped == nil then Looped = false end
102
	
103
	local Sound = Instance.new("Sound", Parent)
104
	Sound.Pitch = Pitch
105
	Sound.Volume = Volume
106
	Sound.SoundId = ID
107
	Sound.Looped = Looped
108
	return Sound
109
end
110
111
function SOUND:StopGlobalSound()
112
	if Sound then Sound:Stop() Sound:Destroy() Sound.SoundId = "" end
113
end
114
115
local STRING = {};
116
function STRING:IsSpacer(Input)
117
	if Input == " " or Input == "." or Input == "-" or Input == "," or Input == "?" or Input == "!" or Input == "	" or Input == nil or Input == "" then
118
		return true
119
	else
120
		return false
121
	end
122
end
123
124
function STRING:IsVowel(Input)
125
	Input = string.lower(tostring(Input))
126
	if Input == "a" or Input == "e" or Input == "i" or Input == "o" or Input == "u" then
127
		return true
128
	else
129
		return false
130
	end
131
end
132
133
function STRING:ValidE(Input)
134
	if not Input then return nil end
135
	if string.lower(Input) == "e" or Input == "~" then
136
		return true
137
	else
138
		return false
139
	end
140
end
141
142
143
144
145
function ConvertText(Text)
146
	Text = string.lower(tostring(Text))
147
	local Letters = {}
148
	local IDs = {}
149
	for Rule,Replace in pairs(TextConverter.Pronounce) do
150
		Text = string.gsub(Text,string.lower(Rule),string.lower(Replace))
151
	end
152
	for Rule,Replace in pairs(TextConverter.NonEnglishRules) do
153
		local Start, End = string.find(Text, string.lower(Rule))
154
		
155
		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
156
			Text = string.gsub(Text, string.lower(Rule), Replace)
157
		end
158
	end
159
	for i = 1,#Text do
160
		table.insert(Letters, string.sub(Text,i,i))
161
	end
162
	for Num = 1,#Letters do
163
		if not Letters[Num] then break end
164
		local Letter = Letters[Num]
165
		
166
		local function AddLetter()
167
			table.insert(IDs, TextConverter.LetterSounds[Letter])
168
		end
169
		
170
		if Letter ~= "~" then
171
			if Letters[Num+1] and Letter..Letters[Num+1] == "oo" then -- moo
172
				table.insert(IDs, TextConverter.LetterSounds["oo"])
173
				table.remove(Letters, Num + 1)
174
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ou" then -- soup
175
				table.insert(IDs, TextConverter.LetterSounds["oo"])
176
				table.remove(Letters, Num + 1)
177
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "th" then -- this
178
				table.insert(IDs, TextConverter.LetterSounds["th"])
179
				table.remove(Letters, Num + 1)
180
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "sh" then -- shut
181
				table.insert(IDs, TextConverter.LetterSounds["sh"])
182
				table.remove(Letters, Num + 1)
183
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ee" then -- flee
184
				table.insert(IDs, TextConverter.LongVowels["e"])
185
				table.remove(Letters, Num + 1)
186
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "wh" then -- what
187
				table.insert(IDs, TextConverter.LetterSounds["wh"])
188
				table.remove(Letters, Num + 1)
189
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ch" then -- chop
190
				table.insert(IDs, TextConverter.LetterSounds["ch"])
191
				table.remove(Letters, Num + 1)
192
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ph" then -- phone
193
				table.insert(IDs, TextConverter.LetterSounds["f"])
194
				table.remove(Letters, Num + 1)
195
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ng" then -- danger
196
				table.insert(IDs, TextConverter.LetterSounds[Num])
197
				Letters[Num + 1] = "j"
198
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ua" then -- lua
199
				table.insert(IDs, TextConverter.LetterSounds["oo"])
200
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ea" then -- peace
201
				table.insert(IDs, TextConverter.LongVowels["e"])
202
				table.remove(Letters, Num + 1)
203
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "eo" then -- people
204
				table.insert(IDs, TextConverter.LongVowels["e"])
205
				table.remove(Letters, Num + 1)
206
				if STRING:ValidE(Letters[Num+4]) then Letters[Num+4] = "~" end
207
			elseif Letter == "c" and STRING:ValidE(Letters[Num+1]) then -- force
208
				table.insert(IDs, TextConverter.LetterSounds["s"])
209
				Letters[Num + 1] = "~"
210
			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
211
				table.insert(IDs, TextConverter.LongVowels[Letter])
212
				Letters[Num + 2] = "~"
213
			elseif Letter == "i" and Letters[Num+1] and STRING:ValidE(Letters[Num+1]) and STRING:IsSpacer(Letters[Num+2]) then -- die
214
				table.insert(IDs, TextConverter.LongVowels["i"])
215
				Letters[Num + 1] = "~"
216
			elseif Letter == "o" and STRING:IsSpacer(Letters[Num+1]) then -- no
217
				table.insert(IDs, TextConverter.LongVowels["o"])
218
			elseif Letter == "i" and STRING:IsSpacer(Letters[Num+1]) then -- hi
219
				table.insert(IDs, TextConverter.LongVowels["i"])
220
			elseif Letters[Num+1] and STRING:IsSpacer(Letters[Num+2]) and Letter..Letters[Num+1] == "le" then -- bottle
221
				AddLetter()
222
				table.remove(Letters, Num + 1)
223
			elseif Letters[Num+1] and STRING:IsSpacer(Letters[Num+2]) and Letter..Letters[Num+1] == "el" then -- model
224
				Letters[Num] = "~"
225
			elseif Letters[Num+1] and Letters[Num+2] and Letter..Letters[Num+1] == "le" then -- bottle
226
				AddLetter()
227
				table.remove(Letters, Num + 1)
228
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "qu" then --quick
229
				AddLetter()
230
				table.remove(Letters, Num + 1)
231
			elseif Letters[Num+1] == Letter then
232
				table.remove(Letters, Num)
233
			elseif Letters[Num+1] and Letter..Letters[Num+1] == "ck" then --click
234
				AddLetter()
235
				table.remove(Letters, Num)
236
			elseif STRING:IsVowel(Letter) and string.upper(Letter) == Letter then
237
				table.insert(IDs, TextConverter.LongVowels[string.lower(Letter)])
238
			elseif TextConverter.LetterSounds[Letter] then
239
				AddLetter()
240
			elseif STRING:IsSpacer(Letter) then
241
				table.insert(IDs, "Rest")
242
			end
243
		end
244
	end
245
	
246
	return IDs
247
end
248
249
250
function SayConvertedText(IDs, Parent,pit,w)
251
	if not Parent then Parent = Workspace end
252
	local Sounds = {}
253
	for _,Data in pairs(IDs) do
254
		if NoSpeak and Parent == Workspace then
255
			break
256
		end
257
		local Length = 0.3
258
		if Data ~= "Rest" then
259
			local ID = Data[1]
260
			Length = Data[2]
261
			
262
			local Sound = SOUND:MakeSound(Parent, ID, 1, pit, false)
263
			Sound.Name = "MML Speak Sound"
264
			table.insert(Sounds, Sound)
265
			Sound:Play()
266
			if Length then
267
				coroutine.wrap(function()
268
					wait(Length)
269
					Sound:Stop()
270
				end)()
271
			end
272
		end
273
		if not Length then Length = 0.3 end
274
		wait(Length/w)
275
	end
276
	coroutine.wrap(function()
277
		wait(1)
278
		for _,Sound in pairs(Sounds) do
279
			Sound:Destroy()
280
		end
281
	end)()
282
end
283
284-
game.Players.DoogleFox.Chatted:connect(function(msg)
284+
game.Players.QuantumWaffle.Chatted:connect(function(msg)
285
   local a,b = msg:match("(.-)/(.+)");
286
   if a and b  then
287
      if tonumber(a) then
288
         SayConvertedText(ConvertText(b),Workspace,tonumber(a),2)
289
      end
290
   end
291
end)