Updated the processAudioLoop to mke sure that the buffer was always flushed after an output stream so we didn't miss any characters. Also made many modifications to the python script running on the Pico to ensure that we get dual inputs and neater outputs now.
This commit is contained in:
@@ -21,8 +21,8 @@ android {
|
|||||||
applicationId = "net.mmanningau.speechtokeyboard"
|
applicationId = "net.mmanningau.speechtokeyboard"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 14
|
versionCode = 15
|
||||||
versionName = "1.1.2"
|
versionName = "1.1.3"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val silenceRule = EndpointRule(
|
val silenceRule = EndpointRule(
|
||||||
mustContainNonSilence = false,
|
mustContainNonSilence = false,
|
||||||
minTrailingSilence = 2.4f,
|
minTrailingSilence = 1.2f,
|
||||||
minUtteranceLength = 0.0f
|
minUtteranceLength = 0.0f
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -214,6 +214,7 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
val cleanText = text.lowercase()
|
val cleanText = text.lowercase()
|
||||||
|
|
||||||
if (isEndpoint) {
|
if (isEndpoint) {
|
||||||
|
// CASE A: Natural Pause (Sentence Finished)
|
||||||
val punctuatedText = punctuator?.addPunctuation(cleanText) ?: cleanText
|
val punctuatedText = punctuator?.addPunctuation(cleanText) ?: cleanText
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
@@ -223,6 +224,8 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
localRec.reset(localStream)
|
localRec.reset(localStream)
|
||||||
} else {
|
} else {
|
||||||
|
// CASE B: Partial (Still talking)
|
||||||
|
// Update screen ONLY, do not send to Pico yet
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
outputText.text = "$committedText $cleanText"
|
outputText.text = "$committedText $cleanText"
|
||||||
}
|
}
|
||||||
@@ -230,6 +233,25 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- NEW: THE FLUSH BLOCK ---
|
||||||
|
// This runs when you hit "Stop". It grabs the last unspoken words.
|
||||||
|
val finalTail = localRec.getResult(localStream).text
|
||||||
|
if (finalTail.isNotEmpty()) {
|
||||||
|
val cleanTail = finalTail.lowercase()
|
||||||
|
val punctuatedTail = punctuator?.addPunctuation(cleanTail) ?: cleanTail
|
||||||
|
|
||||||
|
runOnUiThread {
|
||||||
|
committedText += "$punctuatedTail "
|
||||||
|
outputText.text = committedText
|
||||||
|
// FORCE SEND the remaining text
|
||||||
|
sendToPico("$punctuatedTail ")
|
||||||
|
}
|
||||||
|
// Reset for next time
|
||||||
|
localRec.reset(localStream)
|
||||||
|
}
|
||||||
|
// -----------------------------
|
||||||
|
|
||||||
record.stop()
|
record.stop()
|
||||||
record.release()
|
record.release()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user