Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak: new reserved tts server #620

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/controllers/subsystem/SShttp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ SUBSYSTEM_DEF(http)
* Generates an async request, and adds it to the subsystem's processing list
* These should be used as they do not lock the entire DD process up as they execute inside their own thread pool inside RUSTG
*/
/datum/controller/subsystem/http/proc/create_async_request(method, url, body = "", list/headers, datum/callback/proc_callback)
/datum/controller/subsystem/http/proc/create_async_request(method, url, body = "", list/headers, datum/callback/proc_callback, output_file = "")
var/datum/http_request/req = new()
req.prepare(method, url, body, headers)
req.prepare(method, url, body, headers, output_file)
if(proc_callback)
req.cb = proc_callback

Expand Down
2 changes: 2 additions & 0 deletions modular_ss220/text_to_speech/_tts.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#include "code/hear.dm"
#include "code/numbers.dm"
#include "code/providers/silero.dm"
#include "code/providers/white_dream.dm"
#include "code/rust_g_ss220.dm"
#include "code/seeds/base.dm"
#include "code/seeds/silero.dm"
#include "code/seeds/white_dream.dm"
#include "code/sound.dm"
#include "code/tts_preferences.dm"
#include "code/tts_provider.dm"
Expand Down
5 changes: 4 additions & 1 deletion modular_ss220/text_to_speech/code/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
var/tts_enabled = FALSE
/// TTS API token for silero provider
var/tts_token_silero = ""
/// TTS API token for white dream provider
var/tts_token_white_dream = ""
/// Should oggs be cached
var/tts_cache_enabled = FALSE
/// What cpu threads should ffmpeg use
Expand All @@ -21,10 +23,11 @@
/datum/configuration_section/tts_configuration/load_data(list/data)
CONFIG_LOAD_BOOL(tts_enabled, data["tts_enabled"])
CONFIG_LOAD_STR(tts_token_silero, data["tts_token_silero"])
CONFIG_LOAD_STR(tts_token_white_dream, data["tts_token_white_dream"])
CONFIG_LOAD_BOOL(tts_cache_enabled, data["tts_cache_enabled"])
CONFIG_LOAD_STR(ffmpeg_cpuaffinity, data["ffmpeg_cpuaffinity"])

tts_enabled = tts_token_silero && tts_enabled
tts_enabled = (tts_token_silero || tts_token_white_dream) && tts_enabled
var/sanitized = regex(@"[^0-9,-]", "g").Replace(ffmpeg_cpuaffinity, "")
if(ffmpeg_cpuaffinity != sanitized)
log_config("Wrong value for ffmpeg_cpuaffinity. Check out taskset man page.")
Expand Down
2 changes: 1 addition & 1 deletion modular_ss220/text_to_speech/code/providers/silero.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
return FALSE
return ..()

/datum/tts_provider/silero/request(text, datum/tts_seed/silero/seed, datum/callback/proc_callback)
/datum/tts_provider/silero/request(text, datum/tts_seed/silero/seed, datum/callback/proc_callback, file_name)
if(throttle_check())
return FALSE

Expand Down
36 changes: 36 additions & 0 deletions modular_ss220/text_to_speech/code/providers/white_dream.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/datum/tts_provider/white_dream
name = "White Dream"
is_enabled = FALSE
api_url = "https://pubtts.ss14.su/api/v1/tts"
skip_explicit_file_save = TRUE

/datum/tts_provider/white_dream/vv_edit_var(var_name, var_value)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А тут я скилл ишу, что засунул это в силеро. Этому лучше быть в родительском классе просто, чем копипастить в два места

if(var_name == "api_url")
return FALSE
return ..()

/datum/tts_provider/white_dream/request(text, datum/tts_seed/white_dream/seed, datum/callback/proc_callback, file_name)
if(throttle_check())
return FALSE

var/ssml_text = {"[text]"}

var/requestQuery = {"speaker=[seed.value]&ext=ogg&text=[url_encode(ssml_text)]"}

rustg_file_write("", file_name)

SShttp.create_async_request(RUSTG_HTTP_METHOD_GET, {"[api_url]?[requestQuery]"}, "", list("content-type" = "application/json", "Authorization" = {"Bearer [GLOB.configuration.tts.tts_token_white_dream]"}), proc_callback, file_name)

return TRUE

/datum/tts_provider/white_dream/process_response(datum/http_response/response)
return "voice"

/datum/tts_provider/white_dream/pitch_whisper(text)
return {"[text]"}

/datum/tts_provider/white_dream/rate_faster(text)
return {"[text]"}

/datum/tts_provider/white_dream/rate_medium(text)
return {"[text]"}
Loading