Committed by
GitHub
Refactor the UI of Android TTS engine (#533)
正在显示
1 个修改的文件
包含
24 行增加
和
17 行删除
| @@ -56,32 +56,21 @@ class MainActivity : ComponentActivity() { | @@ -56,32 +56,21 @@ class MainActivity : ComponentActivity() { | ||
| 56 | TopAppBar(title = { Text("Next-gen Kaldi: TTS") }) | 56 | TopAppBar(title = { Text("Next-gen Kaldi: TTS") }) |
| 57 | }) { | 57 | }) { |
| 58 | Box(modifier = Modifier.padding(it)) { | 58 | Box(modifier = Modifier.padding(it)) { |
| 59 | + Column(modifier = Modifier.padding(16.dp)) { | ||
| 59 | Column { | 60 | Column { |
| 60 | - Row { | ||
| 61 | - Text("Speed") | 61 | + Text("Speed " + String.format("%.1f", TtsEngine.speed)) |
| 62 | Slider( | 62 | Slider( |
| 63 | value = TtsEngine.speedState.value, | 63 | value = TtsEngine.speedState.value, |
| 64 | onValueChange = { TtsEngine.speed = it }, | 64 | onValueChange = { TtsEngine.speed = it }, |
| 65 | - valueRange = 0.2F..3.0F | 65 | + valueRange = 0.2F..3.0F, |
| 66 | + modifier = Modifier.fillMaxWidth() | ||
| 66 | ) | 67 | ) |
| 67 | } | 68 | } |
| 68 | var testText by remember { mutableStateOf("") } | 69 | var testText by remember { mutableStateOf("") } |
| 69 | 70 | ||
| 70 | - OutlinedTextField( | ||
| 71 | - value = testText, | ||
| 72 | - onValueChange = { testText = it }, | ||
| 73 | - label = { Text("Test text") }, | ||
| 74 | - modifier = Modifier | ||
| 75 | - .fillMaxWidth() | ||
| 76 | - .wrapContentHeight() | ||
| 77 | - .padding(16.dp), | ||
| 78 | - singleLine = false, | ||
| 79 | - ) | ||
| 80 | 71 | ||
| 81 | val numSpeakers = TtsEngine.tts!!.numSpeakers() | 72 | val numSpeakers = TtsEngine.tts!!.numSpeakers() |
| 82 | if (numSpeakers > 1) { | 73 | if (numSpeakers > 1) { |
| 83 | - Row { | ||
| 84 | - Text("Speaker ID: (0-${numSpeakers - 1})") | ||
| 85 | OutlinedTextField( | 74 | OutlinedTextField( |
| 86 | value = TtsEngine.speakerIdState.value.toString(), | 75 | value = TtsEngine.speakerIdState.value.toString(), |
| 87 | onValueChange = { | 76 | onValueChange = { |
| @@ -91,10 +80,28 @@ class MainActivity : ComponentActivity() { | @@ -91,10 +80,28 @@ class MainActivity : ComponentActivity() { | ||
| 91 | TtsEngine.speakerId = it.toString().toInt() | 80 | TtsEngine.speakerId = it.toString().toInt() |
| 92 | } | 81 | } |
| 93 | }, | 82 | }, |
| 94 | - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) | 83 | + label = { |
| 84 | + Text("Speaker ID: (0-${numSpeakers - 1})") | ||
| 85 | + }, | ||
| 86 | + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), | ||
| 87 | + modifier = Modifier | ||
| 88 | + .fillMaxWidth() | ||
| 89 | + .padding(bottom = 16.dp) | ||
| 90 | + .wrapContentHeight(), | ||
| 95 | ) | 91 | ) |
| 96 | } | 92 | } |
| 97 | - } | 93 | + |
| 94 | + OutlinedTextField( | ||
| 95 | + value = testText, | ||
| 96 | + onValueChange = { testText = it }, | ||
| 97 | + label = { Text("Please input your text here") }, | ||
| 98 | + modifier = Modifier | ||
| 99 | + .fillMaxWidth() | ||
| 100 | + .padding(bottom = 16.dp) | ||
| 101 | + .wrapContentHeight(), | ||
| 102 | + singleLine = false, | ||
| 103 | + ) | ||
| 104 | + | ||
| 98 | Row { | 105 | Row { |
| 99 | Button( | 106 | Button( |
| 100 | modifier = Modifier.padding(20.dp), | 107 | modifier = Modifier.padding(20.dp), |
-
请 注册 或 登录 后发表评论