diff --git a/code/controllers/subsystem/tts.dm b/code/controllers/subsystem/tts.dm index 12d904af246..795c8876b15 100644 --- a/code/controllers/subsystem/tts.dm +++ b/code/controllers/subsystem/tts.dm @@ -311,6 +311,24 @@ SUBSYSTEM_DEF(tts) else queued_http_messages.insert(current_request) +/// Helper to get a random TTS voice for a certain gender. Passing no gender just results in a random voice. +/datum/controller/subsystem/tts/proc/random_tts_voice(gender = NEUTER) + if(!tts_enabled) + return null + + var/sanity = 0 + while(sanity < 10) + var/voice = pick(available_speakers) + if(gender != MALE && gender != FEMALE) + return voice + if(gender == MALE && findtext(voice, "Man")) + return voice + if(gender == FEMALE && findtext(voice, "Woman")) + return voice + sanity += 1 + + return pick(available_speakers) // failsafe + /// A struct containing information on an individual player or mob who has made a TTS request /datum/tts_request /// The mob to play this TTS message on diff --git a/code/modules/admin/create_mob.dm b/code/modules/admin/create_mob.dm index 51ae7dfd0bc..810abe25f27 100644 --- a/code/modules/admin/create_mob.dm +++ b/code/modules/admin/create_mob.dm @@ -30,6 +30,7 @@ human.physique = human.gender human.real_name = human.generate_random_mob_name() human.name = human.get_visible_name() + human.voice = SStts.random_tts_voice(human.gender) human.set_eye_color(random_eye_color()) human.skin_tone = pick(GLOB.skin_tones) // No underwear generation handled here diff --git a/code/modules/client/preferences/voice.dm b/code/modules/client/preferences/voice.dm index 3ebf77aa7f5..b36f6478987 100644 --- a/code/modules/client/preferences/voice.dm +++ b/code/modules/client/preferences/voice.dm @@ -3,6 +3,7 @@ savefile_identifier = PREFERENCE_CHARACTER savefile_key = "tts_voice" category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + priority = PREFERENCE_PRIORITY_BODY_TYPE should_update_preview = FALSE /datum/preference/choiced/voice/is_accessible(datum/preferences/preferences) @@ -23,7 +24,7 @@ /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 + value = SStts.random_tts_voice(target.gender) // As a failsafe target.voice = value /datum/preference/numeric/tts_voice_pitch diff --git a/code/modules/fishing/fishing_equipment.dm b/code/modules/fishing/fishing_equipment.dm index ca39a09ca3b..d41ffa69c58 100644 --- a/code/modules/fishing/fishing_equipment.dm +++ b/code/modules/fishing/fishing_equipment.dm @@ -383,9 +383,7 @@ . = ..() ADD_TRAIT(src, TRAIT_CONTRABAND, INNATE_TRAIT) register_context() - - if(SStts.tts_enabled) //This capsule informs you on why it cannot be deployed in a sliiiiightly different way. - voice = pick(SStts.available_speakers) + voice = SStts.random_tts_voice() /obj/item/survivalcapsule/fishing/add_context(atom/source, list/context, obj/item/held_item, mob/user) if(!held_item || held_item == src) diff --git a/code/modules/mob/living/basic/pets/parrot/poly.dm b/code/modules/mob/living/basic/pets/parrot/poly.dm index f79df7e8dec..88885ad8861 100644 --- a/code/modules/mob/living/basic/pets/parrot/poly.dm +++ b/code/modules/mob/living/basic/pets/parrot/poly.dm @@ -42,7 +42,7 @@ if(!SStts.tts_enabled) return - voice = pick(SStts.available_speakers) + voice = SStts.random_tts_voice() if(SStts.pitch_enabled) if(findtext(voice, "Woman")) pitch = 12 // up-pitch by one octave diff --git a/code/modules/mob/living/carbon/human/login.dm b/code/modules/mob/living/carbon/human/login.dm index 9b3e23a3786..0dc1bb20ab9 100644 --- a/code/modules/mob/living/carbon/human/login.dm +++ b/code/modules/mob/living/carbon/human/login.dm @@ -4,7 +4,7 @@ dna?.species?.on_owner_login(src) if(SStts.tts_enabled && !voice) - voice = pick(SStts.available_speakers) + voice = SStts.random_tts_voice(gender) if(!LAZYLEN(afk_thefts)) return diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 789dc1ef1d8..240ddabf39d 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -53,8 +53,7 @@ /mob/living/silicon/Initialize(mapload) . = ..() - if(SStts.tts_enabled) - voice = pick(SStts.available_speakers) + voice = SStts.random_tts_voice() GLOB.silicon_mobs += src add_faction(FACTION_SILICON) if(ispath(radio)) diff --git a/code/modules/vending/vendor/_vending.dm b/code/modules/vending/vendor/_vending.dm index cf51b6eb291..b8ec1a43cea 100644 --- a/code/modules/vending/vendor/_vending.dm +++ b/code/modules/vending/vendor/_vending.dm @@ -213,9 +213,8 @@ set_wires(new /datum/wires/vending(src)) if(SStts.tts_enabled) - var/static/vendor_voice_by_type = list() - if(!vendor_voice_by_type[type]) - vendor_voice_by_type[type] = pick(SStts.available_speakers) + var/static/list/vendor_voice_by_type = list() + vendor_voice_by_type[type] ||= SStts.random_tts_voice() voice = vendor_voice_by_type[type] slogan_list = splittext(product_slogans, ";")