mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-11 00:12:24 +01:00
voice: replace Whisper with sherpa-onnx, live words from Kroko and the final words from Parakeet
Models download in Settings instead of shipping in the APK. Credits for the engine and models are in About.
This commit is contained in:
1 parent
af9e9a7571
commit
30d94bcfb5
18 files changed
+1085
-289
No files matched your search
@@ -0,0 +1,43 @@
|
||||
// From sherpa-onnx v1.13.8 (Apache-2.0, https://github.com/k2-fsa/sherpa-onnx), kotlin-api.
|
||||
package com.k2fsa.sherpa.onnx
|
||||
|
||||
class OfflineStream(var ptr: Long) {
|
||||
init {
|
||||
require(ptr != 0L) { "Failed to create native OfflineStream" }
|
||||
}
|
||||
|
||||
fun acceptWaveform(samples: FloatArray, sampleRate: Int) =
|
||||
acceptWaveform(ptr, samples, sampleRate)
|
||||
|
||||
fun setOption(key: String, value: String) = setOption(ptr, key, value)
|
||||
|
||||
fun getOption(key: String): String = getOption(ptr, key)
|
||||
|
||||
protected fun finalize() {
|
||||
if (ptr != 0L) {
|
||||
delete(ptr)
|
||||
ptr = 0
|
||||
}
|
||||
}
|
||||
|
||||
fun release() = finalize()
|
||||
|
||||
fun use(block: (OfflineStream) -> Unit) {
|
||||
try {
|
||||
block(this)
|
||||
} finally {
|
||||
release()
|
||||
}
|
||||
}
|
||||
|
||||
private external fun acceptWaveform(ptr: Long, samples: FloatArray, sampleRate: Int)
|
||||
private external fun setOption(ptr: Long, key: String, value: String)
|
||||
private external fun getOption(ptr: Long, key: String): String
|
||||
private external fun delete(ptr: Long)
|
||||
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("sherpa-onnx-jni")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user