add test module

This commit is contained in:
2026-08-16 15:39:52 +08:00
parent d0310620fc
commit 6e4d93cea6
46 changed files with 3880 additions and 206 deletions

View File

@@ -2,7 +2,7 @@
Android SDK for online oral-training video playback. It provides an embeddable
Media3/ExoPlayer player, streaming cache, tablet gestures, sentence navigation,
and a placeholder interface for future imitation-quality scoring.
the server video catalog, and remote imitation-quality assessment.
## Modules
@@ -93,11 +93,36 @@ Override the service only when a staging or private deployment is required:
OralTrainerSdk.init(
context,
OralTrainerSdkConfig(
sentenceBoundaryApiBaseUrl = "https://video_service.d1kt.cn"
sentenceBoundaryApiBaseUrl = "https://video_service.d1kt.cn",
assessmentApiKey = BuildConfig.ORAL_TRAINER_CLIENT_KEY,
)
)
```
## Video Catalog
The SDK loads ready videos from `GET /api/v1/videos` and resolves both absolute
and relative stream URLs:
```kotlin
sdk.videoCatalogApi.fetch(object : VideoCatalogCallback {
override fun onSuccess(videos: List<TrainingVideoSummary>) {
val video = videos.first()
sdk.sentenceBoundaryApi.fetch(video.videoHash, object : SentenceBoundaryApiCallback {
override fun onSuccess(result: SentenceBoundaryApiResult) {
controller.loadItem(video.toTrainingMediaItem(result.sentences))
}
override fun onError(error: Throwable) {
controller.loadItem(video.toTrainingMediaItem())
}
})
}
override fun onError(error: Throwable) = Unit
})
```
## Local Video Testing
The computer path `/Users/...` is not visible to an Android device. For a
@@ -110,19 +135,40 @@ service and pass its URL as `TrainingMediaItem.uri`. The SDK streams it and
caches downloaded ranges locally. Copying large 4K files to each device is
better reserved for explicitly offline courses.
## Future Imitation Scoring
## Remote Imitation Scoring
Provide an implementation of `ImitationQualityAssessor` when the speech
assessment algorithm is ready:
Create the controller with the built-in remote assessor:
```kotlin
val remoteAssessor = sdk.createRemoteImitationQualityAssessor()
val controller = sdk.createController(
imitationAssessor = MyImitationQualityAssessor()
imitationAssessor = remoteAssessor
)
```
Then call `assessCurrentSentence(recordingUri, callback)` after the student
records a sentence.
records a sentence. The current `TrainingMediaItem.id` must be the server video
SHA-256, which is already true for items created by `TrainingVideoSummary`:
```kotlin
controller.assessCurrentSentence(
recordingUri = recordingUri,
locale = "en",
callback = object : ImitationAssessmentCallback {
override fun onResult(result: ImitationAssessmentResult) {
val passed = result.passed == true
val score = result.overallScore
val durationRatio = result.durationRatio
}
override fun onError(error: Throwable) = Unit
}
)
```
The server returns content, completeness, fluency, duration, pause, and speech
rate scores. Phoneme pronunciation and prosody are nullable until the dedicated
models are enabled.
## Build