ADded the punctuation sections to the code - but have not added the zip extraction to include this automatically - might ahve to add another upload manager specifically for this one file I think, as it is really messy to get your hands on through other means....
This commit is contained in:
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-01-22T04:36:45.393638454Z">
|
<DropdownSelection timestamp="2026-01-23T01:29:57.710335816Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/michael/.android/avd/Pixel_5_API_31_Android_12_.avd" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=DKTAB13NEU0019483" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ android {
|
|||||||
applicationId = "net.mmanningau.speechtokeyboard"
|
applicationId = "net.mmanningau.speechtokeyboard"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 10
|
versionCode = 11
|
||||||
versionName = "1.0"
|
versionName = "1.1"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ import com.k2fsa.sherpa.onnx.OnlineTransducerModelConfig
|
|||||||
import com.k2fsa.sherpa.onnx.OnlineStream
|
import com.k2fsa.sherpa.onnx.OnlineStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
import com.k2fsa.sherpa.onnx.OfflinePunctuation
|
||||||
|
import com.k2fsa.sherpa.onnx.OfflinePunctuationConfig
|
||||||
|
import com.k2fsa.sherpa.onnx.OfflinePunctuationModelConfig
|
||||||
|
|
||||||
class TestModelActivity : AppCompatActivity() {
|
class TestModelActivity : AppCompatActivity() {
|
||||||
|
|
||||||
// UI Components
|
// UI Components
|
||||||
@@ -39,6 +43,9 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
private var isRecording = false
|
private var isRecording = false
|
||||||
private var recordingThread: Thread? = null
|
private var recordingThread: Thread? = null
|
||||||
|
|
||||||
|
// Punctuation variables
|
||||||
|
private var punctuator: OfflinePunctuation? = null
|
||||||
|
|
||||||
// USB Components
|
// USB Components
|
||||||
private var usbPort: UsbSerialPort? = null
|
private var usbPort: UsbSerialPort? = null
|
||||||
|
|
||||||
@@ -117,6 +124,23 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
outputText.text = "Engine Loaded. Ready to Stream."
|
outputText.text = "Engine Loaded. Ready to Stream."
|
||||||
|
|
||||||
|
// ... existing recognizer init code ...
|
||||||
|
|
||||||
|
// 5. Initialize Punctuation Engine
|
||||||
|
val punctPath = File(modelDir, "punct_model.onnx").absolutePath
|
||||||
|
|
||||||
|
if (File(punctPath).exists()) {
|
||||||
|
// CORRECTED: Wrap the path inside 'OfflinePunctuationModelConfig'
|
||||||
|
val punctConfig = OfflinePunctuationConfig(
|
||||||
|
model = OfflinePunctuationModelConfig(ctTransformer = punctPath)
|
||||||
|
)
|
||||||
|
|
||||||
|
punctuator = OfflinePunctuation(config = punctConfig)
|
||||||
|
outputText.append("\n+ Punctuation Ready")
|
||||||
|
} else {
|
||||||
|
outputText.append("\n(No Punctuation model found)")
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Sherpa", "Init Error", e)
|
Log.e("Sherpa", "Init Error", e)
|
||||||
outputText.text = "Init Error: ${e.message}"
|
outputText.text = "Init Error: ${e.message}"
|
||||||
@@ -205,10 +229,15 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
// FIX 2: THE ORDER OF OPERATIONS
|
// FIX 2: THE ORDER OF OPERATIONS
|
||||||
|
|
||||||
// A. Update UI first
|
// A. Update UI first
|
||||||
|
// 1. PUNCTUATE
|
||||||
|
// We pass the raw text to the punctuator
|
||||||
|
val punctuatedText = punctuator?.addPunctuation(cleanText) ?: cleanText
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
committedText += "$cleanText "
|
// 2. Commit the BEAUTIFUL text
|
||||||
|
committedText += "$punctuatedText "
|
||||||
outputText.text = committedText
|
outputText.text = committedText
|
||||||
sendToPico("$cleanText ")
|
sendToPico("$punctuatedText ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// B. RESET IMMEDIATELY ON BACKGROUND THREAD
|
// B. RESET IMMEDIATELY ON BACKGROUND THREAD
|
||||||
|
|||||||
Reference in New Issue
Block a user