Separate out empty transcription STT error

This commit is contained in:
Adam Gastineau 2025-11-27 09:21:36 -08:00
parent a8719a2140
commit 3759fd7cd5
2 changed files with 20 additions and 7 deletions

View File

@ -77,12 +77,19 @@ class InteractionFlowManager
if (didAbort) {
return
}
Log.d(TAG, "STT final transcription: $finalText")
setState(InteractionFlowState.PROCESSING)
contentCallback?.onFinalTranscription(finalText)
// Start conversation with the transcribed text
startConversationFromInput(finalText)
if (finalText.trim().isEmpty()) {
Log.d(TAG, "STT transcription was empty, skipping")
setState(InteractionFlowState.IDLE)
stateCallback?.onError(Error.SttError("Empty transcription"))
} else {
Log.d(TAG, "STT final transcription: $finalText")
setState(InteractionFlowState.PROCESSING)
contentCallback?.onFinalTranscription(finalText)
// Start conversation with the transcribed text
startConversationFromInput(finalText)
}
}
override fun onError(errorMessage: String) {

View File

@ -39,8 +39,14 @@ class DemoSttService : MablService("DemoSttService") {
client.stt.initialize(object : SttRecognitionListener() {
override fun onError(error: Int) {
try {
currentCallback?.onError("Recognition error: $error")
} catch (e: RemoteException) {
// RecognitionError.ERROR_NO_MATCH
if (error == 7) {
Log.d("DemoSttService", "No speech recognized")
currentCallback?.onFinalTranscription("")
} else {
currentCallback?.onError("Recognition error: $error")
}
} catch (e: Exception) {
Log.e("DemoSttService", "Callback error", e)
}
}