Skip to content

Commit

Permalink
Merge pull request #1642 from matthiasn/refactor/whisper
Browse files Browse the repository at this point in the history
refactor: consolidate whisper.cpp download & code
  • Loading branch information
matthiasn authored Jan 1, 2024
2 parents fc79fae + 34a8636 commit 0e1b082
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 110 deletions.
15 changes: 2 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,5 @@ test_resources/test.png.aes

screenshots

macos/whisper.cpp/*.zip
macos/whisper.cpp/whisper.cpp*/
macos/whisper.cpp/ggml.c
macos/whisper.cpp/ggml.h
macos/whisper.cpp/whisper.cpp
macos/whisper.cpp/whisper.h

ios/whisper.cpp/*.zip
ios/whisper.cpp/whisper.cpp*/
ios/whisper.cpp/ggml.c
ios/whisper.cpp/ggml.h
ios/whisper.cpp/whisper.cpp
ios/whisper.cpp/whisper.h
whisper.cpp/*.zip
whisper.cpp/whisper.cpp-*/
20 changes: 3 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bundle:
#######################################

.PHONY: ios_build_ipa
ios_build_ipa: get_whisper_cpp_ios
ios_build_ipa: get_whisper_cpp
$(FLUTTER_CMD) build ipa

.PHONY: ios_build
Expand Down Expand Up @@ -193,23 +193,9 @@ macos_open: macos_build macos_archive

.PHONY: get_whisper_cpp
get_whisper_cpp:
cd macos/whisper.cpp/ && \
cd whisper.cpp/ && \
wget -nc https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v$(WHISPER_CPP_VERSION).zip && \
unzip v$(WHISPER_CPP_VERSION).zip && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/ggml.c . && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/ggml.h . && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/whisper.cpp . && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/whisper.h .

.PHONY: get_whisper_cpp_ios
get_whisper_cpp_ios:
cd ios/whisper.cpp/ && \
wget -nc https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v$(WHISPER_CPP_VERSION).zip && \
unzip v$(WHISPER_CPP_VERSION).zip && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/ggml.c . && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/ggml.h . && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/whisper.cpp . && \
cp ./whisper.cpp-$(WHISPER_CPP_VERSION)/whisper.h .
unzip -n v$(WHISPER_CPP_VERSION).zip

