mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-08-13 13:57:57 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
40be74271f | |||
a0c0d08d0f | |||
8fb0a1cd1c | |||
185d3fd6d9 |
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required (VERSION 3.5)
|
cmake_minimum_required (VERSION 3.5)
|
||||||
|
|
||||||
project(whisper.cpp VERSION 1.4.3)
|
project(whisper.cpp VERSION 1.4.2)
|
||||||
|
|
||||||
# Add path to modules
|
# Add path to modules
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://www.npmjs.com/package/whisper.cpp/)
|
[](https://www.npmjs.com/package/whisper.cpp/)
|
||||||
|
|
||||||
Beta: [v1.4.3](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.4.3) / Stable: [v1.2.1](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.2.1) / [Roadmap | F.A.Q.](https://github.com/ggerganov/whisper.cpp/discussions/126)
|
Beta: [v1.4.2](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.4.2) / Stable: [v1.2.1](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.2.1) / [Roadmap | F.A.Q.](https://github.com/ggerganov/whisper.cpp/discussions/126)
|
||||||
|
|
||||||
High-performance inference of [OpenAI's Whisper](https://github.com/openai/whisper) automatic speech recognition (ASR) model:
|
High-performance inference of [OpenAI's Whisper](https://github.com/openai/whisper) automatic speech recognition (ASR) model:
|
||||||
|
|
||||||
|
Submodule bindings/ios updated: 9752de4100...44b39fd4ec
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "whisper.cpp",
|
"name": "whisper.cpp",
|
||||||
"version": "1.4.3",
|
"version": "1.4.2",
|
||||||
"description": "Whisper speech recognition",
|
"description": "Whisper speech recognition",
|
||||||
"main": "whisper.js",
|
"main": "whisper.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -18,7 +18,9 @@ android {
|
|||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
useSupportLibrary true
|
useSupportLibrary true
|
||||||
}
|
}
|
||||||
|
ndk {
|
||||||
|
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -41,10 +43,20 @@ android {
|
|||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerExtensionVersion '1.5.0'
|
kotlinCompilerExtensionVersion '1.5.0'
|
||||||
}
|
}
|
||||||
|
ndkVersion "25.2.9519653"
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path = file("src/main/jni/whisper/CMakeLists.txt")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
packagingOptions {
|
||||||
|
resources {
|
||||||
|
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':lib')
|
|
||||||
implementation 'androidx.activity:activity-compose:1.7.2'
|
implementation 'androidx.activity:activity-compose:1.7.2'
|
||||||
implementation 'androidx.compose.material:material-icons-core:1.5.0'
|
implementation 'androidx.compose.material:material-icons-core:1.5.0'
|
||||||
implementation 'androidx.compose.material3:material3:1.1.1'
|
implementation 'androidx.compose.material3:material3:1.1.1'
|
||||||
|
@ -15,7 +15,7 @@ import androidx.lifecycle.viewmodel.initializer
|
|||||||
import androidx.lifecycle.viewmodel.viewModelFactory
|
import androidx.lifecycle.viewmodel.viewModelFactory
|
||||||
import com.whispercppdemo.media.decodeWaveFile
|
import com.whispercppdemo.media.decodeWaveFile
|
||||||
import com.whispercppdemo.recorder.Recorder
|
import com.whispercppdemo.recorder.Recorder
|
||||||
import com.whispercpp.whisper.WhisperContext
|
import com.whispercppdemo.whisper.WhisperContext
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
@ -35,7 +35,7 @@ class MainScreenViewModel(private val application: Application) : ViewModel() {
|
|||||||
private val modelsPath = File(application.filesDir, "models")
|
private val modelsPath = File(application.filesDir, "models")
|
||||||
private val samplesPath = File(application.filesDir, "samples")
|
private val samplesPath = File(application.filesDir, "samples")
|
||||||
private var recorder: Recorder = Recorder()
|
private var recorder: Recorder = Recorder()
|
||||||
private var whisperContext: com.whispercpp.whisper.WhisperContext? = null
|
private var whisperContext: WhisperContext? = null
|
||||||
private var mediaPlayer: MediaPlayer? = null
|
private var mediaPlayer: MediaPlayer? = null
|
||||||
private var recordedFile: File? = null
|
private var recordedFile: File? = null
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class MainScreenViewModel(private val application: Application) : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun printSystemInfo() {
|
private suspend fun printSystemInfo() {
|
||||||
printMessage(String.format("System Info: %s\n", com.whispercpp.whisper.WhisperContext.getSystemInfo()))
|
printMessage(String.format("System Info: %s\n", WhisperContext.getSystemInfo()))
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun loadData() {
|
private suspend fun loadData() {
|
||||||
@ -78,7 +78,7 @@ class MainScreenViewModel(private val application: Application) : ViewModel() {
|
|||||||
printMessage("Loading model...\n")
|
printMessage("Loading model...\n")
|
||||||
val models = application.assets.list("models/")
|
val models = application.assets.list("models/")
|
||||||
if (models != null) {
|
if (models != null) {
|
||||||
whisperContext = com.whispercpp.whisper.WhisperContext.createContextFromAsset(application.assets, "models/" + models[0])
|
whisperContext = WhisperContext.createContextFromAsset(application.assets, "models/" + models[0])
|
||||||
printMessage("Loaded model ${models[0]}.\n")
|
printMessage("Loaded model ${models[0]}.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.whispercpp.whisper
|
package com.whispercppdemo.whisper
|
||||||
|
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import android.os.Build
|
import android.os.Build
|
@ -1,4 +1,4 @@
|
|||||||
package com.whispercpp.whisper
|
package com.whispercppdemo.whisper
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
@ -131,7 +131,7 @@ static struct whisper_context *whisper_init_from_asset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_initContextFromAsset(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_initContextFromAsset(
|
||||||
JNIEnv *env, jobject thiz, jobject assetManager, jstring asset_path_str) {
|
JNIEnv *env, jobject thiz, jobject assetManager, jstring asset_path_str) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
struct whisper_context *context = NULL;
|
struct whisper_context *context = NULL;
|
||||||
@ -142,7 +142,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_initContextFromAsset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_initContext(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_initContext(
|
||||||
JNIEnv *env, jobject thiz, jstring model_path_str) {
|
JNIEnv *env, jobject thiz, jstring model_path_str) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
struct whisper_context *context = NULL;
|
struct whisper_context *context = NULL;
|
||||||
@ -153,7 +153,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_initContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_freeContext(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_freeContext(
|
||||||
JNIEnv *env, jobject thiz, jlong context_ptr) {
|
JNIEnv *env, jobject thiz, jlong context_ptr) {
|
||||||
UNUSED(env);
|
UNUSED(env);
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
@ -162,7 +162,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_freeContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_fullTranscribe(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_fullTranscribe(
|
||||||
JNIEnv *env, jobject thiz, jlong context_ptr, jint num_threads, jfloatArray audio_data) {
|
JNIEnv *env, jobject thiz, jlong context_ptr, jint num_threads, jfloatArray audio_data) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
||||||
@ -194,7 +194,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_fullTranscribe(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_getTextSegmentCount(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_getTextSegmentCount(
|
||||||
JNIEnv *env, jobject thiz, jlong context_ptr) {
|
JNIEnv *env, jobject thiz, jlong context_ptr) {
|
||||||
UNUSED(env);
|
UNUSED(env);
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
@ -203,7 +203,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_getTextSegmentCount(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_getTextSegment(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_getTextSegment(
|
||||||
JNIEnv *env, jobject thiz, jlong context_ptr, jint index) {
|
JNIEnv *env, jobject thiz, jlong context_ptr, jint index) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
struct whisper_context *context = (struct whisper_context *) context_ptr;
|
||||||
@ -213,7 +213,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_getTextSegment(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_getSystemInfo(
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_getSystemInfo(
|
||||||
JNIEnv *env, jobject thiz
|
JNIEnv *env, jobject thiz
|
||||||
) {
|
) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
@ -223,7 +223,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_getSystemInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_benchMemcpy(JNIEnv *env, jobject thiz,
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_benchMemcpy(JNIEnv *env, jobject thiz,
|
||||||
jint n_threads) {
|
jint n_threads) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
const char *bench_ggml_memcpy = whisper_bench_memcpy_str(n_threads);
|
const char *bench_ggml_memcpy = whisper_bench_memcpy_str(n_threads);
|
||||||
@ -231,7 +231,7 @@ Java_com_whispercpp_whisper_WhisperLib_00024Companion_benchMemcpy(JNIEnv *env, j
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_whispercpp_whisper_WhisperLib_00024Companion_benchGgmlMulMat(JNIEnv *env, jobject thiz,
|
Java_com_whispercppdemo_whisper_WhisperLib_00024Companion_benchGgmlMulMat(JNIEnv *env, jobject thiz,
|
||||||
jint n_threads) {
|
jint n_threads) {
|
||||||
UNUSED(thiz);
|
UNUSED(thiz);
|
||||||
const char *bench_ggml_mul_mat = whisper_bench_ggml_mul_mat_str(n_threads);
|
const char *bench_ggml_mul_mat = whisper_bench_ggml_mul_mat_str(n_threads);
|
1
examples/whisper.android/lib/.gitignore
vendored
1
examples/whisper.android/lib/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/build
|
|
@ -1,51 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.android.library'
|
|
||||||
id 'org.jetbrains.kotlin.android'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
namespace 'com.whispercpp'
|
|
||||||
compileSdk 34
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdk 26
|
|
||||||
targetSdk 34
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
|
|
||||||
ndk {
|
|
||||||
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = '1.8'
|
|
||||||
}
|
|
||||||
|
|
||||||
ndkVersion "25.2.9519653"
|
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
path = file("src/main/jni/whisper/CMakeLists.txt")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
packagingOptions {
|
|
||||||
resources {
|
|
||||||
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'androidx.core:core-ktx:1.9.0'
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
||||||
implementation 'com.google.android.material:material:1.8.0'
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
</manifest>
|
|
@ -14,4 +14,3 @@ dependencyResolutionManagement {
|
|||||||
}
|
}
|
||||||
rootProject.name = "WhisperCppDemo"
|
rootProject.name = "WhisperCppDemo"
|
||||||
include ':app'
|
include ':app'
|
||||||
include ':lib'
|
|
||||||
|
12
ggml.c
12
ggml.c
@ -143,6 +143,12 @@ void ggml_print_backtrace(void) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef MIN
|
||||||
|
#undef MAX
|
||||||
|
|
||||||
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
|
||||||
/*#define GGML_PERF*/
|
/*#define GGML_PERF*/
|
||||||
#define GGML_DEBUG 0
|
#define GGML_DEBUG 0
|
||||||
#define GGML_GELU_FP16
|
#define GGML_GELU_FP16
|
||||||
@ -271,12 +277,6 @@ inline static void * ggml_aligned_malloc(size_t size) {
|
|||||||
// floating point type used to accumulate sums
|
// floating point type used to accumulate sums
|
||||||
typedef double ggml_float;
|
typedef double ggml_float;
|
||||||
|
|
||||||
#undef MIN
|
|
||||||
#undef MAX
|
|
||||||
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// global data
|
// global data
|
||||||
//
|
//
|
||||||
|
@ -3714,7 +3714,6 @@ void whisper_print_timings(struct whisper_context * ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void whisper_reset_timings(struct whisper_context * ctx) {
|
void whisper_reset_timings(struct whisper_context * ctx) {
|
||||||
ctx->t_start_us = ggml_time_us();
|
|
||||||
if (ctx->state != nullptr) {
|
if (ctx->state != nullptr) {
|
||||||
ctx->state->t_sample_us = 0;
|
ctx->state->t_sample_us = 0;
|
||||||
ctx->state->t_encode_us = 0;
|
ctx->state->t_encode_us = 0;
|
||||||
|
Reference in New Issue
Block a user