Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
Show language names in Samosa AI voice/language pickers and link speech docs
Jalebicbf84fe473e6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fa8f779..75c5481 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,14 @@ All notable changes to Gotcha are documented here.## [Unreleased]### Added+- **Voice and language pickers name the language.** The Speech page listed raw+ codes — `hi`, `en-us`, `af_heart` — with nothing saying which language each+ one is. Transcription language entries now read like `hi — Hindi`, the field+ shows the name of the code you typed, and TTS voices read like+ `af_heart — English (United States), female` (the language and gender are+ taken from the server, or read off Kokoro-style voice ids when it sends+ none). The Samosa AI TTS and STT sections also link to the Samosa AI docs on+ choosing a voice and language.- **Two sample chats on a fresh install.** The chat list opened on nothing atall, so the one thing a first-time user couldn't find out was what Gotcha isfor. A new install now starts with two short transcripts that show it: adiff --git a/app/src/main/java/com/gotcha/audio/AudioLanguageLabels.kt b/app/src/main/java/com/gotcha/audio/AudioLanguageLabels.ktnew file mode 100644index 0000000..93845ff--- /dev/null+++ b/app/src/main/java/com/gotcha/audio/AudioLanguageLabels.kt@@ -0,0 +1,69 @@+package com.gotcha.audio++import java.util.Locale++/**+ * Human-readable names for the raw language codes and voice ids the audio+ * servers publish (issue #75). `/v1/models` hands back codes like `hi`, `en-us`+ * or `af_heart`; the pickers show those next to a name so the user can tell+ * which language each entry is without looking the code up.+ */+object AudioLanguageLabels {++ /** Where the Samosa AI docs explain choosing speech providers, voices and languages. */+ const val SPEECH_DOCS_URL = "https://samosa-ai.com/gotcha/docs/getting-started#5-Speech"++ /** Codes the JDK has no name for, or that are not language tags at all. */+ private val OVERRIDES = mapOf(+ "jw" to "Javanese", // Whisper's legacy code for `jv`+ "multilingual" to "Multiple languages",+ "auto" to "Auto-detect"+ )++ /**+ * Kokoro voice ids start with a language letter and a gender letter+ * (`af_heart` = American English, female). Used only when the server did+ * not send a `language` for the voice.+ */+ private val KOKORO_VOICE_ID = Regex("^([abefhijpz])([fm])_", RegexOption.IGNORE_CASE)+ private val KOKORO_LANGUAGES = mapOf(+ 'a' to "en-US",+ 'b' to "en-GB",+ 'e' to "es",+ 'f' to "fr-FR",+ 'h' to "hi",+ 'i' to "it",+ 'j' to "ja",+ 'p' to "pt-BR",+ 'z' to "zh-CN"+ )++ /**+ * English name for [code] (`hi` → "Hindi", `en-us` → "English (United States)"),+ * or null when the code is blank or not a language the JDK recognises.+ */+ fun describe(code: String): String? {+ val trimmed = code.trim()+ if (trimmed.isEmpty()) return null+ OVERRIDES[trimmed.lowercase()]?.let { return it }+ val locale = Locale.forLanguageTag(trimmed.replace('_', '-'))+ val language = locale.language+ if (language.isEmpty()) return null+ // An unknown code comes back as itself rather than as a name.+ if (locale.getDisplayLanguage(Locale.ENGLISH).equals(language, ignoreCase = true)) return null+ return locale.getDisplayName(Locale.ENGLISH).takeIf { it.isNotBlank() }+ }++ /** "`hi` — Hindi" style picker text; the bare code when it has no known name. */+ fun label(code: String): String = describe(code)?.let { "$code — $it" } ?: code++ /** Language tag implied by a Kokoro-style voice id, or null. */+ fun languageFromVoiceId(voiceId: String): String? =+ KOKORO_VOICE_ID.find(voiceId)?.let { KOKORO_LANGUAGES[it.groupValues[1].lowercase()[0]] }++ /** Gender implied by a Kokoro-style voice id, or null. */+ fun genderFromVoiceId(voiceId: String): String? =+ KOKORO_VOICE_ID.find(voiceId)?.let { match ->+ if (match.groupValues[2].equals("f", ignoreCase = true)) "female" else "male"+ }+}diff --git a/app/src/main/java/com/gotcha/audio/AudioModels.kt b/app/src/main/java/com/gotcha/audio/AudioModels.ktindex cef3d7f..b84c3bc 100644--- a/app/src/main/java/com/gotcha/audio/AudioModels.kt+++ b/app/src/main/java/com/gotcha/audio/AudioModels.kt@@ -52,16 +52,23 @@ data class VoiceInfo(val language: String = "",val gender: String = "") {+ /**+ * Picker text: the id followed by the language's name and the gender, e.g.+ * `af_heart — English (United States), female`. When the server sent no+ * language or gender, both are read off Kokoro-style ids where possible.+ */val displayLabel: Stringget() {+ val languageCode = language.ifBlank { AudioLanguageLabels.languageFromVoiceId(id).orEmpty() }val details = listOfNotNull(- language.takeIf { it.isNotBlank() },- gender.takeIf { it.isNotBlank() }+ name.takeIf { it.isNotBlank() && !it.equals(id, ignoreCase = true) },+ languageCode.takeIf { it.isNotBlank() }?.let { AudioLanguageLabels.describe(it) ?: it },+ gender.ifBlank { AudioLanguageLabels.genderFromVoiceId(id).orEmpty() }.takeIf { it.isNotBlank() })return if (details.isEmpty()) {id} else {- "$id (${details.joinToString(", ")})"+ "$id — ${details.joinToString(", ")}"}}}diff --git a/app/src/main/java/com/gotcha/ui/SpeechScreen.kt b/app/src/main/java/com/gotcha/ui/SpeechScreen.ktindex e3165c9..bf950b4 100644--- a/app/src/main/java/com/gotcha/ui/SpeechScreen.kt+++ b/app/src/main/java/com/gotcha/ui/SpeechScreen.kt@@ -1,5 +1,6 @@package com.gotcha.ui+import androidx.compose.foundation.clickableimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxWidth@@ -22,9 +23,13 @@ import androidx.compose.runtime.rememberCoroutineScopeimport androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier+import androidx.compose.ui.platform.LocalUriHandler+import androidx.compose.ui.platform.testTagimport androidx.compose.ui.text.input.PasswordVisualTransformationimport androidx.compose.ui.text.input.VisualTransformation+import androidx.compose.ui.text.style.TextDecorationimport com.gotcha.BuildConfig+import com.gotcha.audio.AudioLanguageLabelsimport com.gotcha.audio.AudioModelimport com.gotcha.audio.AudioProviderimport com.gotcha.audio.VoiceInfo@@ -303,6 +308,7 @@ fun SpeechScreen(},onClearVoice = { ttsVoice = "" })+ SpeechDocsLink(modifier = Modifier.testTag("settings_tts_docs_link"))}AudioProvider.API -> {OutlinedTextField(@@ -463,6 +469,7 @@ fun SpeechScreen(style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)+ SpeechDocsLink(modifier = Modifier.testTag("settings_stt_docs_link"))}AudioProvider.API -> {OutlinedTextField(@@ -774,6 +781,7 @@ private fun SttLanguagePicker(onValueChange = onSelect,label = { Text("Transcription language override") },placeholder = { Text("Follow voice language / auto-detect") },+ supportingText = AudioLanguageLabels.describe(selectedLanguage)?.let { name -> { Text(name) } },trailingIcon = {ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded)},@@ -789,7 +797,7 @@ private fun SttLanguagePicker()languagesList.forEach { lang ->DropdownMenuItem(- text = { Text(lang) },+ text = { Text(AudioLanguageLabels.label(lang)) },onClick = { onSelect(lang) })}@@ -797,6 +805,21 @@ private fun SttLanguagePicker(}}+/** Inline link to the Samosa AI docs on choosing a voice and language. */+@Composable+private fun SpeechDocsLink(modifier: Modifier = Modifier) {+ val uriHandler = LocalUriHandler.current+ Text(+ text = "How to choose a voice and language (Samosa AI docs)",+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.primary,+ textDecoration = TextDecoration.Underline,+ modifier = modifier+ .fillMaxWidth()+ .clickable { uriHandler.openUri(AudioLanguageLabels.SPEECH_DOCS_URL) }+ )+}+private val COMMON_STT_LANGUAGES = listOf("en", "zh", "de", "es", "ru", "ko", "fr", "ja", "pt", "tr", "pl", "ca", "nl", "ar","sv", "it", "id", "hi", "fi", "vi", "he", "uk", "el", "ms", "cs", "ro", "da", "hu",diff --git a/app/src/test/java/com/gotcha/audio/AudioApiTest.kt b/app/src/test/java/com/gotcha/audio/AudioApiTest.ktindex 04d1ab9..54befc7 100644--- a/app/src/test/java/com/gotcha/audio/AudioApiTest.kt+++ b/app/src/test/java/com/gotcha/audio/AudioApiTest.kt@@ -94,7 +94,7 @@ class AudioApiTest {assertEquals("af_heart", tts.voices[0].id)assertEquals("en-us", tts.voices[0].language)assertEquals("female", tts.voices[0].gender)- assertEquals("af_heart (en-us, female)", tts.voices[0].displayLabel)+ assertEquals("af_heart — English (United States), female", tts.voices[0].displayLabel)val stt = models[1]assertEquals("faster-whisper-medium", stt.id)diff --git a/app/src/test/java/com/gotcha/audio/AudioLanguageLabelsTest.kt b/app/src/test/java/com/gotcha/audio/AudioLanguageLabelsTest.ktnew file mode 100644index 0000000..8bca9b4--- /dev/null+++ b/app/src/test/java/com/gotcha/audio/AudioLanguageLabelsTest.kt@@ -0,0 +1,45 @@+package com.gotcha.audio++import org.junit.Assert.assertEquals+import org.junit.Assert.assertNull+import org.junit.Test++class AudioLanguageLabelsTest {++ @Test+ fun `plain and regional codes get English names`() {+ assertEquals("Hindi", AudioLanguageLabels.describe("hi"))+ assertEquals("English (United States)", AudioLanguageLabels.describe("en-us"))+ assertEquals("Portuguese (Brazil)", AudioLanguageLabels.describe("pt_BR"))+ assertEquals("Hawaiian", AudioLanguageLabels.describe("haw"))+ }++ @Test+ fun `codes the JDK does not know use overrides or return null`() {+ assertEquals("Javanese", AudioLanguageLabels.describe("jw"))+ assertEquals("Multiple languages", AudioLanguageLabels.describe("multilingual"))+ assertNull(AudioLanguageLabels.describe("qq"))+ assertNull(AudioLanguageLabels.describe(""))+ }++ @Test+ fun `label pairs the code with its name and falls back to the bare code`() {+ assertEquals("hi — Hindi", AudioLanguageLabels.label("hi"))+ assertEquals("qq", AudioLanguageLabels.label("qq"))+ }++ @Test+ fun `voice label infers language and gender from Kokoro ids`() {+ assertEquals("bm_george — English (United Kingdom), male", VoiceInfo(id = "bm_george").displayLabel)+ assertEquals("hf_alpha — Hindi, female", VoiceInfo(id = "hf_alpha").displayLabel)+ assertEquals("custom-voice", VoiceInfo(id = "custom-voice").displayLabel)+ }++ @Test+ fun `voice label prefers server metadata and keeps a distinct name`() {+ assertEquals(+ "v1 — Priya, Hindi (India), female",+ VoiceInfo(id = "v1", name = "Priya", language = "hi-IN", gender = "female").displayLabel+ )+ }+}