@@ -35,7 +35,6 @@ class TextProcessor : ITextProcessor {
35
35
private lateinit var engine: SpeechRuleEngine
36
36
private val textReplacer = TextReplacer ()
37
37
38
- private var singleVoice: TtsConfiguration ? = null
39
38
private var configs: List <TtsConfiguration > = emptyList()
40
39
private var speechRules: List <SpeechRuleInfo > = emptyList()
41
40
private val random by lazy { Random (System .currentTimeMillis()) }
@@ -58,10 +57,8 @@ class TextProcessor : ITextProcessor {
58
57
speechRules = this .configs.map { it.speechInfo }
59
58
} else {
60
59
this .configs = configs.values.toList()
61
- if (this .configs.isEmpty()) {
60
+ if (this .configs.isEmpty())
62
61
return Err (TextProcessorError .MissingConfig (ConfigType .SINGLE_VOICE ))
63
- } else
64
- singleVoice = this .configs.random(random)
65
62
}
66
63
67
64
loadReplacer()
@@ -131,7 +128,7 @@ class TextProcessor : ITextProcessor {
131
128
// Exact match ID > random match in tag > random match in all
132
129
val config = configFromId
133
130
? : sameTagList.randomOrNull(random)
134
- ? : singleVoice
131
+ ? : configs.randomOrNull(random)
135
132
? : return Err (
136
133
TextProcessorError .MissingConfig (
137
134
ConfigType .TAG ,
@@ -142,7 +139,7 @@ class TextProcessor : ITextProcessor {
142
139
}
143
140
}
144
141
} else {
145
- val singleVoice = singleVoice ? : return Err (
142
+ val singleVoice = configs.randomOrNull(random) ? : return Err (
146
143
TextProcessorError .MissingConfig (
147
144
ConfigType .SINGLE_VOICE , " single voice"
148
145
)
0 commit comments