기능 1차 구현 후 정상 동작 테스트에 사용되는 CommandLineRunner

This commit is contained in:
이상진 2025-08-20 21:16:48 +09:00
parent 2134ca58f4
commit a8c1dbc9c9

View File

@ -0,0 +1,91 @@
package com.sangdol.text_to_speech
import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import org.springframework.boot.CommandLineRunner
import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Component
private val log: KLogger = KotlinLogging.logger {}
@Profile("none")
@Component
class SampleCreateTestRunner(
private val singleTextConverter: SingleTextConverter
) : CommandLineRunner {
override fun run(vararg args: String?) {
listOf(
ConvertSingleTextRequest(
text = "Did you find the book you were looking for?",
type = Neural2FemaleVoice.TYPE_C,
speakingRate = 1.0,
order = 1
),
ConvertSingleTextRequest(
text = "Yes, its right here. Its exactly what I need for my project.",
type = Neural2MaleVoice.TYPE_A,
speakingRate = 1.0,
order = 2
),
ConvertSingleTextRequest(
text = "Great. Do you need help with anything else?",
type = Neural2FemaleVoice.TYPE_E,
speakingRate = 1.0,
order = 3
),
ConvertSingleTextRequest(
text = "Could you show me how to use the copy machine?",
type = Neural2MaleVoice.TYPE_D,
speakingRate = 1.0,
order = 4
),
ConvertSingleTextRequest(
text = "Sure, its over there in the corner. Let me guide you.",
type = Neural2FemaleVoice.TYPE_F,
speakingRate = 1.0,
order = 5
),
).forEach {
val type: VoiceType = it.type
val filePath = "library/sample-scripts-1/${it.order}(${genderString(type)}-${type.name}).mp3"
singleTextConverter.convert(it, filePath)
}
listOf(
ConvertSingleTextRequest(
text = "I want to pick up a new hobby, but Im not sure what to try.",
type = Neural2FemaleVoice.TYPE_C,
speakingRate = 1.0,
order = 1
),
ConvertSingleTextRequest(
text = "Have you thought about gardening? ",
type = Neural2MaleVoice.TYPE_A,
speakingRate = 1.0,
order = 2
),
ConvertSingleTextRequest(
text = "Gardening? Ive never tried it before. What can I grow?",
type = Neural2FemaleVoice.TYPE_E,
speakingRate = 1.0,
order = 3
),
ConvertSingleTextRequest(
text = "You can start with some flowers for your balcony.",
type = Neural2MaleVoice.TYPE_D,
speakingRate = 1.0,
order = 4
),
).forEach {
val type: VoiceType = it.type
val filePath = "library/sample-scripts-1/${it.order}(${genderString(type)}-${type.name}).mp3"
singleTextConverter.convert(it, filePath)
}
}
private fun genderString(type: VoiceType) = when(type) {
is Neural2MaleVoice -> "male"
is Neural2FemaleVoice -> "female"
}
}