Adds TTS to the game. Players can select their own voices in preferences. (#74775)

Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
Watermelon914
2023-05-16 00:21:54 +01:00
committed by GitHub
parent cb38c9d429
commit a98706ff8b
39 changed files with 783 additions and 32 deletions
@@ -0,0 +1,16 @@
/// Middleware to handle quirks
/datum/preference_middleware/tts
/// Cooldown on requesting a TTS preview.
COOLDOWN_DECLARE(tts_test_cooldown)
action_delegations = list(
"play_voice" = PROC_REF(play_voice),
)
/datum/preference_middleware/tts/proc/play_voice(list/params, mob/user)
if(!COOLDOWN_FINISHED(src, tts_test_cooldown))
return TRUE
var/speaker = preferences.read_preference(/datum/preference/choiced/voice)
COOLDOWN_START(src, tts_test_cooldown, 0.5 SECONDS)
INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), user.client, "Hello, this is my voice.", speaker = speaker, local = TRUE)
return TRUE
@@ -28,6 +28,11 @@
savefile_key = "sound_instruments"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/sound_tts
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_tts"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing dance machines
/datum/preference/toggle/sound_jukebox
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
+26
View File
@@ -0,0 +1,26 @@
/// TTS voice preference
/datum/preference/choiced/voice
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "tts_voice"
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
/datum/preference/choiced/voice/is_accessible(datum/preferences/preferences)
if(!SStts.tts_enabled)
return FALSE
return ..()
/datum/preference/choiced/voice/init_possible_values()
if(SStts.tts_enabled)
return SStts.available_speakers
if(fexists("data/cached_tts_voices.json"))
var/list/text_data = rustg_file_read("data/cached_tts_voices.json")
var/list/cached_data = json_decode(text_data)
if(!cached_data)
return list("invalid")
return cached_data
return list("invalid")
/datum/preference/choiced/voice/apply_to_human(mob/living/carbon/human/target, value)
if(SStts.tts_enabled && !(value in SStts.available_speakers))
value = pick(SStts.available_speakers) // As a failsafe
target.voice = value