A flutter library for offline speech-to-text conversion which use whisper.cpp models implementation for Android、iOS、macOS. https://pub.dev/packages/whisper_flutter_new
Go to file
2024-11-11 14:54:33 +00:00
.vscode feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
android chore(deps): update dependency gradle to v8.11 2024-11-11 14:54:33 +00:00
example chore(deps): update dependency gradle to v8.11 2024-11-11 14:54:33 +00:00
ios feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
lib feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
macos feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
src feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
.gitignore feat: update README.md 2024-06-12 10:31:01 +08:00
analysis_options.yaml feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
build.yaml feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
CHANGELOG.md feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
ffigen.yaml feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
LICENSE feat: publish v1.0.1 2024-06-12 10:31:01 +08:00
pubspec.yaml chore(deps): update dependency ffigen to v14 2024-09-14 16:30:27 +00:00
README.md feat: add Notice 2024-10-10 10:40:10 +08:00
renovate.json feat: publish v1.0.1 2024-06-12 10:31:01 +08:00

Whisper Flutter New

pub package

Important Notice:

I am currently refactoring the functionality and plan to provide flutter bindings for both llama.cpp and whisper.cpp. After the refactoring is complete, I will consider adapting to Windows and MacOS

Ready to use whisper.cpp models implementation for iOS and Android

  1. Support AGP8+
  2. Support Android 5.0+ & iOS 13+ & MacOS 11+
  3. It is optimized and fast

Supported models: tiny、base、small、medium、large-v1、large-v2

Recommended Modelsbase、small、medium

All models have been actually tested, test devices: Android: Google Pixel 7 Pro, iOS: M1 iOS simulatorMacOS: M1 MacBookPro & M2 MacMini

Install library

flutter pub add whisper_flutter_new

import library

import 'package:whisper_flutter_new/whisper_flutter_new.dart';

Quickstart

// Prepare wav file
final Directory documentDirectory = await getApplicationDocumentsDirectory();
final ByteData documentBytes = await rootBundle.load('assets/jfk.wav');

final String jfkPath = '${documentDirectory.path}/jfk.wav';

await File(jfkPath).writeAsBytes(
    documentBytes.buffer.asUint8List(),
);

// Begin whisper transcription
/// China: https://hf-mirror.com/ggerganov/whisper.cpp/resolve/main
/// Other: https://huggingface.co/ggerganov/whisper.cpp/resolve/main
final Whisper whisper = Whisper(
    model: WhisperModel.base,
    downloadHost: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main"
);

final String? whisperVersion = await whisper.getVersion();
print(whisperVersion);

final String transcription = await whisper.transcribe(
    transcribeRequest: TranscribeRequest(
        audio: jfkPath,
        isTranslate: true, // Translate result from audio lang to english text
        isNoTimestamps: false, // Get segments in result
        splitOnWord: true, // Split segments on each word 
    ),
);
print(transcription);