-
Notifications
You must be signed in to change notification settings - Fork 0
/
tts.js
686 lines (589 loc) · 21.3 KB
/
tts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
'use strict'
// ```js
const TTSSystem = {
speakUtterance(u) {
return new Promise((yay, nay) => {
u.onend = e=>(e.charIndex < e.target.text.length) ? nay(e) : yay()
u.onerror = e=>nay(e)
speechSynthesis.speak(u)
})
},
playSound(s) {
return new Promise((yay, nay) => {
let se = s.elem
se.currentTime = 0
se.volume = ('number'==typeof s.volume) ? s.volume : 1.0
se.loop = false
let removeListeners = ()=>{ se.onpause = se.onerror = null }
se.onpause = e=>removeListeners((se.currentTime < se.duration) ? nay(e) : yay())
se.onerror = e=>removeListeners(nay(e))
se.play()
})
},
getMessageAuthorName(message) {
if (message.Author && message.Author.bridge)
return message.Author.nickname || message.values.b;
else
return message.Author.username;
},
getUserParam(message) {
let k; if (message.Author && message.Author.bridge)
k = message.Author.nickname || message.values.b
else
k = message.createUserId;
return Object.assign({}, this.userParams[0], this.userParams[k]);
},
getRoomSettings(room) {
return Object.assign({}, this.roomSettings[0], this.roomSettings[room]);
},
lastMessage: {
room: NaN,
user: NaN,
time: NaN,
},
speakString(message) {
let utter = new SpeechSynthesisUtterance(String(message));
let opts = this.userParams[0];
utter.voice = this.voiceFrom(opts.voice);
utter.volume = opts.volume;
utter.pitch = opts.pitch;
utter.rate = opts.rate;
this.speakUtteranceBatch([ utter ])
},
speakSound(elem) {
if (!(elem instanceof HTMLAudioElement))
elem = new Audio(elem);
this.speakUtteranceBatch([{ elem, volume: this.userParams[0].volume }])
return elem; // -> so you can cache stuff like placeholderSound
},
// need to refactor this Now..
batchFromMessage(message, merged = false) {
if ('object'!=typeof message) {
message = { text: String(message), values: { m: 'plaintext' } };
merged = true;
}
let tree = Markup.langs.parse(message.text, message.values.m);
let opts = this.getUserParam(message);
if (!merged) {
opts.nickname || (opts.nickname = this.getMessageAuthorName(message));
opts.msg || (opts.msg = `${opts.nickname} says; `);
}
return { batch: this.renderUtteranceBatch(tree, opts), tag: message.id };
},
speakMessage(message, merged = false) {
this.speakUtteranceBatch(this.batchFromMessage(message, merged))
},
queue: [],
currentBatch: null,
currentPart: null,
async speakUtteranceBatch(batch) {
this.queue.push(batch);
// it may already be speaking. if so, we've already done enough.
if (this.queue.length > 1 || this.currentBatch) return;
while (this.queue.length) {
try {
this.currentBatch = this.queue.shift()
for (let u of this.currentBatch.batch) {
this.currentPart = u
if (u instanceof SpeechSynthesisUtterance) await this.speakUtterance(u)
else if (u.elem instanceof HTMLAudioElement) await this.playSound(u)
}
} catch {} finally {
this.currentBatch = null
this.currentPart = null
}
}
},
currentNotify: null,
async notifySound(url) {
if (this.currentNotify)
this.currentNotify.pause();
let u = { volume: Math.max(0, Math.min(TTSSystem.userParams[0].volume, 1)) };
if (url instanceof HTMLAudioElement) u.elem = url;
else {
u.elem = this.notifyMediaCache[url]
|| (this.notifyMediaCache[url] = new Audio(url));
}
try {
this.currentNotify = u;
await this.playSound(u);
} catch {} finally {
this.currentNotify = null;
}
},
placeholderSound: null,
userParams: {
[0]: { // global user params
voice: null,
volume: 1,
pitch: 1,
rate: 1.25,
},
// regretting calling this "params"... should be userSettings maybe
},
// wait aren't user IDs and room IDs the same thing
roomSettings: {
[0]: { // global room settings
localAction: 'speak', // either 'none', 'speak', "<url to sound>", or HTMLAudioElement (last one intended only for at runtime)
globalAction: 'none', // guess.
},
},
// i mean it works.
notifyMediaCache: {},
_textReplacements: [],
clearReplacements() { this._textReplacements = []; },
replaceText(pattern, replacement, surround = true) {
if ('string' == typeof pattern) {
pattern = new RegExp(`\\b${TTSSystem.escapePattern(pattern)}\\b`, 'gi');
replacement = TTSSystem.escapeReplacement(replacement);
} else if (pattern instanceof RegExp && !pattern.flags && surround) {
pattern = new RegExp(`\\b${pattern.source}\\b`, 'gi');
}
this._textReplacements.push([pattern, replacement]);
},
escapePattern(p) { return p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); },
escapeReplacement(r) { return r.replace(/\$/g, '$$$$'); },
voiceFrom(name) {
return speechSynthesis.getVoices().find(v=>v.name.includes(name))
},
// creates a list of smaller utterances and media to play in sequence
renderUtteranceBatch(tree, opts = {}) {
opts.msg || (opts.msg = "")
if ('string'==typeof opts.voice)
opts.voice = this.voiceFrom(opts.voice)
opts.utter || (opts.utter = [])
opts.media || (opts.media = {})
let sound = url=>{
if (!url) return;
finalizeChunk()
let u = { volume: Math.max(0, Math.min(opts.volume, 1)) }
if (url instanceof HTMLAudioElement) u.elem = url;
else u.elem = opts.media[url] || (opts.media[url] = new Audio(url));
opts.utter.push(u)
return u;
}
let renderWithAltParams = (elem, {volume = 1, pitch = 1, rate = 1})=>{
let prev = [ opts.volume, opts.pitch, opts.rate ]
opts.volume *= volume; opts.pitch *= pitch; opts.rate *= rate
finalizeChunk()
this.renderUtteranceBatch(elem, opts)
finalizeChunk()
;[ opts.volume, opts.pitch, opts.rate ] = prev
}
// pushes utterance onto the end of the speech queue.
let finalizeChunk = ()=>{
opts.msg = opts.msg.trim()
if (!opts.msg.length) return;
let u = new SpeechSynthesisUtterance(opts.msg)
u.voice = opts.voice
u.volume = opts.volume
u.pitch = opts.pitch
u.rate = opts.rate
opts.utter.push(u)
opts.msg = ""
}
// goofy way to do things
function simplifyUrl(s) {
if (s.startsWith("sbs:") || s.includes("://qcs.s")) return "qcs"
if (s.includes("cdn.discordapp.com/")) return "discord"
if (s.includes("pbs.twimg.com/")) return "twitter"
if (s.includes(" ") && !s.includes(".")) return false // silly fake link heuristics
if (s.includes(" ") && s.includes(".") && s.indexOf(" ") < s.indexOf(".")) return false
if (s.startsWith('#')) return `anchor "${s.substring(1)}"`
else try { return new URL(s).hostname.replace("www.", "") }
catch { return "invalid URL" }
}
for (let elem of tree.content) {
if ('string'==typeof elem) {
this._textReplacements.forEach(([match, replace])=>{
elem = elem.replaceAll(match, replace)
});
opts.msg += elem
} else switch (elem.type) {
case 'italic': {
this.renderUtteranceBatch(elem, opts)
} break;case 'bold': {
this.renderUtteranceBatch(elem, opts)
} break;case 'strikethrough': {
renderWithAltParams(elem, { rate: 1.25, volume: 0.75 })
} break;case 'underline': {
this.renderUtteranceBatch(elem, opts)
} break;case 'video': {
opts.msg += `\nvideo from ${simplifyUrl(elem.args.url)}\n`
} break;case 'youtube': {
opts.msg += "\nyoutube video\n"
} break;case 'link': {
// depending on if they're labeled or unlabeled,
// i treat these as either inline or block respectively.
// inline being normal space pause, block being sentence break.
if (elem.content) {
this.renderUtteranceBatch(elem, opts)
opts.msg += " (link)"
} else {
opts.msg += elem.args.text ? ` ${elem.args.text} (link)` : `\nlink to ${simplifyUrl(elem.args.url)}\n`
}
} break;case 'simple_link': {
let url = simplifyUrl(elem.args.url)
if (!url) opts.msg += ` ${elem.args.url} (fake link)`
else opts.msg += elem.args.text ? ` ${elem.args.text} (link)` : `\nlink to ${url}\n`
} break;case 'image': { // pretty safe bet that all images are block elements
opts.msg += (elem.args.alt ? `\n${elem.args.alt} (image)` : `\nimage from ${simplifyUrl(elem.args.url)}`) + "\n"
} break;case 'audio': {
sound(elem.args.url)
// todo: time limite for audio?
} break;case 'code': {
opts.msg += "\ncode block"
if (elem.args.lang
&& elem.args.lang != 'none'
&& elem.args.lang != 'sb') // sign of the times...
opts.msg += ` written in ${elem.args.lang}`
opts.msg += "\n"
} break;case 'icode': {
opts.msg += elem.args.text
} break;case 'spoiler': {
opts.msg += "\nspoiler"
if (elem.args.label)
opts.msg += ` for ${elem.args.label}`
opts.msg += "\n"
} break;case 'heading': {
renderWithAltParams(elem, { rate: 0.75, volume: 1.25 })
} break;case 'subscript': case 'superscript': {
renderWithAltParams(elem, { volume: 0.75 })
} break;case 'quote': {
opts.msg += "\nquote"
if (elem.args.cite)
opts.msg += ` from ${elem.args.cite}`
opts.msg += "\n"
this.renderUtteranceBatch(elem, opts)
opts.msg += "\n(end quote)\n"
} break;case 'ruby': {
this.renderUtteranceBatch(elem, opts)
if (elem.args.text)
opts.msg += ` (${elem.args.text})`
} break;case 'bg':case 'key':case 'list':case 'anchor': {
this.renderUtteranceBatch(elem, opts)
} break;case 'list_item': {
this.renderUtteranceBatch(elem, opts)
opts.msg += "\n"
} break;case 'align': {
opts.msg += "\n"
this.renderUtteranceBatch(elem, opts)
opts.msg += "\n"
} break;case 'table_cell': {
this.renderUtteranceBatch(elem, opts)
opts.msg += "; "
} break;case 'divider': {
opts.msg += "\n"
} break;case 'table': {
let headers = elem.content[0]
headers = headers.content[0].args.header ? headers : false
if (!headers) opts.msg += "\ntable\n"
else {
opts.msg += "\ntable with headers: "
this.renderUtteranceBatch(headers, opts)
opts.msg += "\n"
}
} break;default: {
if (elem.content)
this.renderUtteranceBatch(elem, opts)
else {
// store loaded copy of placeholderSound for replaying later
this.placeholderSound = sound(this.placeholderSound).elem
console.log(`TTS renderer ignored ${elem.type}`)
}
}
}
}
// if we're root elem, we probably have unfinalized stuff.
// finalize it and return the utterance list.
if (tree.type == 'ROOT') {
finalizeChunk()
if (!opts.utter.length) {
opts.msg += 'nothing'
finalizeChunk()
}
return opts.utter
}
},
// skip current utterance
skip() {
speechSynthesis.cancel()
if (this.currentPart && this.currentPart.elem instanceof HTMLAudioElement)
this.currentPart.elem.pause()
},
// skip a tagged batch that matches the provided tag
skipTagged(tag) {
if (this.currentBatch && this.currentBatch.tag == tag) this.skip();
else this.queue = this.queue.filter(({t})=>tag!=t);
},
// replace one tagged batch with a lazily-evaluated batch.
// returns whether newBatch was used or not
replaceTagged(tag, newBatch) {
if (this.currentBatch && this.currentBatch.tag == tag) {
this.queue.unshift(newBatch());
this.skip();
return true;
} else {
let hits = 0;
for (let [i, b] of this.queue.entries()) {
if (b.tag != tag) continue;
this.queue[i] = newBatch();
hits++;
}
// if (!hits) this.speakUtteranceBatch(newBatch());
return hits > 0;
}
},
// cancel all utterances
cancel() {
this.queue = []
this.skip()
},
skipKey: {
_enabled: false,
key: 'Control',
enable(state = true) {
if (this._enabled == state) return
let toggle = `${state?'add':'remove'}EventListener`
document[toggle]('keydown', this.keydown)
document[toggle]('keyup', this.keyup)
window[toggle]('blur', this.windowBlur)
this._enabled = state
},
keydown(event) {
let k = TTSSystem.skipKey
if (event.key == k.key) {
if (!k.action) {
k.action = 'single'
} else {
k.action = 'double'
k.callback && (k.callback = clearTimeout(k.callback))
}
} else {
k.action = null
}
},
keyup(event) {
if (!document.hasFocus()) return;
let k = TTSSystem.skipKey
if (event.key == k.key) {
if (k.action == 'single') {
TTSSystem.skip()
k.callback = setTimeout(()=>k.action = null, 300)
} else if (k.action == 'double') {
TTSSystem.cancel()
k.action = null
}
}
},
windowBlur(_event) { TTSSystem.skipKey.action = null }
}
}
;(()=>{
Settings.add({
name: 'tts_notify', label: "TTS Notify", type: 'select',
options: ['no', 'quiet', 'everyone else', 'yes'],
})
Settings.add({
name: 'tts_volume', label: "TTS Volume", type: 'range',
range: [0.0, 1.0],
default: 0.5,
step: "0.05", //making this a string to /potentially/ bypass floating point
notches: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], // 🥴
update(value, type) {
TTSSystem.userParams[0].volume = value
if ('change'==type) {
TTSSystem.cancel()
if (TTSSystem.placeholderSound)
TTSSystem.speakMessage({text:"{#uwu",values:{m:'12y'}}, true)
else
TTSSystem.speakMessage("example message")
}
}
})
Settings.add({
name: 'tts_speed', label: "TTS Speed", type: 'range',
range: [0.5, 5], // (heard range may be narrower)
step: "0.05",
default: 1,
notches: [1],
update(value, type) {
TTSSystem.userParams[0].rate = value
if ('change'==type) {
TTSSystem.cancel()
TTSSystem.speakMessage("example message")
}
},
})
Settings.add({
name: 'tts_pitch', label: "TTS Pitch", type: 'range',
range: [0, 2],
step: "0.05",
default: 1,
notches: [1],
update(value, type) {
TTSSystem.userParams[0].pitch = value
if ('change'==type) {
TTSSystem.cancel()
TTSSystem.speakMessage("example message")
}
},
})
})()
Events.messages.listen(this, (c)=>{
let notifyMode = Settings.values.tts_notify;
if (notifyMode === 'no') return;
if (c.length > 3) c = c.slice(-3);
let currentRoom = View.current instanceof PageView ? View.current.page_id : NaN;
for (let message of c) {
// filter out your messages, if you asked to.
let fromYou = message.createUserId == Req.uid;
if (fromYou && notifyMode !== 'yes')
continue;
let roomSettings = TTSSystem.getRoomSettings(message.contentId);
let isLocal = message.contentId == currentRoom;
// if quiet mode enabled, just always use the global option
// (and yes, quiet mode also filters out your messages)
if (notifyMode === 'quiet')
isLocal = false;
let localNotNone = roomSettings.localAction !== 'none';
let action = ((isLocal && localNotNone) ? roomSettings.localAction : roomSettings.globalAction) || 'none';
if (action === 'none') {
continue;
} else if (action === 'speak') {
if (message.deleted) {
// pull message from queue (if still in there), to respect wishes.
TTSSystem.skipTagged(message.id);
continue;
}
let [ room, user, time ] = [
message.contentId,
message.createUserId,
new Date(message.createDate)
];
// "merge" messages from the same user, removing the "user says" part of the utterance.
let merge = TTSSystem.lastMessage.room == room
&& TTSSystem.lastMessage.user == user
&& Math.abs(time - TTSSystem.lastMessage.time) < 1000*60*3;
// save this information to check against later.
TTSSystem.lastMessage.room = room;
TTSSystem.lastMessage.user = user;
TTSSystem.lastMessage.time = time;
if (message.edited) {
let batch = ()=>TTSSystem.batchFromMessage(message, merge);
if (!TTSSystem.replaceTagged(message.id, batch)) {
// TODO: sound effects for unused replacement
}
continue;
}
TTSSystem.speakMessage(message, merge);
} else {
// sound effect
// skip if it's actually a deletion oops
if (message.deleted) continue;
TTSSystem.notifySound(action);
}
}
})
do_when_ready(()=>{
let userTabButtons = $sidebarUserPanel.querySelector('.registerBox');
let injectButton = document.createElement('button');
injectButton.onclick = ()=>TTSSystem.cancel();
injectButton.onmouseover = ()=>{
injectButton.title = `${TTSSystem.queue.length} messages in TTS queue`;
};
injectButton.textContent = "Stop TTS";
userTabButtons.appendChild(injectButton);
userTabButtons.appendChild($logOut);
})
/* ```
* Configuring the basics:
The script contributes a handful of settings, so just check the user tab of the 12 frontend.
It lists four options:
- 'no' - you won't hear TTS or notification sounds.
- 'quiet' - the global action for rooms will override the local action. good for if you only want to hear notification sounds.
- 'everyone else' - normal behavior, but you won't hear your own messages.
- 'yes' - normal behavior, and you will hear your own messages.
* Configuring beyond the basics:
If you insert snippets that modify `TTSSystem` into your UserJS, you can configure the TTS more:
- Add a placeholder sound
- simply assign a URL to `TTSSystem.placeholderSound`
- plays when volume adjusted in user tab
- plays whenever an unrecognized 12y tag is encountered
- Enable & configure the "skip key"
- `TTSSystem.skipKey.enable(true)` - sets up the event handlers and such
- `TTSSystem.skipKey.key` (by default is 'Control' - but can be any key)
- press it once to skip a single utterance
- press it twice (relatively) quickly to cancel all utterances
- Configure default voice
- `TTSSystem.userParams[0]` contains global TTS parameters, such as volume - all the stuff that you configure inside the user tab.
- `TTSSystem.userParams[0].voice = "Zira" `
- Create per-user TTS synthesizer parameter profiles
- two types of keys into `userParams`: (may change later)
- qcs user id (number)
- bridge name (string)
- and a parameter object includes these fields:
- `nickname` - a string that specifies how the TTS speaks the username
- `voice` - a string that matches (part of) a TTS voice
- `volume` - a number in [0, 1]. how loud the voice is
- `pitch` - a number in [0, 2]. the pitch of the voice
- `rate` - a number in [0.1, 10]. how fast the voice speaks
- `msg` - a string with the pre-message message (will override `nickname`'s effects)
- Change how text is pronounced with `replaceText`
- uses syntax from `String.prototype.replaceAll` (strings, regexes, functions; all available)
- `TTSSystem.replaceText(`{#sup{#sub pattern:}}`"V360",`{#sup{#sub replacement:}}`"v 3 60")`
- if pattern is a string, it'll be converted into a regex. you don't have to think about escaping or anything, it's all good.
- if pattern is a regex and it has no flags set (and the secret third "surround" flag isn't unset), it'll be surrounded with word boundaries and given flags and everything,
- it's recommended to do `TTSSystem.clearReplacements()` at the start of your siteJS so replacements don't accumulate while you try out new ones
- Create per-room rules for the TTS system
- by default, there's `TTSSystem.roomSettings[0] = { localAction: 'speak', globalAction: 'none' }`
- as you can see, both `localAction` and `globalAction` are enums (and they also slightly aren't..) here's the options you can use:
- `'speak'` - speak the message
- `'none'` - do nothing with the message
- if this is used as the local action, I'll use the global action instead. this makes sense probably
- `"`{/url to sound}`"` - play the sound when the message is received
- your messages will be unconditionally skipped if you have "TTS Notify" set to `'everyone else'`. if this sucks, tell me and i can change it lo
- sorry the official contentapi term is "pages", but uh.. i guess this is okay because it's chat focused, not content focused
** I want to apply one configuration to multiple keys!
```js
TTSSystem.userParams[123] = TTSSystem.userParams["bridge"] = { nickname: "bridge user" }
```
And if you ever want to get really wild, there's always `Object.assign`.
* Example UserJS:
```js
do_when_ready(()=>{
TTSSystem.placeholderSound = "https://raw.githubusercontent.com/TheV360/qcs-tts/main/meow.wav"
TTSSystem.skipKey.enable(true)
TTSSystem.userParams[0].voice = "Zira" // global voice
// string only has to match a little of the name
// userParams accepts either a user id or a bridge name as its key,
// and.. well there's the list of params demonstrated there:
TTSSystem.userParams[123] = { nickname: "qcs user" }
TTSSystem.userParams["bridge"] = {
nickname: "bridge user",
voice: "Zira",
volume: 1,
pitch: 1,
rate: 3.60
}
// play a funny sound any time something happens
let myFunnyNotifSound = "https://raw.githubusercontent.com/TheV360/qcs-tts/main/808cowbell.mp3"
TTSSystem.roomSettings[0] = { localAction: 'speak', globalAction: myFunnyNotifSound }
// room-specific stuff
let quietRoom = 'put the room id here'
let ignoreRoom = 'put the room id here'
let touhouRoom = 'i dont understand touhou and at this point im too afraid to ask'
TTSSystem.roomSettings[quietRoom] = { localAction: 'none' } // only plays notif sound even if active room
TTSSystem.roomSettings[ignoreRoom] = { localAction: 'none', globalAction: 'none' } // ignores room
TTSSystem.roomSettings[touhouRoom] = { globalAction: 'none' } // falls back to global setting if active room
TTSSystem.clearReplacements()
TTSSystem.replaceText("lol", "lawl")
TTSSystem.replaceText("idk", "i dunno")
TTSSystem.replaceText('nade', 'nah day')
TTSSystem.replaceText(/a{2,}/, "$&h")
TTSSystem.replaceText(/sona(s)?\b/gi, " so nuh$1")
})
```
```js
i love doing this. it's like shutting the door as you step outside..
*/// ```