commit 12/10/2025

This commit is contained in:
2025-12-10 10:59:22 +07:00
parent 802cf940a9
commit cbca8cd43d
10 changed files with 403 additions and 4 deletions

View File

@@ -44,6 +44,7 @@ import java.time.LocalDateTime
import codes.configKeys
import config
import database.QueueTable
import google.GoogleTTS
import io.javalin.websocket.WsCloseStatus
import org.tinylog.Logger
import java.io.File
@@ -59,6 +60,7 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
lateinit var semiauto: Javalin
val objectmapper = jacksonObjectMapper()
val WsContextMap = mutableMapOf<String, LiveListenData>()
val ttsjob = GoogleTTS()
private fun SendReply(context: WsMessageContext, command: String, value: String) {
try {
@@ -201,6 +203,32 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
SendReply(wsMessageContext, cmd.command, objectmapper.writeValueAsString(reply))
}
"start_generate_tts" ->{
val js : JsonNode = objectmapper.readTree(cmd.data)
SendReply(wsMessageContext, cmd.command, "ok")
val voicetype = js.get("voicetype")?.asText("Wavenet-A") ?: "Wavenet-A"
val languagecode = js.get("languagecode")?.asText("id-ID") ?: "id-ID"
val databasesource = js.get("databasesource")?.asText("VOICE_1") ?: "VOICE_1"
val targetas = js.get("targetas")?.asText("VOICE_2") ?: "VOICE_2"
val fileoperation = js.get("fileoperation")?.asText("overwrite") ?: "overwrite"
val autoadd = js.get("autoadd")?.asText("add") ?: "add"
Logger.info {"Starting TTS Soundbank Generation, VoiceType=$voicetype, Language"}
ttsjob.GenerateSoundbank(voicetype, languagecode, databasesource, targetas, fileoperation, autoadd){ progress, message ->
SendReply(wsMessageContext, "tts_generate_progress", objectmapper.writeValueAsString(
mapOf(
"progress" to progress,
"message" to message
)
))
}
}
"stop_generate_tts" ->{
SendReply(wsMessageContext, cmd.command, "ok")
ttsjob.StopGenerate()
}
else -> {
SendReply(wsMessageContext, cmd.command, "Unknown command")
}