From bef3b1dc977ad7d6c03806f5329e83ed57fd8567 Mon Sep 17 00:00:00 2001 From: TiviPlus <572233640+TiviPlus@users.noreply.com> Date: Fri, 8 Mar 2024 17:28:03 +0100 Subject: [PATCH 1/5] Announcements now use TTS --- code/datums/jobs/squads.dm | 9 +++++++++ .../xenomorph/castes/hivemind/hivemind.dm | 2 +- .../mob/living/carbon/xenomorph/hive_datum.dm | 6 ------ .../mob/living/carbon/xenomorph/say.dm | 19 ++++++++++++------- tools/tts/tts-api/Dockerfile | 2 ++ tools/tts/tts-api/tts-api.py | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/code/datums/jobs/squads.dm b/code/datums/jobs/squads.dm index b61225e7a5e9f..721008a703b5e 100644 --- a/code/datums/jobs/squads.dm +++ b/code/datums/jobs/squads.dm @@ -348,10 +348,14 @@ return "[nametext][text]" +GLOBAL_VAR_INIT(hailer_tts_filter, @{"[0:a] asetrate=%SAMPLE_RATE%*0.7,aresample=16000,atempo=1/0.7,lowshelf=g=-20:f=500,highpass=f=500,aphaser=in_gain=1:out_gain=1:delay=3.0:decay=0.4:speed=0.5:type=t [out]; [out]atempo=1.2,volume=15dB [final]; anoisesrc=a=0.01:d=60 [noise]; [final][noise] amix=duration=shortest"}) + /datum/squad/proc/message_squad(message, mob/living/carbon/human/sender) if(is_ic_filtered(message) || NON_ASCII_CHECK(message)) to_chat(sender, span_boldnotice("Message invalid. Check your message does not contain filtered words or characters.")) return + var/list/treated_message = sender.treat_message(message) + message = treated_message["message"] var/header = "AUTOMATED CIC NOTICE:" if(sender) @@ -359,6 +363,11 @@ for(var/mob/living/marine AS in marines_list) marine.play_screen_text("[header]
" + message, /atom/movable/screen/text/screen_text/command_order) + if(sender.voice && SStts.tts_enabled) + var/list/extra_filters = list(TTS_FILTER_RADIO) + if(isrobot(sender)) + extra_filters += TTS_FILTER_SILICON + INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), sender, treated_message["tts_message"], sender.get_default_language(), sender.voice, GLOB.hailer_tts_filter, marines_list, FALSE, INFINITY, 20, sender.pitch, extra_filters.Join("|")) /datum/squad/proc/check_entry(datum/job/job) if(!(job.title in current_positions)) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/hivemind/hivemind.dm b/code/modules/mob/living/carbon/xenomorph/castes/hivemind/hivemind.dm index 4f08bc673e8ac..d69ebf18e7772 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/hivemind/hivemind.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/hivemind/hivemind.dm @@ -222,7 +222,7 @@ /mob/living/carbon/xenomorph/hivemind/receive_hivemind_message(mob/living/carbon/xenomorph/speaker, message) var/track = "(F)" - show_message("[track] [speaker.hivemind_start()] [span_message("hisses, '[message]'")][speaker.hivemind_end()]", 2) + return show_message("[track] [speaker.hivemind_start()] [span_message("hisses, '[message]'")][speaker.hivemind_end()]", 2) /mob/living/carbon/xenomorph/hivemind/Topic(href, href_list) . = ..() diff --git a/code/modules/mob/living/carbon/xenomorph/hive_datum.dm b/code/modules/mob/living/carbon/xenomorph/hive_datum.dm index ff906a3d84841..6f992a3985d7b 100644 --- a/code/modules/mob/living/carbon/xenomorph/hive_datum.dm +++ b/code/modules/mob/living/carbon/xenomorph/hive_datum.dm @@ -869,12 +869,6 @@ to_chat will check for valid clients itself already so no need to double check f to_chat(X, " [message][report_distance ? " Distance: [get_dist(X, target)]" : ""]") -// This is to simplify the process of talking in hivemind, this will invoke the receive proc of all xenos in this hive -/datum/hive_status/proc/hive_mind_message(mob/living/carbon/xenomorph/sender, message) - for(var/i in get_all_xenos()) - var/mob/living/carbon/xenomorph/X = i - X.receive_hivemind_message(sender, message) - ///Used for setting the trackers of all xenos in the hive, like when a nuke activates /datum/hive_status/proc/set_all_xeno_trackers(atom/target) for(var/mob/living/carbon/xenomorph/X AS in get_all_xenos()) diff --git a/code/modules/mob/living/carbon/xenomorph/say.dm b/code/modules/mob/living/carbon/xenomorph/say.dm index c6d5c2c8ec4bd..096ef6b2b5c9c 100644 --- a/code/modules/mob/living/carbon/xenomorph/say.dm +++ b/code/modules/mob/living/carbon/xenomorph/say.dm @@ -46,20 +46,25 @@ log_talk(message, LOG_HIVEMIND) - for(var/i in GLOB.observer_list) - var/mob/dead/observer/S = i - if(!S?.client?.prefs || !(S.client.prefs.toggles_chat & CHAT_GHOSTHIVEMIND)) + for(var/mob/dead/observer/ghost AS in GLOB.observer_list) + if(!ghost?.client?.prefs || !(ghost.client.prefs.toggles_chat & CHAT_GHOSTHIVEMIND)) continue - var/track = FOLLOW_LINK(S, src) - S.show_message("[track] [hivemind_start()] [span_message("hisses, '[message]'")][hivemind_end()]", 2) + var/track = FOLLOW_LINK(ghost, src) + ghost.show_message("[track] [hivemind_start()] [span_message("hisses, '[message]'")][hivemind_end()]", 2) - hive.hive_mind_message(src, message) + var/list/listened = list() + for(var/mob/living/carbon/xenomorph/sister AS in hive.get_all_xenos()) + if(sister.receive_hivemind_message(src, message)) + listened += sister + if(SStts.tts_enabled && length(listened) && voice) + var/list/treated_message = treat_message(message) + INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), src, treated_message["tts_message"], get_default_language(), voice, voice_filter, listened, FALSE, INFINITY, pitch = pitch) return TRUE /mob/living/carbon/xenomorph/proc/receive_hivemind_message(mob/living/carbon/xenomorph/X, message) var/follow_link = X != src ? "(F) " : "" - show_message("[follow_link][X.hivemind_start()][span_message(" hisses, '[message]'")][X.hivemind_end()]", 2) + return show_message("[follow_link][X.hivemind_start()][span_message(" hisses, '[message]'")][X.hivemind_end()]", 2) /mob/living/carbon/xenomorph/get_saymode(message, talk_key) diff --git a/tools/tts/tts-api/Dockerfile b/tools/tts/tts-api/Dockerfile index 482cda7bae36e..a317b4ac0d993 100644 --- a/tools/tts/tts-api/Dockerfile +++ b/tools/tts/tts-api/Dockerfile @@ -24,6 +24,8 @@ SHELL ["conda", "run", "-n", "intel", "/bin/bash", "-c"] # Setup python requirements and install the TTS python module into the new intel anaconda environment. RUN pip install Flask &&\ pip install waitress &&\ + pip install pysbd &&\ + pip install pydub &&\ pip cache purge COPY . /root diff --git a/tools/tts/tts-api/tts-api.py b/tools/tts/tts-api/tts-api.py index e1a5880da5bc2..aae0201287176 100644 --- a/tools/tts/tts-api/tts-api.py +++ b/tools/tts/tts-api/tts-api.py @@ -15,7 +15,7 @@ segmenter = pysbd.Segmenter(language="en", clean=True) radio_starts = ["./on1.wav", "./on2.wav"] radio_ends = ["./off1.wav", "./off2.wav", "./off3.wav", "./off4.wav"] -authorization_token = os.getenv("TTS_AUTHORIZATION_TOKEN", "vote_goof_2024") +authorization_token = os.getenv("TTS_AUTHORIZATION_TOKEN", "coolio") def hhmmss_to_seconds(string): new_time = 0 separated_times = string.split(":") From 04f12260231493838146d4163a397267616184fc Mon Sep 17 00:00:00 2001 From: TiviPlus <572233640+TiviPlus@users.noreply.com> Date: Sun, 10 Mar 2024 10:13:11 +0100 Subject: [PATCH 2/5] Misc fixes --- code/datums/jobs/squads.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/datums/jobs/squads.dm b/code/datums/jobs/squads.dm index 721008a703b5e..2763e37cbd1c5 100644 --- a/code/datums/jobs/squads.dm +++ b/code/datums/jobs/squads.dm @@ -354,7 +354,7 @@ GLOBAL_VAR_INIT(hailer_tts_filter, @{"[0:a] asetrate=%SAMPLE_RATE%*0.7,aresample if(is_ic_filtered(message) || NON_ASCII_CHECK(message)) to_chat(sender, span_boldnotice("Message invalid. Check your message does not contain filtered words or characters.")) return - var/list/treated_message = sender.treat_message(message) + var/list/treated_message = sender?.treat_message(message) message = treated_message["message"] var/header = "AUTOMATED CIC NOTICE:" @@ -363,7 +363,7 @@ GLOBAL_VAR_INIT(hailer_tts_filter, @{"[0:a] asetrate=%SAMPLE_RATE%*0.7,aresample for(var/mob/living/marine AS in marines_list) marine.play_screen_text("[header]
" + message, /atom/movable/screen/text/screen_text/command_order) - if(sender.voice && SStts.tts_enabled) + if(sender?.voice && SStts.tts_enabled) var/list/extra_filters = list(TTS_FILTER_RADIO) if(isrobot(sender)) extra_filters += TTS_FILTER_SILICON From 434cbfa09fdd2d6144db54776206b10c0543d0ae Mon Sep 17 00:00:00 2001 From: TiviPlus <572233640+TiviPlus@users.noreply.com> Date: Fri, 11 Oct 2024 22:11:17 +0200 Subject: [PATCH 3/5] Fixes --- code/datums/jobs/squads.dm | 13 +++---------- code/modules/mob/living/carbon/xenomorph/say.dm | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/code/datums/jobs/squads.dm b/code/datums/jobs/squads.dm index 0e24bcaeaaa23..05f55b28e59d2 100644 --- a/code/datums/jobs/squads.dm +++ b/code/datums/jobs/squads.dm @@ -347,9 +347,6 @@ text = "[text]" return "[nametext][text]" - -GLOBAL_VAR_INIT(hailer_tts_filter, @{"[0:a] asetrate=%SAMPLE_RATE%*0.7,aresample=16000,atempo=1/0.7,lowshelf=g=-20:f=500,highpass=f=500,aphaser=in_gain=1:out_gain=1:delay=3.0:decay=0.4:speed=0.5:type=t [out]; [out]atempo=1.2,volume=15dB [final]; anoisesrc=a=0.01:d=60 [noise]; [final][noise] amix=duration=shortest"}) - /datum/squad/proc/message_squad(message, mob/living/carbon/human/sender) if(is_ic_filtered(message) || NON_ASCII_CHECK(message)) to_chat(sender, span_boldnotice("Message invalid. Check your message does not contain filtered words or characters.")) @@ -368,17 +365,13 @@ GLOBAL_VAR_INIT(hailer_tts_filter, @{"[0:a] asetrate=%SAMPLE_RATE%*0.7,aresample message_type = /atom/movable/screen/text/screen_text/command_order for(var/mob/living/marine AS in marines_list) -<<<<<<< HEAD - marine.play_screen_text("[header]
" + message, /atom/movable/screen/text/screen_text/command_order) + marine.playsound_local(marine, sound, 35) + marine.play_screen_text("[header]
" + message, message_type, message_color) if(sender?.voice && SStts.tts_enabled) var/list/extra_filters = list(TTS_FILTER_RADIO) if(isrobot(sender)) extra_filters += TTS_FILTER_SILICON - INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), sender, treated_message["tts_message"], sender.get_default_language(), sender.voice, GLOB.hailer_tts_filter, marines_list, FALSE, INFINITY, 20, sender.pitch, extra_filters.Join("|")) -======= - marine.playsound_local(marine, sound, 35) - marine.play_screen_text("[header]
" + message, message_type, message_color) ->>>>>>> master + INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), marines_list, treated_message["tts_message"], sender.get_default_language(), sender.voice, sender.voice_filter, local = TRUE, pitch = sender.pitch, special_filters = extra_filters.Join("|"), directionality = FALSE) /datum/squad/proc/check_entry(datum/job/job) if(!(job.title in current_positions)) diff --git a/code/modules/mob/living/carbon/xenomorph/say.dm b/code/modules/mob/living/carbon/xenomorph/say.dm index 096ef6b2b5c9c..237065433b056 100644 --- a/code/modules/mob/living/carbon/xenomorph/say.dm +++ b/code/modules/mob/living/carbon/xenomorph/say.dm @@ -58,7 +58,7 @@ listened += sister if(SStts.tts_enabled && length(listened) && voice) var/list/treated_message = treat_message(message) - INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), src, treated_message["tts_message"], get_default_language(), voice, voice_filter, listened, FALSE, INFINITY, pitch = pitch) + INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), listened, treated_message["tts_message"], get_default_language(), voice, voice_filter, local = TRUE, pitch = pitch, directionality = FALSE) return TRUE From ac0e615d3827297c3aa4c5341e532374f9fb7ea4 Mon Sep 17 00:00:00 2001 From: TiviPlus <57223640+TiviPlus@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:51:31 +0200 Subject: [PATCH 4/5] Update code/datums/jobs/squads.dm Co-authored-by: Lumipharon --- code/datums/jobs/squads.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/jobs/squads.dm b/code/datums/jobs/squads.dm index 05f55b28e59d2..e835f3b491491 100644 --- a/code/datums/jobs/squads.dm +++ b/code/datums/jobs/squads.dm @@ -371,7 +371,7 @@ var/list/extra_filters = list(TTS_FILTER_RADIO) if(isrobot(sender)) extra_filters += TTS_FILTER_SILICON - INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), marines_list, treated_message["tts_message"], sender.get_default_language(), sender.voice, sender.voice_filter, local = TRUE, pitch = sender.pitch, special_filters = extra_filters.Join("|"), directionality = FALSE) + INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), sender, treated_message["tts_message"], sender.get_default_language(), sender.voice, sender.voice_filter, marines_list, TRUE, pitch = sender.pitch, special_filters = extra_filters.Join("|"), directionality = FALSE) /datum/squad/proc/check_entry(datum/job/job) if(!(job.title in current_positions)) From 6d5402d1e8a9043517e4d9f4708860fba035186b Mon Sep 17 00:00:00 2001 From: Lumipharon Date: Wed, 16 Oct 2024 09:17:46 +1300 Subject: [PATCH 5/5] Update code/modules/mob/living/carbon/xenomorph/say.dm --- code/modules/mob/living/carbon/xenomorph/say.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/say.dm b/code/modules/mob/living/carbon/xenomorph/say.dm index 237065433b056..9d22822022863 100644 --- a/code/modules/mob/living/carbon/xenomorph/say.dm +++ b/code/modules/mob/living/carbon/xenomorph/say.dm @@ -58,7 +58,7 @@ listened += sister if(SStts.tts_enabled && length(listened) && voice) var/list/treated_message = treat_message(message) - INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), listened, treated_message["tts_message"], get_default_language(), voice, voice_filter, local = TRUE, pitch = pitch, directionality = FALSE) + INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), src, treated_message["tts_message"], get_default_language(), voice, voice_filter, listened, TRUE, pitch = pitch, directionality = FALSE) return TRUE