.PHONY: macos_fastlane_build
macos_fastlane_build:
Expand Down
11 changes: 5 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ PODS:
- Flutter
- MTBBarcodeScanner
- ReachabilitySwift (5.0.0)
- record_darwin (1.0.0):
- record (0.0.1):
- Flutter
- FlutterMacOS
- SDWebImage (5.16.0):
- SDWebImage/Core (= 5.16.0)
- SDWebImage/Core (5.16.0)
Expand Down Expand Up @@ -138,7 +137,7 @@ DEPENDENCIES:
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- photo_manager (from `.symlinks/plugins/photo_manager/ios`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- record_darwin (from `.symlinks/plugins/record_darwin/ios`)
- record (from `.symlinks/plugins/record/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
Expand Down Expand Up @@ -207,8 +206,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/photo_manager/ios"
qr_code_scanner:
:path: ".symlinks/plugins/qr_code_scanner/ios"
record_darwin:
:path: ".symlinks/plugins/record_darwin/ios"
record:
:path: ".symlinks/plugins/record/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
Expand Down Expand Up @@ -253,7 +252,7 @@ SPEC CHECKSUMS:
photo_manager: 4f6810b7dfc4feb03b461ac1a70dacf91fba7604
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
record_darwin: 1f6619f2abac4d1ca91d3eeab038c980d76f1517
record: cae05d8dd3cdb1dea3511b20e5a5811a1ae00d0d
SDWebImage: 2aea163b50bfcb569a2726b6a754c54a4506fcf6
SDWebImageWebPCoder: f0f287cee4cd96a59937fbf3c77a8cfda9ba67b0
share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
Expand Down
40 changes: 20 additions & 20 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
ADA413812A0DB79F00C39C5B /* whisper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADA4137C2A0DB79F00C39C5B /* whisper.cpp */; };
ADA413822A0DB79F00C39C5B /* ggml.c in Sources */ = {isa = PBXBuildFile; fileRef = ADA4137F2A0DB79F00C39C5B /* ggml.c */; settings = {COMPILER_FLAGS = "-DGGML_USE_ACCELERATE"; }; };
AD7744982B41E10000D73DE0 /* LibWhisper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD7744972B41E10000D73DE0 /* LibWhisper.swift */; };
AD77449D2B41E10F00D73DE0 /* ggml.c in Sources */ = {isa = PBXBuildFile; fileRef = AD7744992B41E10F00D73DE0 /* ggml.c */; };
AD77449E2B41E10F00D73DE0 /* whisper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD77449A2B41E10F00D73DE0 /* whisper.cpp */; };
ADB650B7270B3C4300B98C66 /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADB650B6270B3C4300B98C66 /* HealthKit.framework */; };
ADC929BF2A16DD7300FEAF10 /* LibWhisper.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC929BE2A16DD7300FEAF10 /* LibWhisper.swift */; };
FD4BDDFBB85CAB6754042A0B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E08CACAFD56E1EF268BBD8C5 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -50,15 +50,15 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AD0869BB271438AF00225DF9 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Base.xcconfig; path = Flutter/Base.xcconfig; sourceTree = "<group>"; };
ADA4137C2A0DB79F00C39C5B /* whisper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = whisper.cpp; sourceTree = "<group>"; };
ADA4137D2A0DB79F00C39C5B /* ggml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ggml.h; sourceTree = "<group>"; };
ADA4137E2A0DB79F00C39C5B /* whisper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = whisper.h; sourceTree = "<group>"; };
ADA4137F2A0DB79F00C39C5B /* ggml.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ggml.c; sourceTree = "<group>"; };
ADA413802A0DB79F00C39C5B /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
AD7744962B41E10000D73DE0 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Runner-Bridging-Header.h"; path = "../../whisper.cpp/Runner-Bridging-Header.h"; sourceTree = "<group>"; };
AD7744972B41E10000D73DE0 /* LibWhisper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibWhisper.swift; path = ../../whisper.cpp/LibWhisper.swift; sourceTree = "<group>"; };
AD7744992B41E10F00D73DE0 /* ggml.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ggml.c; path = "../../whisper.cpp/whisper.cpp-1.4.2/ggml.c"; sourceTree = "<group>"; };
AD77449A2B41E10F00D73DE0 /* whisper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = whisper.cpp; path = "../../whisper.cpp/whisper.cpp-1.4.2/whisper.cpp"; sourceTree = "<group>"; };
AD77449B2B41E10F00D73DE0 /* ggml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ggml.h; path = "../../whisper.cpp/whisper.cpp-1.4.2/ggml.h"; sourceTree = "<group>"; };
AD77449C2B41E10F00D73DE0 /* whisper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = whisper.h; path = "../../whisper.cpp/whisper.cpp-1.4.2/whisper.h"; sourceTree = "<group>"; };
ADAEC2742738A8F200996377 /* RunnerRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerRelease.entitlements; sourceTree = "<group>"; };
ADB650B5270B3C4300B98C66 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
ADB650B6270B3C4300B98C66 /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
ADC929BE2A16DD7300FEAF10 /* LibWhisper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibWhisper.swift; path = ../../macos/whisper.cpp/LibWhisper.swift; sourceTree = "<group>"; };
ADEF534728103FDF00F29D25 /* RunnerDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerDebug.entitlements; sourceTree = "<group>"; };
E08CACAFD56E1EF268BBD8C5 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F9EF5E47E2CAAE216BAF45A3 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,7 +101,7 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
ADA4137B2A0DB72A00C39C5B /* whisper.cpp */,
AD7744952B41E0D800D73DE0 /* whisper.cpp */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
Expand Down Expand Up @@ -136,15 +136,15 @@
path = Runner;
sourceTree = "<group>";
};
ADA4137B2A0DB72A00C39C5B /* whisper.cpp */ = {
AD7744952B41E0D800D73DE0 /* whisper.cpp */ = {
isa = PBXGroup;
children = (
ADC929BE2A16DD7300FEAF10 /* LibWhisper.swift */,
ADA4137F2A0DB79F00C39C5B /* ggml.c */,
ADA4137D2A0DB79F00C39C5B /* ggml.h */,
ADA413802A0DB79F00C39C5B /* Runner-Bridging-Header.h */,
ADA4137C2A0DB79F00C39C5B /* whisper.cpp */,
ADA4137E2A0DB79F00C39C5B /* whisper.h */,
AD7744992B41E10F00D73DE0 /* ggml.c */,
AD77449B2B41E10F00D73DE0 /* ggml.h */,
AD77449A2B41E10F00D73DE0 /* whisper.cpp */,
AD77449C2B41E10F00D73DE0 /* whisper.h */,
AD7744972B41E10000D73DE0 /* LibWhisper.swift */,
AD7744962B41E10000D73DE0 /* Runner-Bridging-Header.h */,
);
path = whisper.cpp;
sourceTree = "<group>";
Expand Down Expand Up @@ -309,10 +309,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ADA413812A0DB79F00C39C5B /* whisper.cpp in Sources */,
ADA413822A0DB79F00C39C5B /* ggml.c in Sources */,
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
ADC929BF2A16DD7300FEAF10 /* LibWhisper.swift in Sources */,
AD77449E2B41E10F00D73DE0 /* whisper.cpp in Sources */,
AD7744982B41E10000D73DE0 /* LibWhisper.swift in Sources */,
AD77449D2B41E10F00D73DE0 /* ggml.c in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/blocs/audio/recorder_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AudioRecorderCubit extends Cubit<AudioRecorderState> {
});
}

final _audioRecorder = AudioRecorder();
final _audioRecorder = Record();
StreamSubscription<Amplitude>? _amplitudeSub;
final LoggingDb _loggingDb = getIt<LoggingDb>();
final PersistenceLogic persistenceLogic = getIt<PersistenceLogic>();
Expand Down Expand Up @@ -73,7 +73,7 @@ class AudioRecorderCubit extends Cubit<AudioRecorderState> {
);

await _audioRecorder.start(
const RecordConfig(sampleRate: 48000),
samplingRate: 48000,
path: filePath,
);
}
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import package_info_plus
import pasteboard
import path_provider_foundation
import photo_manager
import record_darwin
import record_macos
import screen_retriever
import share_plus
import shared_preferences_foundation
Expand All @@ -44,7 +44,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "PhotoManagerPlugin"))
RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin"))
RecordMacosPlugin.register(with: registry.registrar(forPlugin: "RecordMacosPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
Expand Down
11 changes: 5 additions & 6 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ PODS:
- Flutter
- FlutterMacOS
- ReachabilitySwift (5.0.0)
- record_darwin (1.0.0):
- Flutter
- record_macos (0.2.0):
- FlutterMacOS
- screen_retriever (0.0.1):
- FlutterMacOS
Expand Down Expand Up @@ -97,7 +96,7 @@ DEPENDENCIES:
- pasteboard (from `Flutter/ephemeral/.symlinks/plugins/pasteboard/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- photo_manager (from `Flutter/ephemeral/.symlinks/plugins/photo_manager/macos`)
- record_darwin (from `Flutter/ephemeral/.symlinks/plugins/record_darwin/macos`)
- record_macos (from `Flutter/ephemeral/.symlinks/plugins/record_macos/macos`)
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
Expand Down Expand Up @@ -148,8 +147,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
photo_manager:
:path: Flutter/ephemeral/.symlinks/plugins/photo_manager/macos
record_darwin:
:path: Flutter/ephemeral/.symlinks/plugins/record_darwin/macos
record_macos:
:path: Flutter/ephemeral/.symlinks/plugins/record_macos/macos
screen_retriever:
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
share_plus:
Expand Down Expand Up @@ -188,7 +187,7 @@ SPEC CHECKSUMS:
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
photo_manager: 4f6810b7dfc4feb03b461ac1a70dacf91fba7604
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
record_darwin: 1f6619f2abac4d1ca91d3eeab038c980d76f1517
record_macos: 937889e0f2a7a12b6fc14e97a3678e5a18943de6
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
Expand Down
Loading

0 comments on commit 0e1b082

Please sign in to comment.