From 826a3a322c646c8ce7e1611bef11ecf21409b5f0 Mon Sep 17 00:00:00 2001 From: Legendaxe <102746941+Legendaxe@users.noreply.github.com> Date: Sun, 19 Nov 2023 18:27:41 +0200 Subject: [PATCH] tts url to config --- config/example/config.toml | 2 ++ modular_ss220/text_to_speech/code/configuration.dm | 7 +++++++ modular_ss220/text_to_speech/code/providers/silero.dm | 8 +------- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config/example/config.toml b/config/example/config.toml index 25311d096ea9..6a33946ea878 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -871,6 +871,8 @@ enabled_away_missions = [ tts_enabled = false # If enabled, what token does it use for API tts_token_silero = "" +# api url for your tts provider +tts_api_url_silero = "http://you.tts.provider.com:port/endpoint" # Are the audio files saved after usage tts_cache_enabled = false # What CPU threads are used for ffmpeg. Example valid values: "0-3" or "1,4-7" diff --git a/modular_ss220/text_to_speech/code/configuration.dm b/modular_ss220/text_to_speech/code/configuration.dm index 30d862197bfb..7c63ff528a12 100644 --- a/modular_ss220/text_to_speech/code/configuration.dm +++ b/modular_ss220/text_to_speech/code/configuration.dm @@ -13,6 +13,8 @@ var/tts_enabled = FALSE /// TTS API token for silero provider var/tts_token_silero = "" + /// TTS API url for silero provide + var/tts_api_url_silero = "http://s2.ss220.club:9999/voice" /// Should oggs be cached var/tts_cache_enabled = FALSE /// What cpu threads should ffmpeg use @@ -23,6 +25,7 @@ CONFIG_LOAD_STR(tts_token_silero, data["tts_token_silero"]) CONFIG_LOAD_BOOL(tts_cache_enabled, data["tts_cache_enabled"]) CONFIG_LOAD_STR(ffmpeg_cpuaffinity, data["ffmpeg_cpuaffinity"]) + CONFIG_LOAD_STR(tts_api_url_silero, data["tts_api_url_silero"]) tts_enabled = tts_token_silero && tts_enabled var/sanitized = regex(@"[^0-9,-]", "g").Replace(ffmpeg_cpuaffinity, "") @@ -32,3 +35,7 @@ /datum/http_request/vv_get_var(var_name) if(var_name == "body") return FALSE + +/datum/configuration_section/tts_configuration/vv_get_var(var_name, var_value) + if(var_name == "tts_api_url_silero") + return FALSE diff --git a/modular_ss220/text_to_speech/code/providers/silero.dm b/modular_ss220/text_to_speech/code/providers/silero.dm index 9f3f2bba1772..c1257a6997c4 100644 --- a/modular_ss220/text_to_speech/code/providers/silero.dm +++ b/modular_ss220/text_to_speech/code/providers/silero.dm @@ -1,12 +1,6 @@ /datum/tts_provider/silero name = "Silero" is_enabled = TRUE - api_url = "http://s2.ss220.club:9999/voice" - -/datum/tts_provider/silero/vv_edit_var(var_name, var_value) - if(var_name == "api_url") - return FALSE - return ..() /datum/tts_provider/silero/request(text, datum/tts_seed/silero/seed, datum/callback/proc_callback) if(throttle_check()) @@ -28,7 +22,7 @@ req_body["format"] = "ogg" req_body["word_ts"] = FALSE - SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, api_url, json_encode(req_body), list("content-type" = "application/json"), proc_callback) + SShttp.create_async_request(RUSTG_HTTP_METHOD_POST, GLOB.configuration.tts.tts_api_url_silero , json_encode(req_body), list("content-type" = "application/json"), proc_callback) return TRUE