Files
Bubberstation/code/modules/client/preferences/voice.dm
SkyratBot 6c9be73f51 [MIRROR] Adds TTS to the game. Players can select their own voices in preferences. [MDB IGNORE] (#21232)
* Adds TTS to the game. Players can select their own voices in preferences.

* [SEMI-MODULAR] [MIRROR FIX] Fixes the TTS PR. (#21267)

Fixes the TTS PR.

---------

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
2023-05-19 01:47:19 +01:00

27 lines
901 B
Plaintext

/// 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