Skip to content

Commit 8e340f3

Browse files
committed
fix: Resolve issue with random selection in single voice mode #266
1 parent bea00bc commit 8e340f3

File tree

1 file changed

+3
-6
lines changed
  • app/src/main/java/com/github/jing332/tts_server_android/service/systts/help

1 file changed

+3
-6
lines changed

app/src/main/java/com/github/jing332/tts_server_android/service/systts/help/TextProcessor.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class TextProcessor : ITextProcessor {
3535
private lateinit var engine: SpeechRuleEngine
3636
private val textReplacer = TextReplacer()
3737

38-
private var singleVoice: TtsConfiguration? = null
3938
private var configs: List<TtsConfiguration> = emptyList()
4039
private var speechRules: List<SpeechRuleInfo> = emptyList()
4140
private val random by lazy { Random(System.currentTimeMillis()) }
@@ -58,10 +57,8 @@ class TextProcessor : ITextProcessor {
5857
speechRules = this.configs.map { it.speechInfo }
5958
} else {
6059
this.configs = configs.values.toList()
61-
if (this.configs.isEmpty()) {
60+
if (this.configs.isEmpty())
6261
return Err(TextProcessorError.MissingConfig(ConfigType.SINGLE_VOICE))
63-
} else
64-
singleVoice = this.configs.random(random)
6562
}
6663

6764
loadReplacer()
@@ -131,7 +128,7 @@ class TextProcessor : ITextProcessor {
131128
// Exact match ID > random match in tag > random match in all
132129
val config = configFromId
133130
?: sameTagList.randomOrNull(random)
134-
?: singleVoice
131+
?: configs.randomOrNull(random)
135132
?: return Err(
136133
TextProcessorError.MissingConfig(
137134
ConfigType.TAG,
@@ -142,7 +139,7 @@ class TextProcessor : ITextProcessor {
142139
}
143140
}
144141
} else {
145-
val singleVoice = singleVoice ?: return Err(
142+
val singleVoice = configs.randomOrNull(random) ?: return Err(
146143
TextProcessorError.MissingConfig(
147144
ConfigType.SINGLE_VOICE, "single voice"
148145
)

0 commit comments

Comments
 (0)