package com.sherpaonnxofflinestt.models /** * Configuration for speaker diarization */ data class DiarizationConfig( val speakerThreshold: Float = 0.55f, // Min similarity for speaker assignment (lenient) val embeddingThreshold: Float = 0.70f, // Min similarity for profile update (strict) val minSpeechDurationMs: Int = 800, // Min speech duration to create speaker val minEmbeddingUpdateMs: Int = 500, // Min speech duration to update profile val maxSpeakers: Int = 10, // Limit tracked speakers (LRU eviction) val embeddingAverageWeight: Float = 0.2f, // Weight for running average update val onboardingSegments: Int = 3, // First N segments always assigned to Speaker 1 val minSpeechForNewSpeaker: Int = 3000 // Min accumulated speech (ms) before creating new speaker ) /** * Configuration for STT initialization */ data class STTConfig( val sampleRate: Int = 16000, val vadThreshold: Float = 0.5f, val vadMinSpeechMs: Int = 300, val vadMinSilenceMs: Int = 500, val modelPath: String, val tokensPath: String, val modelType: String = "streaming", val denoiserModelPath: String? = null, val diarizationModelPath: String? = null, val diarizationConfig: DiarizationConfig = DiarizationConfig(), val provider: String = "cpu" ) /** * Speaker profile for diarization */ data class SpeakerProfile( val speakerId: Int, var embedding: FloatArray, var numSegments: Int, var status: String, // "pending" or "confirmed" var totalSpeechDurationMs: Long = 0, var lastSeenTimestamp: Long = System.currentTimeMillis() ) { override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as SpeakerProfile return speakerId == other.speakerId } override fun hashCode(): Int = speakerId } /** * VAD state machine states */ sealed class VADState { object Silence : VADState() object SpeechStart : VADState() object Speech : VADState() object SpeechEnd : VADState() val name: String get() = when (this) { is Silence -> "silence" is SpeechStart -> "speech_start" is Speech -> "speech" is SpeechEnd -> "speech_end" } companion object { fun fromString(state: String): VADState = when (state) { "silence" -> Silence "speech_start" -> SpeechStart "speech" -> Speech "speech_end" -> SpeechEnd else -> Silence } } } /** * Transcript result from STT */ data class TranscriptResult( val text: String, val isFinal: Boolean, val startTime: Long, val endTime: Long, val speakerId: Int = -1 ) /** * VAD processing result */ data class VADResult( val isSpeech: Boolean, val probability: Float )