Refactor the UI of Android TTS engine (#533)
This commit is contained in:
@@ -56,45 +56,52 @@ class MainActivity : ComponentActivity() {
|
|||||||
TopAppBar(title = { Text("Next-gen Kaldi: TTS") })
|
TopAppBar(title = { Text("Next-gen Kaldi: TTS") })
|
||||||
}) {
|
}) {
|
||||||
Box(modifier = Modifier.padding(it)) {
|
Box(modifier = Modifier.padding(it)) {
|
||||||
Column {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
Row {
|
Column {
|
||||||
Text("Speed")
|
Text("Speed " + String.format("%.1f", TtsEngine.speed))
|
||||||
Slider(
|
Slider(
|
||||||
value = TtsEngine.speedState.value,
|
value = TtsEngine.speedState.value,
|
||||||
onValueChange = { TtsEngine.speed = it },
|
onValueChange = { TtsEngine.speed = it },
|
||||||
valueRange = 0.2F..3.0F
|
valueRange = 0.2F..3.0F,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var testText by remember { mutableStateOf("") }
|
var testText by remember { mutableStateOf("") }
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
value = testText,
|
|
||||||
onValueChange = { testText = it },
|
|
||||||
label = { Text("Test text") },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.wrapContentHeight()
|
|
||||||
.padding(16.dp),
|
|
||||||
singleLine = false,
|
|
||||||
)
|
|
||||||
|
|
||||||
val numSpeakers = TtsEngine.tts!!.numSpeakers()
|
val numSpeakers = TtsEngine.tts!!.numSpeakers()
|
||||||
if (numSpeakers > 1) {
|
if (numSpeakers > 1) {
|
||||||
Row {
|
OutlinedTextField(
|
||||||
Text("Speaker ID: (0-${numSpeakers - 1})")
|
value = TtsEngine.speakerIdState.value.toString(),
|
||||||
OutlinedTextField(
|
onValueChange = {
|
||||||
value = TtsEngine.speakerIdState.value.toString(),
|
if (it.isEmpty() || it.isBlank()) {
|
||||||
onValueChange = {
|
TtsEngine.speakerId = 0
|
||||||
if (it.isEmpty() || it.isBlank()) {
|
} else {
|
||||||
TtsEngine.speakerId = 0
|
TtsEngine.speakerId = it.toString().toInt()
|
||||||
} else {
|
}
|
||||||
TtsEngine.speakerId = it.toString().toInt()
|
},
|
||||||
}
|
label = {
|
||||||
},
|
Text("Speaker ID: (0-${numSpeakers - 1})")
|
||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
|
},
|
||||||
)
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||||
}
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 16.dp)
|
||||||
|
.wrapContentHeight(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = testText,
|
||||||
|
onValueChange = { testText = it },
|
||||||
|
label = { Text("Please input your text here") },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 16.dp)
|
||||||
|
.wrapContentHeight(),
|
||||||
|
singleLine = false,
|
||||||
|
)
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.padding(20.dp),
|
modifier = Modifier.padding(20.dp),
|
||||||
|
|||||||
Reference in New Issue
Block a user