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

Tweak: TTS core actualization #437

Merged
merged 5 commits into from
Oct 19, 2023
Merged
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: 9 additions & 8 deletions modular_ss220/text_to_speech/code/tts_subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,18 @@ SUBSYSTEM_DEF(tts220)
if(traits & TTS_TRAIT_PITCH_WHISPER)
text = provider.pitch_whisper(text)

var/hash = rustg_hash_string(RUSTG_HASH_MD5, text)
var/hash = rustg_hash_string(RUSTG_HASH_MD5, lowertext(text))
dj-34 marked this conversation as resolved.
Show resolved Hide resolved
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)

if(fexists("[filename].ogg"))
tts_reused++
tts_rrps_counter++
play_tts(speaker, listener, filename, is_local, effect, preSFX, postSFX)
return

var/datum/callback/play_tts_cb = CALLBACK(src, PROC_REF(play_tts), speaker, listener, filename, is_local, effect, preSFX, postSFX)

if(LAZYLEN(tts_queue[filename]))
tts_reused++
tts_rrps_counter++
Expand All @@ -306,14 +307,14 @@ SUBSYSTEM_DEF(tts220)
// Bail if it errored
if(response.errored)
provider.timed_out_requests++
message_admins("<span class='warning'>Error connecting to [provider.name] TTS API. Please inform a maintainer or server host.</span>")
log_game(span_warning("Error connecting to [provider.name] TTS API. Please inform a maintainer or server host."))
message_admins(span_warning("Error connecting to [provider.name] TTS API. Please inform a maintainer or server host."))
return

if(response.status_code != 200)
provider.failed_requests++
if(provider.failed_requests >= provider.failed_requests_limit)
provider.is_enabled = FALSE
message_admins("<span class='warning'>Error performing [provider.name] TTS API request (Code: [response.status_code])</span>")
log_game(span_warning("Error performing [provider.name] TTS API request (Code: [response.status_code])"))
message_admins(span_warning("Error performing [provider.name] TTS API request (Code: [response.status_code])"))
tts_request_failed++
if(response.status_code)
if(tts_errors["[response.status_code]"])
Expand Down Expand Up @@ -408,7 +409,7 @@ SUBSYSTEM_DEF(tts220)
if(preSFX)
play_sfx(listener, preSFX, output.channel, output.volume, output.environment)

listener.playsound_local(turf_source, output, volume, S = output, channel = channel, wait = TRUE)
output = listener.playsound_local(turf_source, output, volume, S = output, channel = channel, wait = TRUE)

if(!output || output.volume <= 0)
return
Expand Down Expand Up @@ -458,7 +459,7 @@ SUBSYSTEM_DEF(tts220)
/datum/controller/subsystem/tts220/proc/sanitize_tts_input(message)
var/hash
if(sanitized_messages_caching)
hash = rustg_hash_string(RUSTG_HASH_MD5, message)
hash = rustg_hash_string(RUSTG_HASH_MD5, lowertext(message))
if(sanitized_messages_cache[hash])
sanitized_messages_cache_hit++
return sanitized_messages_cache[hash]
Expand Down
Loading