mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 12:05:59 +01:00
Adds a tts filter to the squid tongue (#93980)
## About The Pull Request A while ago I had a thought that adding a certain voice filter to the squid tongue would be a funny change. Goofball never got around to testing the specific filter parameters I'm using, so I'm going "fuck it, we ball" with the filter in its current iteration. ## Why It's Good For The Game A thematically-fitting tts filter for a tongue that didn't but could reasonably be given one.
This commit is contained in:
@@ -2,3 +2,9 @@
|
||||
// Only allow alphanumeric characters and whitespace
|
||||
var/static/regex/bad_chars_regex = regex("\[^a-zA-Z0-9 ,?.!'&-]", "g")
|
||||
return bad_chars_regex.Replace(text, " ")
|
||||
|
||||
/proc/tts_filter_encode(text, atom/movable/speaker, blips)
|
||||
text = replacetext(text, "%PITCH%", SStts.pitch_enabled ? speaker.pitch : 0)
|
||||
text = replacetext(text, "%FEMALE%", !!findtext(speaker.voice, "Woman"))
|
||||
text = replacetext(text, "%BLIPS%", blips)
|
||||
return url_encode(text)
|
||||
|
||||
@@ -297,8 +297,8 @@ SUBSYSTEM_DEF(tts)
|
||||
var/datum/http_request/request_blips = new()
|
||||
var/file_name = "tmp/tts/[identifier].ogg"
|
||||
var/file_name_blips = "tmp/tts/[identifier]_blips.ogg"
|
||||
request.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/tts_http_url)]/tts?voice=[speaker]&identifier=[identifier]&filter=[url_encode(filter)]&pitch=[pitch]&special_filters=[url_encode(special_filters)]", json_encode(list("text" = shell_scrubbed_input)), headers, file_name, timeout_seconds = CONFIG_GET(number/tts_http_timeout_seconds))
|
||||
request_blips.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/tts_http_url)]/tts-blips?voice=[speaker]&identifier=[identifier]&filter=[url_encode(filter)]&pitch=[pitch]&special_filters=[url_encode(special_filters)]", json_encode(list("text" = shell_scrubbed_input)), headers, file_name_blips, timeout_seconds = CONFIG_GET(number/tts_http_timeout_seconds))
|
||||
request.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/tts_http_url)]/tts?voice=[speaker]&identifier=[identifier]&filter=[tts_filter_encode(filter, speaker)]&pitch=[pitch]&special_filters=[url_encode(special_filters)]", json_encode(list("text" = shell_scrubbed_input)), headers, file_name, timeout_seconds = CONFIG_GET(number/tts_http_timeout_seconds))
|
||||
request_blips.prepare(RUSTG_HTTP_METHOD_GET, "[CONFIG_GET(string/tts_http_url)]/tts-blips?voice=[speaker]&identifier=[identifier]&filter=[tts_filter_encode(filter, speaker, blips = TRUE)]&pitch=[pitch]&special_filters=[url_encode(special_filters)]", json_encode(list("text" = shell_scrubbed_input)), headers, file_name_blips, timeout_seconds = CONFIG_GET(number/tts_http_timeout_seconds))
|
||||
var/datum/tts_request/current_request = new /datum/tts_request(identifier, request, request_blips, shell_scrubbed_input, target, local, language, message_range, volume_offset, listeners, pitch)
|
||||
var/list/player_queued_tts_messages = queued_tts_messages[target]
|
||||
if(!player_queued_tts_messages)
|
||||
|
||||
@@ -467,6 +467,37 @@
|
||||
icon = 'icons/obj/medical/organs/infuser_organs.dmi'
|
||||
icon_state = "inky_tongue"
|
||||
actions_types = list(/datum/action/cooldown/ink_spit)
|
||||
/**
|
||||
* This is probably the most complex tts filter that won't require external files to be added to the tts image.
|
||||
* It works as follows:
|
||||
* 1. Increase the pitch of the input audio. Pitch increase is lower for higher speaker pitch and vice-versa.
|
||||
* 2. Apply a mid-heavy EQ curve.
|
||||
* 3. Using an oscillating target frequency:
|
||||
* - Apply a low pass filter with its cutoff at the target frequency
|
||||
* - Boost frequencies very close to the target frequency
|
||||
*/
|
||||
voice_filter = "\
|
||||
rubberband=pitch='\
|
||||
ifnot(%BLIPS%,\
|
||||
2-(%PITCH%+if(%FEMALE%,4))/16\
|
||||
,1)'\
|
||||
:formant=preserved,\
|
||||
highpass=f=1000:t=s:w=24,\
|
||||
equalizer=f=1200:g=15,\
|
||||
equalizer=f=4350:g=-15,\
|
||||
highshelf=f=870:g=1,\
|
||||
afftfilt=\
|
||||
real='\
|
||||
st(0,(b+0.5)/nb*sr);\
|
||||
st(1,3000+1500*sin(9.3*2*PI*pts));\
|
||||
st(2,ld(0)/ld(1));\
|
||||
re*(1-ld(2)^2+2*gauss(log(ld(2)+1)))'\
|
||||
:imag='\
|
||||
st(0,(b+0.5)/nb*sr);\
|
||||
st(1,3000+1500*sin(9.3*2*PI*pts));\
|
||||
st(2,ld(0)/ld(1));\
|
||||
im*(1-ld(2)^2+2*gauss(log(ld(2)+1)))'\
|
||||
:win_size=1024"
|
||||
|
||||
// Seafood instead of meat, because it's a fish organ
|
||||
foodtype_flags = RAW | SEAFOOD | GORE
|
||||
|
||||
Reference in New Issue
Block a user