Skip to content

Commit 0a5307a

Browse files
committed
integrate ggml's excellent and amazing whisper.cpp to kantv ---- step7
various experiment and invesigation for asr performance on Xiaomi 14 asr performance from 21 secs to 2 secs on Xiaomi 14 by build optimization refine regular codes and prepare for coding work of implment real-time English subtile for online English TV
1 parent 3a881b4 commit 0a5307a

35 files changed

+245
-124
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ KanTV("Kan", aka Chinese PinYin "Kan" or Chinese HanZi "看" or English "watch/l
1212

1313
- Watch encrypted live stream(Google Widevine, Huawei WisePlay, ChinaDRM......)
1414

15-
- Real-time English subtitle by excellent&amazing <a href="https://github.com/ggerganov/whisper.cpp">whisper.cpp</a> for unencrypted/clear online TV (not finished)
15+
- Real-time English subtitle for online TV by excellent&amazing <a href="https://github.com/ggerganov/whisper.cpp">whisper.cpp</a> (not finished)
1616

1717
- UI refactor
1818

@@ -104,13 +104,13 @@ bazel is **NOT** used currently but put it here for further usage in the future.
104104
[Android Studio 4.2.1](https://developer.android.google.cn/studio)
105105

106106

107-
[Android NDK-r21e](https://developer.android.com/ndk/downloads)
107+
[Android NDK-r26c](https://developer.android.com/ndk/downloads)
108108

109109

110-
then put Android NDK-r21e into /opt/kantv-toolchain accordingly
110+
then put Android NDK-r26c into /opt/kantv-toolchain accordingly
111111

112112
```
113-
ls /opt/kantv-toolchain/android-ndk-r21e
113+
ls /opt/kantv-toolchain/android-ndk-r26c
114114
115115
```
116116

@@ -176,7 +176,7 @@ time ./build-all.sh
176176

177177
- Build APK from source code by Android Studio IDE manually
178178

179-
Please attention ![some source codes in ASRFragment.java](https://github.com/cdeos/kantv/blob/master/cdeosplayer/kantv/src/main/java/com/cdeos/kantv/ui/fragment/ASRFragment.java#L131) which affect the running of the ASR demo and the size of the generated APK.
179+
Please attention ![some source codes in ASRFragment.java](https://github.com/cdeos/kantv/blob/kantv-poc-with-whispercpp/cdeosplayer/kantv/src/main/java/com/cdeos/kantv/ui/fragment/ASRFragment.java#L155) which affect the running of the ASR demo and the size of the generated APK.
180180

181181
- Latest prebuit APK could be found here [![Github](https://user-images.githubusercontent.com/6889919/122489234-c13db400-d011-11eb-9d8c-8e4b2555dabe.png)](https://github.com/cdeos/kantv/raw/master/release/kantv-latest.apk)(the size of the prebuilt APK is about 90M because it contains **dependent model file of DeepSpeech** for purpose of make ASR demo happy).
182182

@@ -192,11 +192,10 @@ The following is some English snapshots.
192192

193193
![Screenshot_20240301_000503_com cdeos kantv](https://github.com/zhouwg/kantv/assets/6889919/07653f3d-1e7a-4208-a3d8-90b3aecc30b4)
194194
![Screenshot_20240301_000509_com cdeos kantv](https://github.com/zhouwg/kantv/assets/6889919/28d549ba-2fd5-434f-bf7a-b66d82d6dde3)
195-
![990238413](https://github.com/zhouwg/kantv/assets/6889919/44054d57-0149-4d45-8762-46ec80682c66)
195+
![1210108450](https://github.com/cdeos/kantv/assets/6889919/9f82c290-2ed6-444c-98d4-ef840cdd9083)
196196

197197

198198

199-
![Screenshot_20240301_114059_com cdeos kantv](https://github.com/zhouwg/kantv/assets/6889919/b0171435-44a5-48bf-9b59-a4b5fbcaa39f)
200199
![Screenshot_20240301_114116_com cdeos kantv](https://github.com/zhouwg/kantv/assets/6889919/10224799-cdf8-46f7-acd0-6df64f0fc674)
201200
![Screenshot_2024_0304_131033](https://github.com/zhouwg/kantv/assets/6889919/6c5bd531-5577-4570-bc87-aa3a87822d6b)
202201

@@ -216,9 +215,9 @@ Changelog could be found <a href="https://github.com/cdeos/kantv/blob/master/rel
216215

217216
### Roadmap
218217

219-
- real-time English subtitle for online English TV on Xiaomi 14 by excellent and amazing ![whisper.cpp](https://github.com/ggerganov/whisper.cpp)
218+
- real-time English subtitle for online English TV on Xiaomi 14(because it contains a very powerful mobile SoC) by excellent and amazing ![whisper.cpp](https://github.com/ggerganov/whisper.cpp)
220219

221-
- real-time Chinese subtitle for online English TV on Xiaomi 14 by excellent and amazing ![whisper.cpp](https://github.com/ggerganov/whisper.cpp)
220+
- real-time Chinese subtitle for online English TV on Xiaomi 14(because it contains a very powerful mobile SoC) by excellent and amazing ![whisper.cpp](https://github.com/ggerganov/whisper.cpp)
222221

223222
- integrate ![gstreamer](https://github.com/cdeos/gstreamer) to project KanTV(<a href="https://www.videolan.org/vlc/" target="_blank">VLC</a> is also excellent and gstreamer is more complicated than VLC but gstreamer was supported by many semiconductor companies. anyway, they are both born in/come from EU)
224223

@@ -310,15 +309,16 @@ Report issue in various Android-based phone or even submit PR to this project is
310309

311310
### Acknowledgement
312311

313-
Many/sincerely thanks to all contributors of the great open source community, especially all original authors and all contributors of the great Linux & Android & FFmpeg and other excellent projects.
312+
Many/sincerely thanks to all contributors of the great open source community, especially all original authors and all contributors of the great Linux & Android & FFmpeg && whisper.cpp and other excellent projects.
314313

315314
Project KanTV has used/tried following open-source projects(list in here is not incomplete):
316315
<ul>
316+
<li><a href="https://github.com/torvalds/linux" target="_blank">Linux</a></li>
317317
<li><a href="https://blog.google/products/android/" target="_blank" rel="noopener">Android</a></li>
318318
<li><a href="http://ffmpeg.org/" target="_blank" rel="noopener">FFmpeg</a></li>
319-
<li><a href="https://github.com/bilibili/ijkplayer" target="_blank" rel="noopener">ijkplayer</a></li>
320-
<li><a href="https://github.com/google/ExoPlayer" target="_blank" rel="noopener">ExoPlayer</a></li>
321319
<li><a href="https://github.com/ggerganov/whisper.cpp" target="_blank" rel="noopener">whisper.cpp</a></li>
320+
<li><a href="https://github.com/bilibili/ijkplayer" target="_blank" rel="noopener">ijkplayer</a></li>
321+
<li><a href="https://github.com/google/ExoPlayer" target="_blank" rel="noopener">ExoPlayer</a></li>
322322
<li><a href="https://www.videolan.org/vlc/" target="_blank" rel="noopener">libx264/libx265</a></li>
323323
<li><a href="https://github.com/mozilla/DeepSpeech" target="_blank" rel="noopener">DeepSpeech</a></li>
324324
<li><a href="https://www.intel.com/content/www/us/en/developer/articles/technical/scalable-video-technology.html" target="_blank" rel="noopener">SVT-AV1</a></li>

build/envsetup.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,25 @@ export LOCAL_WHISPERCPP_PATH=${PROJECT_ROOT_PATH}/external/whispercpp
4646
#modify following lines to adapt to local dev envs
4747
#export KANTV_TOOLCHAIN_PATH=${PROJECT_ROOT_PATH}/toolchain
4848
export KANTV_TOOLCHAIN_PATH=/opt/kantv-toolchain
49-
export ANDROID_NDK=${KANTV_TOOLCHAIN_PATH}/android-ndk-r21e
49+
#API21:Android 5.0 (Android L)Lollipop
50+
#API22:Android 5.1 (Android L)Lollipop
51+
#API23:Android 6.0 (Android M)Marshmallow
52+
#API24: Android 7.0 (Android N)Nougat
53+
#API25: Android 7.1 (Android N)Nougat
54+
#API26:Android 8.0 (Android O)Oreo
55+
#API27:Android 8.1 (Android O)Oreo
56+
#API28:Android 9.0 (Android P)Pie
57+
#API29:Android 10
58+
#API30:Android 11
59+
#API31:Android 12
60+
#API31:Android 12L
61+
#API33:Android 13
62+
#API34:Android 14
63+
export ANDROID_PLATFORM=android-34
64+
#export ANDROID_NDK=${KANTV_TOOLCHAIN_PATH}/android-ndk-r18b
65+
#export ANDROID_NDK=${KANTV_TOOLCHAIN_PATH}/android-ndk-r21e
66+
#export ANDROID_NDK=${KANTV_TOOLCHAIN_PATH}/android-ndk-r24
67+
export ANDROID_NDK=${KANTV_TOOLCHAIN_PATH}/android-ndk-r26c
5068
export LOCAL_BAZEL_PATH=${HOME_PATH}/.cache/bazel/_bazel_${BUILD_USER}/d483cd2a2d9204cb5bb4d870c2729238
5169
export UPSTREAM_WHISPERCPP_PATH=~/cdeos/whisper.cpp
5270

build/public.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ function dump_global_envs()
216216
echo -e "PROJECT_HOME_PATH: ${PROJECT_HOME_PATH}"
217217
echo -e "PROJECT_ROOT_PATH: ${PROJECT_ROOT_PATH}"
218218
echo -e "KANTV_TOOLCHAIN_PATH: ${KANTV_TOOLCHAIN_PATH}"
219-
220219
echo -e "host cpu counts: ${HOST_CPU_COUNTS}"
221220

222221
if [ "${BUILD_TARGET}" = "android" ]; then
223222
echo -e "\n"
224-
echo -e "ANDROID_NDK: ${ANDROID_NDK}"
225-
echo -e "LOCAL_WHISPERCPP_PATH: ${LOCAL_WHISPERCPP_PATH}"
226-
echo -e "UPSTREAM_WHISPERCPP_PATH: ${UPSTREAM_WHISPERCPP_PATH}"
223+
echo -e "${TEXT_RED}ANDROID_PLATFORM: ${ANDROID_PLATFORM}${TEXT_RESET}"
224+
echo -e "${TEXT_RED}ANDROID_NDK: ${ANDROID_NDK}${TEXT_RESET}"
225+
echo -e "LOCAL_WHISPERCPP_PATH: ${LOCAL_WHISPERCPP_PATH}"
226+
echo -e "UPSTREAM_WHISPERCPP_PATH: ${UPSTREAM_WHISPERCPP_PATH}"
227227
echo -e "\n"
228228
fi
229229

cdeosplayer/build.gradle

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
google()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.0.2'
11+
classpath 'com.android.tools.build:gradle:7.0.3'
1212
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
1313
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
1414
}
@@ -30,30 +30,5 @@ task clean(type: Delete) {
3030
}
3131

3232
wrapper {
33-
gradleVersion = '7.0.2'
33+
gradleVersion = '7.0.3'
3434
}
35-
36-
37-
38-
/*
39-
API14: Android 4.0-4.0.2 – Ice Cream Sandwich, released October 2011. Build version
40-
API15:Android 4.0.3 - 4.0.4 Ice Cream Sandwich
41-
API16:Android 4.1 Jelly Bean
42-
API17:Android 4.2 Jelly Bean
43-
API18:Android 4.3 Jelly Bean
44-
API19:Android 4.4 KitKat
45-
API20:Android 4.4W Kitkat Watch
46-
API21:Android 5.0 (Android L)Lollipop
47-
API22:Android 5.1 (Android L)Lollipop
48-
API23:Android 6.0 (Android M)Marshmallow
49-
API24: Android 7.0 (Android N)Nougat
50-
API25: Android 7.1 (Android N)Nougat
51-
API26:Android 8.0 (Android O)Oreo
52-
API27:Android 8.1 (Android O)Oreo
53-
API28:Android 9.0 (Android P)Pie
54-
API29:Android 10.0 (Android Q)
55-
API30:Android 11.0 (Android R)
56-
API31:Android 12.0
57-
API32:Android 13.0
58-
API33:Android 14.0
59-
*/

cdeosplayer/cdeosplayer-lib/src/main/java/cdeos/media/player/FFmpegMediaPlayer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ public static void loadLibrariesOnce(IjkLibLoader libLoader) {
211211
if (libLoader == null)
212212
libLoader = sLocalLibLoader;
213213

214-
CDELog.j(TAG, "load library kantv-ffmpeg-jni");
215-
libLoader.loadLibrary("kantv-ffmpeg-jni");
216-
CDELog.j(TAG, "after load library kantv-ffmpeg-jni");
214+
CDELog.j(TAG, "load library kantv-play-jni");
215+
libLoader.loadLibrary("kantv-play-jni");
216+
CDELog.j(TAG, "after load library kantv-play-jni");
217217

218-
CDELog.j(TAG, "load library kantv-ffmpeg");
219-
libLoader.loadLibrary("kantv-ffmpeg");
220-
CDELog.j(TAG, "after load library kantv-ffmpeg");
218+
CDELog.j(TAG, "load library kantv-play");
219+
libLoader.loadLibrary("kantv-play");
220+
CDELog.j(TAG, "after load library kantv-play");
221221
mIsLibLoaded = true;
222222
}
223223
}

cdeosplayer/cdeosplayer-lib/src/main/java/cdeos/media/player/KANTVVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
final class KANTVVersion
2121
{
22-
public static final String KANTV_VERSION="KANTV-v1.3.0";
22+
public static final String KANTV_VERSION="KANTV-v1.3.1";
2323

2424
public static native int kantv_anti_tamper();
2525
}

cdeosplayer/cdeosplayer-lib/src/main/java/org/ggml/whispercpp/whispercpp.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ public class whispercpp {
88

99
public static native String get_systeminfo();
1010

11+
public static native int get_cpu_core_counts();
12+
1113
public static native void set_benchmark_status(int bExitBenchmark);
1214

1315
/**
1416
*
1517
* @param modelPath
1618
* @param audioFile
17-
* @param nBenchType 0: memcpy 1: mulmat 2: asr 3: full/whisper_encoder
19+
* @param nBenchType 0: asr 1: memcpy 2: mulmat 3: full/whisper_encode
1820
* @param nThreadCounts
1921
* @return
2022
*/

cdeosplayer/constants.gradle

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 The Android Open Source Project
1+
// Copyright 2024 The Android Open Source Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,18 +11,40 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
/*
15+
API14: Android 4.0-4.0.2 – Ice Cream Sandwich, released October 2011. Build version
16+
API15:Android 4.0.3 - 4.0.4 Ice Cream Sandwich
17+
API16:Android 4.1 Jelly Bean
18+
API17:Android 4.2 Jelly Bean
19+
API18:Android 4.3 Jelly Bean
20+
API19:Android 4.4 KitKat
21+
API20:Android 4.4W Kitkat Watch
22+
API21:Android 5.0 (Android L)Lollipop
23+
API22:Android 5.1 (Android L)Lollipop
24+
API23:Android 6.0 (Android M)Marshmallow
25+
API24: Android 7.0 (Android N)Nougat
26+
API25: Android 7.1 (Android N)Nougat
27+
API26:Android 8.0 (Android O)Oreo
28+
API27:Android 8.1 (Android O)Oreo
29+
API28:Android 9.0 (Android P)Pie
30+
API29:Android 10
31+
API30:Android 11
32+
API31:Android 12
33+
API32: Android 12L
34+
API33:Android 13
35+
API34:Android 14
36+
*/
1437
project.ext {
15-
compileSdkVersion = 30
16-
buildToolsVersion = "30.0.3"
17-
targetSdkVersion = 28
18-
minSdkVersion = 19
19-
//minSdkVersion = 16
38+
//weiguo:2024-03-10, attention here,only validated ok on Xiaomi 14
39+
compileSdkVersion = 34
40+
buildToolsVersion = "34.0.0"
41+
targetSdkVersion = 34
42+
minSdkVersion = 34
2043
appTargetSdkVersion = 29
21-
ndkVersion = "21.4.7075529"
2244

2345
//version and version code of KanTV
24-
releaseVersion = '1.3.0'
25-
releaseVersionCode = 1000300
46+
releaseVersion = '1.3.1'
47+
releaseVersionCode = 1000301
2648

2749
//version and version code of internal Exoplayer2 playEngine
2850
releaseVersionExoplayer = '2.15.1'
@@ -44,4 +66,4 @@ project.ext {
4466
if (gradle.ext.has('exoplayerModulePrefix')) {
4567
modulePrefix += gradle.ext.exoplayerModulePrefix
4668
}
47-
}
69+
}

cdeosplayer/kantv/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ android {
4444
}
4545
}
4646

47-
ndkVersion '21.1.6352462'
47+
//weiguo:2024-03-10, attention here
48+
//ndkVersion '21.1.6352462'
49+
ndkVersion '26.2.11394342'
4850

4951
sourceSets {
5052
main {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"kantvServer": "www.cde-os.com",
3-
"releaseMode": "0",
4-
"apkVersion": "1.3.0",
3+
"releaseMode": "1",
4+
"apkVersion": "1.3.1",
55
"apkForTV": "0"
66
}

0 commit comments

Comments
 (0)