commit 10/10/2025

Restrukturisasi soundbank path di database
This commit is contained in:
2025-10-10 16:21:13 +07:00
parent 41d6dd7f47
commit e0cdf74dec
3 changed files with 28 additions and 15 deletions

View File

@@ -2,8 +2,10 @@ package codes
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import content.Category
import content.Language
import content.ScheduleDay
import content.VoiceType
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@@ -25,15 +27,8 @@ import kotlin.io.path.name
class Somecodes {
companion object {
val current_directory : String = System.getProperty("user.dir")
val Soundbank_directory : Path = Path.of(current_directory,"Soundbank")
val Soundbank_Languages_directory : List<Path> = listOf(
Soundbank_directory.resolve(Language.INDONESIA.name),
Soundbank_directory.resolve(Language.LOCAL.name),
Soundbank_directory.resolve(Language.ENGLISH.name),
Soundbank_directory.resolve(Language.CHINESE.name),
Soundbank_directory.resolve(Language.JAPANESE.name),
Soundbank_directory.resolve(Language.ARABIC.name)
)
var Soundbank_directory : Path = Path.of(current_directory,"Soundbank")
val SoundbankResult_directory : Path = Path.of(current_directory,"SoundbankResult")
val PagingResult_directory : Path = Path.of(current_directory,"PagingResult")
@@ -56,6 +51,17 @@ class Somecodes {
// regex for getting ann_id from Message, which is the number inside []
private val ann_id_regex = Regex("\\[(\\d+)]")
/**
* Get the directory path for a specific language, voice type, and category.
* @param language The language.
* @param voice The voice type.
* @param category The category.
* @return The path to the directory.
*/
fun SoundbankDirectory(language: Language, voice: VoiceType, category: Category) : Path{
return Soundbank_directory.resolve(language.name).resolve(voice.name).resolve(category.name)
}
fun ExtractFilesFromClassPath(resourcePath: String, outputDir: Path) {
try {
val resource = Somecodes::class.java.getResource(resourcePath)
@@ -157,14 +163,13 @@ class Somecodes {
/**
* List all audio files (.mp3 and .wav) in the specified directory and its subdirectories.
* Only files larger than 1KB are included.
* @param dir The directory to search in (default is the current working directory).
* @param p The directory Path to search in
* @return A list of absolute paths to the audio files found.
*/
fun ListAudioFiles(dir: String = current_directory) : List<String>{
fun ListAudioFiles(p: Path) : List<String>{
return try{
// find all files that ends with .mp3 or .wav
// and find them recursively
val p = Path.of(dir)
if (Files.exists(p) && Files.isDirectory(p)){
Files.walk(p)
// cari file regular saja