mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-06-11 20:26:42 +02:00
Update LibWhisper.kt
This commit is contained in:
parent
6b8b91ad81
commit
85f7c8f4d9
@ -16,11 +16,11 @@ class WhisperContext private constructor(private var ptr: Long) {
|
||||
Executors.newSingleThreadExecutor().asCoroutineDispatcher()
|
||||
)
|
||||
|
||||
suspend fun transcribeData(data: FloatArray, printTimestamp: Boolean = true): String = withContext(scope.coroutineContext) {
|
||||
suspend fun transcribeData(data: FloatArray, printTimestamp: Boolean = true, tokenTimestamps: Boolean = false, splitOnWord: Boolean = false, maxLen: Int): String = withContext(scope.coroutineContext) {
|
||||
require(ptr != 0L)
|
||||
val numThreads = WhisperCpuConfig.preferredThreadCount
|
||||
Log.d(LOG_TAG, "Selecting $numThreads threads")
|
||||
WhisperLib.fullTranscribe(ptr, numThreads, data)
|
||||
WhisperLib.fullTranscribe(ptr, numThreads, data, tokenTimestamps, splitOnWord, maxLen)
|
||||
val textCount = WhisperLib.getTextSegmentCount(ptr)
|
||||
return@withContext buildString {
|
||||
for (i in 0 until textCount) {
|
||||
@ -134,7 +134,7 @@ private class WhisperLib {
|
||||
external fun initContextFromAsset(assetManager: AssetManager, assetPath: String): Long
|
||||
external fun initContext(modelPath: String): Long
|
||||
external fun freeContext(contextPtr: Long)
|
||||
external fun fullTranscribe(contextPtr: Long, numThreads: Int, audioData: FloatArray)
|
||||
external fun fullTranscribe(contextPtr: Long, numThreads: Int, audioData: FloatArray, tokenTimestamps: Boolean, splitOnWord: Boolean, maxLen: Int)
|
||||
external fun getTextSegmentCount(contextPtr: Long): Int
|
||||
external fun getTextSegment(contextPtr: Long, index: Int): String
|
||||
external fun getTextSegmentT0(contextPtr: Long, index: Int): Long
|
||||
@ -177,4 +177,4 @@ private fun cpuInfo(): String? {
|
||||
Log.w(LOG_TAG, "Couldn't read /proc/cpuinfo", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user