Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {
}
val releaseSigning = if (hasReleaseKeystore) signingConfigs.getByName("release") else null

val baseVersionName = "2.5.4"
val baseVersionName = "2.5.5"

defaultConfig {
applicationId = "me.shirobyte42.glosso"
Expand All @@ -58,7 +58,9 @@ android {
// 2222 is 2.5.0: American English, "Your turn" and spaced review.
// 2223 is 2.5.1: Russian A1 rewritten from Russian culture.
// 2226 is 2.5.4: the v2 usage statistics and crash reports.
versionCode = 2226
// 2227 is 2.5.5: Spanish, the course switcher and the first F-Droid build.
// 2227 is 2.5.5: the first F-Droid release; server-anchored time for streaks.
versionCode = 2227
versionName = baseVersionName
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class GlossoApplication : Application(), SingletonImageLoader.Factory {
wireSharedCode()
ServerPreferences.init(this, BuildConfig.API_BASE_URL)
DeviceId.init(this)
TrustedClock.init(this)
Analytics.init(this)
CrashReporter.install(this)
ApiCache.init(this)
Expand Down
3 changes: 2 additions & 1 deletion deploy/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ GLOSSO_ASSET_CHECKSUMS=
# Reconocimientos simultaneos (2 vCPU: no subir de 1-2).
GLOSSO_MAX_CONCURRENT=1
# Espera maxima en cola antes de devolver 503 (ms).
GLOSSO_QUEUE_WAIT_MS=30000
GLOSSO_QUEUE_WAIT_MS=12000
GLOSSO_MAX_QUEUED=8
# 1 = logs del engine (fonemas). Dejar vacio en produccion.
GLOSSO_DEBUG=
# Origenes CORS permitidos para web, separados por coma. Vacio = sin CORS.
Expand Down
3 changes: 2 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ services:
GLOSSO_INGEST_TOKEN: ${GLOSSO_INGEST_TOKEN:-}
GLOSSO_BOOTSTRAP: ${GLOSSO_BOOTSTRAP:-}
GLOSSO_MAX_CONCURRENT: ${GLOSSO_MAX_CONCURRENT:-1}
GLOSSO_QUEUE_WAIT_MS: ${GLOSSO_QUEUE_WAIT_MS:-30000}
GLOSSO_QUEUE_WAIT_MS: ${GLOSSO_QUEUE_WAIT_MS:-12000}
GLOSSO_MAX_QUEUED: ${GLOSSO_MAX_QUEUED:-8}
GLOSSO_DEBUG: ${GLOSSO_DEBUG:-}
GLOSSO_ANALYTICS_RETENTION_DAYS: ${GLOSSO_ANALYTICS_RETENTION_DAYS:-180}
# Copia de los eventos de la app en umami (docs/ANALYTICS-BETA.md). Vacio
Expand Down
3 changes: 2 additions & 1 deletion docs/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ sudo systemctl enable --now glosso-server
| `GLOSSO_ASSETS_DIR` | `data/assets` | Carpeta de assets estaticos |
| `GLOSSO_BOOTSTRAP` | (vacio) | `1` descarga modelo/vocab/CMUdict en el primer arranque |
| `GLOSSO_MAX_CONCURRENT` | `1` | Reconocimientos simultaneos admitidos |
| `GLOSSO_QUEUE_WAIT_MS` | `30000` | Espera maxima en cola antes de devolver 503 |
| `GLOSSO_QUEUE_WAIT_MS` | `12000` | Espera maxima en cola antes de devolver 503; menor que el timeout de puntuacion de la app (30 s) |
| `GLOSSO_MAX_QUEUED` | `8` | Puntuaciones en espera como maximo; con la cola llena el servidor responde 503 al instante y la app reintenta |
| `GLOSSO_DEBUG` | (vacio) | `1` activa logs del engine (fonemas) |
| `GLOSSO_ADMIN_TOKEN` | (vacio) | Token que protege `/metrics`, `/stats` y las vistas de analitica. Sin el, cerrados |
| `GLOSSO_API_KEY` | (vacio) | Credencial de cliente (`X-Api-Key`) que protege `/v1/score`. Sin ella, scoring abierto (dev/emulador). **No definir en produccion hasta que la app envie la cabecera** |
Expand Down
30 changes: 30 additions & 0 deletions docs/FDROID.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ The only binary in git is `gradle/wrapper/gradle-wrapper.jar`, which the scanner
removes on its own. Repositories are only `google()`, `mavenCentral()` and the
Gradle plugin portal. The model, vocabulary and content are gitignored.

**The web app's binaries.** The repository also holds the web app (`docs/WEB.md`),
whose Ogg decoder is a committed WebAssembly build of the vendored stb_vorbis
(`shared/src/wasmJsMain/resources/stb_vorbis.wasm`, built from source by
`shared/src/nativeInterop/stb_vorbis/build-wasm.sh`). `fdroid scanner` flags it
as a binary. The Android app never uses it, so the recipe deletes it (`rm:`) and
turns the web target off (`glosso.web=false`), which also keeps the Kotlin/Wasm
toolchain (a prebuilt Node download) out of the F-Droid build.

**Self-updater.** None. The server's version policy is only a dismissible notice
with no link and no download.

Expand Down Expand Up @@ -123,3 +131,25 @@ ones `tools/fetch-assets.sh` downloads.

Lesson packs are not importable: they are fetched per lesson from the content
manifest and have no file format of their own yet.

## Releasing a version to F-Droid

Checked for 2.5.5 (2227) on 2026-11-22: the steps below passed locally.

1. Bump `baseVersionName` and `versionCode` in `androidApp/build.gradle.kts`, add
`fastlane/metadata/android/<locale>/changelogs/<versionCode>.txt` (max 500
characters) for every locale, and set the same version in the recipe's build
entry, `CurrentVersion` and `CurrentVersionCode`.
2. Check the recipe and the build the way F-Droid runs them:
- `fdroid readmeta` and `fdroid lint me.shirobyte42.glosso` in a directory with
the recipe under `metadata/` and fdroiddata's `config/` (sparse clone of
https://gitlab.com/fdroid/fdroiddata).
- From a fresh clone of the tagged commit, delete the `rm:` paths, then
`ANDROID_HOME=... ./gradlew :androidApp:assembleFdroidRelease -Pglosso.ios=false -Pglosso.web=false`.
- `fdroid scanner --exit-code` on that APK, and the scanner's `scan_source` on
the clone: the only source finding is the `rm:`'d `stb_vorbis.wasm`.
3. Tag the release commit `v<versionName>` and push the tag. F-Droid builds from
tags (`UpdateCheckMode: Tags`), and the recipe's `commit:` is the tag.
4. First submission only: open the merge request to fdroiddata with
`metadata/me.shirobyte42.glosso.yml`. Later versions are picked up from new
tags (`AutoUpdateMode: Version`).
2 changes: 1 addition & 1 deletion fastlane/metadata/android/ar/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
تطبيق Glosso دورة لغات تقيس نطقك فعلًا. يستمع إلى كل تسجيل، ويتعرف على الأصوات التي نطقتها حقًا، ويقارنها بالأصوات المتوقعة، ثم يخبرك بالضبط أي صوت تحتاج إلى تصحيحه.

اللغات: الإنجليزية (البريطانية والأمريكية) والفرنسية والألمانية والروسية.
الدورات: الإنجليزية (البريطانية والأمريكية)، إضافة إلى الروسية والإسبانية كدورتين تجريبيتين للمبتدئين.

<b>ما ستحصل عليه</b>
<ul>
Expand Down
9 changes: 9 additions & 0 deletions fastlane/metadata/android/de-DE/changelogs/2227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Neu: Spanisch lernen (experimentell) und ein umfangreicherer Russischkurs.
- Kurs mit einem Tipp unter Heute oder Lektionen wechseln.
- Freies Üben ist jetzt unter Heute.
- Das Üben konzentriert sich auf deine schwierigsten Laute.
- Klarere Korrekturen und gemischte Antworten.
- Jede Sprache steht unter ihrem eigenen Namen.
- Flüssigerer Startbildschirm.
- Serien zählen nach Serverzeit, nicht nach der Handyuhr.
- Ein Download ohne Verbindung zeigt nun, dass er wartet.
2 changes: 1 addition & 1 deletion fastlane/metadata/android/de-DE/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Glosso ist ein Sprachkurs, der deine Aussprache wirklich misst. Er hört jeden Versuch, erkennt die Laute, die du tatsächlich gesprochen hast, vergleicht sie mit den erwarteten und sagt dir genau, welchen Laut du verbessern solltest.

Sprachen: Englisch (britisch und amerikanisch), Französisch, Deutsch und Russisch.
Kurse: Englisch (britisch und amerikanisch), dazu Russisch und Spanisch als experimentelle Anfängerkurse.

<b>Was du bekommst</b>
<ul>
Expand Down
9 changes: 9 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/2227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- New: learn Spanish (experimental), and a fuller Russian course.
- Switch course in one tap from Today or Lessons.
- Free practice is now on Today.
- Practice focuses on the sounds you miss most.
- Clearer corrections and shuffled answers.
- Each language appears under its own name.
- Smoother first-run screen.
- Streaks count by the server's time, not the phone's clock.
- A model download started offline now shows that it is waiting.
2 changes: 1 addition & 1 deletion fastlane/metadata/android/en-US/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Glosso is a language course that measures your pronunciation for real. It listens to each take, recognizes the sounds you actually made, compares them with the expected ones and tells you exactly which sound to fix.

Languages: English (British and American), French, German and Russian.
Courses: English (British and American), plus Russian and Spanish as experimental beginner courses.

<b>What you get</b>
<ul>
Expand Down
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions fastlane/metadata/android/es-ES/changelogs/2227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Nuevo: aprende español (experimental) y un curso de ruso más completo.
- Cambia de curso con un toque desde Hoy o Lecciones.
- La práctica libre ahora está en Hoy.
- La práctica se centra en los sonidos que más fallas.
- Correcciones más claras y respuestas barajadas.
- Cada idioma aparece con su propio nombre.
- Pantalla de bienvenida más fluida.
- Las rachas usan la hora del servidor, no la del móvil.
- Una descarga del modelo sin conexión ahora indica que está esperando.
2 changes: 1 addition & 1 deletion fastlane/metadata/android/es-ES/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Glosso es un curso de idiomas que mide tu pronunciación de verdad. Escucha cada intento, reconoce los sonidos que has hecho de verdad, los compara con los esperados y te dice exactamente qué sonido corregir.

Idiomas: inglés (británico y americano), francés, alemán y ruso.
Cursos: inglés (británico y americano), además de ruso y español como cursos experimentales de nivel inicial.

<b>Qué incluye</b>
<ul>
Expand Down
9 changes: 9 additions & 0 deletions fastlane/metadata/android/fr-FR/changelogs/2227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Nouveau : apprenez l'espagnol (expérimental), et un cours de russe plus complet.
- Changez de cours en un geste depuis Aujourd'hui ou Leçons.
- La pratique libre est maintenant sur Aujourd'hui.
- La pratique cible les sons que vous ratez le plus.
- Corrections plus claires et réponses mélangées.
- Chaque langue apparaît sous son propre nom.
- Écran d'accueil plus fluide.
- Les séries suivent l'heure du serveur, pas celle du téléphone.
- Un téléchargement hors ligne indique son attente.
2 changes: 1 addition & 1 deletion fastlane/metadata/android/fr-FR/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Glosso est un cours de langues qui mesure vraiment votre prononciation. Il écoute chaque essai, reconnaît les sons que vous avez réellement produits, les compare aux sons attendus et vous dit exactement quel son corriger.

Langues : anglais (britannique et américain), français, allemand et russe.
Cours : anglais (britannique et américain), ainsi que russe et espagnol en cours expérimentaux pour débutants.

<b>Ce que vous obtenez</b>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion fastlane/metadata/android/hi-IN/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Glosso एक भाषा कोर्स है जो आपके उच्चारण को सच में जाँचता है। यह आपकी हर रिकॉर्डिंग सुनता है, पहचानता है कि आपने असल में कौन से साउंड बोले, उन्हें सही साउंड से मिलाता है और ठीक-ठीक बताता है कि कौन सा साउंड सुधारना है।

भाषाएँ: अंग्रेज़ी (ब्रिटिश और अमेरिकन), फ़्रेंच, जर्मन और रूसी।
कोर्स: अंग्रेज़ी (ब्रिटिश और अमेरिकन), साथ ही रूसी और स्पैनिश शुरुआती स्तर के प्रायोगिक कोर्स के रूप में।

<b>आपको क्या मिलता है</b>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion fastlane/metadata/android/ru-RU/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Glosso - курс иностранных языков, который по-настоящему оценивает ваше произношение. Приложение слушает каждую попытку, распознаёт звуки, которые вы действительно произнесли, сравнивает их с эталоном и точно говорит, какой звук нужно исправить.

Языки: английский (британский и американский), французский, немецкий и русский.
Курсы: английский (британский и американский), а также русский и испанский как экспериментальные курсы для начинающих.

<b>Что вы получаете</b>
<ul>
Expand Down
13 changes: 8 additions & 5 deletions metadata/me.shirobyte42.glosso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ RepoType: git
Repo: https://github.com/IgnacioLD/glosso.git

Builds:
- versionName: 2.5.4
versionCode: 2226
commit: v2.5.4
- versionName: 2.5.5
versionCode: 2227
commit: v2.5.5
subdir: androidApp
rm:
- shared/src/wasmJsMain/resources/stb_vorbis.wasm
gradle:
- fdroid
gradleprops:
- glosso.ios=false
- glosso.web=false

AutoUpdateMode: Version
UpdateCheckMode: Tags
CurrentVersion: 2.5.4
CurrentVersionCode: 2226
CurrentVersion: 2.5.5
CurrentVersionCode: 2227
36 changes: 15 additions & 21 deletions server/src/main/kotlin/com/glosso/server/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
Expand Down Expand Up @@ -728,10 +726,14 @@ fun Application.module(
// test shows the host benefits from it.
val maxConcurrent = System.getenv("GLOSSO_MAX_CONCURRENT")?.toIntOrNull()?.coerceAtLeast(1)
?: 1
val queueWaitMs = System.getenv("GLOSSO_QUEUE_WAIT_MS")?.toLongOrNull() ?: 30_000L
val inferenceSlots = Semaphore(maxConcurrent)
// Below the app's 30 s score timeout minus a slow inference, so a busy server
// answers 503 (the app retries) instead of the phone timing out mid-wait.
val queueWaitMs = System.getenv("GLOSSO_QUEUE_WAIT_MS")?.toLongOrNull() ?: 12_000L
// Beyond this many waiting takes the server answers 503 at once (the app retries).
val maxQueued = System.getenv("GLOSSO_MAX_QUEUED")?.toIntOrNull()?.coerceAtLeast(0) ?: 8
val inferenceGate = InferenceGate(maxConcurrent, maxQueued, queueWaitMs)
val inFlight = AtomicInteger(0)
logger.info { "Inference gate: maxConcurrent=$maxConcurrent, queueWaitMs=$queueWaitMs" }
logger.info { "Inference gate: maxConcurrent=$maxConcurrent, maxQueued=$maxQueued, queueWaitMs=$queueWaitMs" }

// First-party analytics: the store the caller passed (the production
// overload builds it from the environment); null disables it cleanly.
Expand Down Expand Up @@ -1297,10 +1299,7 @@ fun Application.module(

// Suspend while waiting for a slot; never block a thread, or the
// dispatcher starves and inference collapses.
val admitted = withTimeoutOrNull(queueWaitMs) {
inferenceSlots.acquire()
true
} ?: false
val admitted = inferenceGate.admit()
if (!admitted) {
scoreBusy.increment()
call.response.header(HttpHeaders.RetryAfter, "2")
Expand Down Expand Up @@ -1334,7 +1333,7 @@ fun Application.module(
analysis.recognition.ipa
} finally {
inFlight.decrementAndGet()
inferenceSlots.release()
inferenceGate.release()
}
} else if (!request.actualIpa.isNullOrBlank()) {
request.actualIpa
Expand Down Expand Up @@ -1474,10 +1473,7 @@ fun Application.module(
ErrorResponse("Recognition model is not ready"),
)
}
val admitted = withTimeoutOrNull(queueWaitMs) {
inferenceSlots.acquire()
true
} ?: false
val admitted = inferenceGate.admit()
if (!admitted) {
scoreBusy.increment()
call.response.header(HttpHeaders.RetryAfter, "2")
Expand All @@ -1491,7 +1487,7 @@ fun Application.module(
withContext(Dispatchers.Default) { recognizer.recognize(request.audioBase64) }
} finally {
inFlight.decrementAndGet()
inferenceSlots.release()
inferenceGate.release()
}
if (ipa.isNullOrBlank()) {
scoreError.increment()
Expand Down Expand Up @@ -1550,10 +1546,7 @@ fun Application.module(
ErrorResponse("Recognition model is not ready"),
)
}
val admitted = withTimeoutOrNull(queueWaitMs) {
inferenceSlots.acquire()
true
} ?: false
val admitted = inferenceGate.admit()
if (!admitted) {
scoreBusy.increment()
call.response.header(HttpHeaders.RetryAfter, "2")
Expand All @@ -1567,7 +1560,7 @@ fun Application.module(
withContext(Dispatchers.Default) { recognizer.analyze(request.audioBase64, expectedIpa) }
} finally {
inFlight.decrementAndGet()
inferenceSlots.release()
inferenceGate.release()
}
if (analysis == null) {
scoreError.increment()
Expand Down Expand Up @@ -2250,7 +2243,8 @@ fun Application.module(
mapOf(
"inFlight" to inFlight.get(),
"maxConcurrent" to maxConcurrent,
"availableSlots" to inferenceSlots.availablePermits,
"availableSlots" to inferenceGate.availablePermits,
"queued" to inferenceGate.queued,
),
)
}
Expand Down
35 changes: 35 additions & 0 deletions server/src/main/kotlin/com/glosso/server/InferenceGate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.glosso.server

import java.util.concurrent.atomic.AtomicInteger
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.withTimeoutOrNull

/**
* Admission to the CPU-bound recognizer: [maxConcurrent] runs at a time, at most
* [maxWaiting] requests queued behind them, each for at most [waitMs]. A full
* queue is refused at once, so a burst gets a fast 503 the app retries instead
* of everyone waiting out the clock and failing together.
*/
class InferenceGate(maxConcurrent: Int, private val maxWaiting: Int, private val waitMs: Long) {
private val slots = Semaphore(maxConcurrent)
private val waiting = AtomicInteger(0)

val availablePermits: Int get() = slots.availablePermits
val queued: Int get() = waiting.get()

/** True with a slot held (pair with [release]); false means answer 503. */
suspend fun admit(): Boolean {
if (slots.tryAcquire()) return true
if (waiting.incrementAndGet() > maxWaiting) {
waiting.decrementAndGet()
return false
}
return try {
withTimeoutOrNull(waitMs) { slots.acquire(); true } ?: false
} finally {
waiting.decrementAndGet()
}
}

fun release() = slots.release()
}
33 changes: 33 additions & 0 deletions server/src/test/kotlin/com/glosso/server/InferenceGateTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.glosso.server

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlinx.coroutines.async
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runTest

class InferenceGateTest {

@Test
fun fullQueueIsRefusedAtOnce() = runTest {
val gate = InferenceGate(maxConcurrent = 1, maxWaiting = 1, waitMs = 10_000)
assertTrue(gate.admit())
val queued = async { gate.admit() }
advanceTimeBy(1)
assertEquals(1, gate.queued)
assertFalse(gate.admit()) // the queue is full: no wait
gate.release()
assertTrue(queued.await())
assertEquals(0, gate.queued)
}

@Test
fun waitRunsOut() = runTest {
val gate = InferenceGate(maxConcurrent = 1, maxWaiting = 4, waitMs = 1_000)
assertTrue(gate.admit())
assertFalse(gate.admit())
assertEquals(0, gate.queued)
}
}
Loading