Compare commits
2 Commits
StreamingO
...
2a8f004916
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a8f004916 | |||
| ac7d51b46e |
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<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">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/michael/.android/avd/Pixel_5_API_31_Android_12_.avd" />
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=DKTAB13NEU0019483" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
||||
@@ -11,8 +11,8 @@ android {
|
||||
applicationId = "net.mmanningau.speechtokeyboard"
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
versionCode = 10
|
||||
versionName = "1.0"
|
||||
versionCode = 12
|
||||
versionName = "1.1"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
<activity
|
||||
android:name=".TestModelActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:exported="false"
|
||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||
android:label="Test Microphone" />
|
||||
|
||||
</application>
|
||||
|
||||
@@ -27,6 +27,10 @@ import com.k2fsa.sherpa.onnx.OnlineTransducerModelConfig
|
||||
import com.k2fsa.sherpa.onnx.OnlineStream
|
||||
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() {
|
||||
|
||||
// UI Components
|
||||
@@ -39,6 +43,9 @@ class TestModelActivity : AppCompatActivity() {
|
||||
private var isRecording = false
|
||||
private var recordingThread: Thread? = null
|
||||
|
||||
// Punctuation variables
|
||||
private var punctuator: OfflinePunctuation? = null
|
||||
|
||||
// USB Components
|
||||
private var usbPort: UsbSerialPort? = null
|
||||
|
||||
@@ -117,6 +124,23 @@ class TestModelActivity : AppCompatActivity() {
|
||||
|
||||
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) {
|
||||
Log.e("Sherpa", "Init Error", e)
|
||||
outputText.text = "Init Error: ${e.message}"
|
||||
@@ -205,10 +229,15 @@ class TestModelActivity : AppCompatActivity() {
|
||||
// FIX 2: THE ORDER OF OPERATIONS
|
||||
|
||||
// A. Update UI first
|
||||
// 1. PUNCTUATE
|
||||
// We pass the raw text to the punctuator
|
||||
val punctuatedText = punctuator?.addPunctuation(cleanText) ?: cleanText
|
||||
|
||||
runOnUiThread {
|
||||
committedText += "$cleanText "
|
||||
// 2. Commit the BEAUTIFUL text
|
||||
committedText += "$punctuatedText "
|
||||
outputText.text = committedText
|
||||
sendToPico("$cleanText ")
|
||||
sendToPico("$punctuatedText ")
|
||||
}
|
||||
|
||||
// B. RESET IMMEDIATELY ON BACKGROUND THREAD
|
||||
|
||||
Reference in New Issue
Block a user