Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref: rustg220 #254

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions modular_ss220/text_to_speech/code/rust_g_ss220.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,10 @@
#endif

/// Gets the version of rust_g
/proc/rustgss220_get_version() return RUSTG_CALL(RUST_G_SS220, "get_version")()
/proc/rustg_ss220_get_version() return RUSTG_CALL(RUST_G_SS220, "get_version")()

#define rustgss220_file_write_b64decode(text, fname) RUSTG_CALL(RUST_G_SS220, "file_write")(text, fname, "true")

// Hashing Operations //
#define rustgss220_hash_string(algorithm, text) RUSTG_CALL(RUST_G_SS220, "hash_string")(algorithm, text)
#define rustgss220_hash_file(algorithm, fname) RUSTG_CALL(RUST_G_SS220, "hash_file")(algorithm, fname)


#ifdef RUSTG_OVERRIDE_BUILTINS
#define md5(thing) (isfile(thing) ? rustgss220_hash_file(RUSTG_HASH_MD5, "[thing]") : rustgss220_hash_string(RUSTG_HASH_MD5, thing))
#endif
#define rustg_ss220_file_write_b64decode(text, fname) RUSTG_CALL(RUST_G_SS220, "file_write")(text, fname, "true")

// Text Operations //
#define rustgss220_cyrillic_to_latin(text) RUSTG_CALL(RUST_G_SS220, "cyrillic_to_latin")("[text]")
#define rustgss220_latin_to_cyrillic(text) RUSTG_CALL(RUST_G_SS220, "latin_to_cyrillic")("[text]")
#define rustg_ss220_cyrillic_to_latin(text) RUSTG_CALL(RUST_G_SS220, "cyrillic_to_latin")("[text]")
#define rustg_ss220_latin_to_cyrillic(text) RUSTG_CALL(RUST_G_SS220, "latin_to_cyrillic")("[text]")
8 changes: 4 additions & 4 deletions modular_ss220/text_to_speech/code/tts_subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ SUBSYSTEM_DEF(tts220)
if(traits & TTS_TRAIT_PITCH_WHISPER)
text = provider.pitch_whisper(text)

var/hash = rustgss220_hash_string(RUSTG_HASH_MD5, text)
var/hash = rustg_hash_string(RUSTG_HASH_MD5, text)
var/filename = "data/tts_cache/[seed.name]/[hash]"

var/datum/callback/play_tts_cb = CALLBACK(src, PROC_REF(play_tts), speaker, listener, filename, is_local, effect, preSFX, postSFX)
Expand Down Expand Up @@ -330,7 +330,7 @@ SUBSYSTEM_DEF(tts220)
if(!voice)
return

rustgss220_file_write_b64decode(voice, "[filename].ogg")
rustg_ss220_file_write_b64decode(voice, "[filename].ogg")

if (!GLOB.configuration.tts.tts_cache_enabled)
addtimer(CALLBACK(src, PROC_REF(cleanup_tts_file), "[filename].ogg"), 30 SECONDS)
Expand Down Expand Up @@ -458,7 +458,7 @@ SUBSYSTEM_DEF(tts220)
/datum/controller/subsystem/tts220/proc/sanitize_tts_input(message)
var/hash
if(sanitized_messages_caching)
hash = rustgss220_hash_string(RUSTG_HASH_MD5, message)
hash = rustg_hash_string(RUSTG_HASH_MD5, message)
if(sanitized_messages_cache[hash])
sanitized_messages_cache_hit++
return sanitized_messages_cache[hash]
Expand All @@ -481,7 +481,7 @@ SUBSYSTEM_DEF(tts220)
. = replacetext(., words, /proc/tts_word_replacer)
for(var/job in tts_job_replacements)
. = replacetext(., regex(job, "igm"), tts_job_replacements[job])
. = rustgss220_latin_to_cyrillic(.)
. = rustg_ss220_latin_to_cyrillic(.)

var/static/regex/decimals = new(@"-?\d+\.\d+", "g")
. = replacetext(., decimals, /proc/dec_in_words)
Expand Down
14 changes: 3 additions & 11 deletions modular_ss220/text_to_speech/code/~undefs/~undefs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@
#undef TTS_TRAIT_RATE_FASTER
#undef TTS_TRAIT_RATE_MEDIUM

#undef rustgss220_file_write_b64decode

#undef rustgss220_hash_string
#undef rustgss220_hash_file


#ifdef RUSTG_OVERRIDE_BUILTINS
#undef md5
#endif
#undef rustg_ss220_file_write_b64decode

// Text Operations //
#undef rustgss220_cyrillic_to_latin
#undef rustgss220_latin_to_cyrillic
#undef rustg_ss220_cyrillic_to_latin
#undef rustg_ss220_latin_to_cyrillic

#undef TTS_CATEGORY_OTHER
#undef TTS_CATEGORY_WARCRAFT3
Expand Down