whisper_kit 0.0.1 copy "whisper_kit: ^0.0.1" to clipboard
whisper_kit: ^0.0.1 copied to clipboard

A flutter library for offline speech-to-text conversion which use whisper.cpp models implementation for Android.

Whisper Flutter (Android Only) #

A Flutter plugin that brings OpenAI's Whisper ASR (Automatic Speech Recognition) capabilities natively into your Android app. It supports offline speech-to-text transcription using Whisper models directly on the device.


Features #

  • Real-time Microphone Input and Transcription: Capture audio directly from the microphone and get instant transcriptions.
  • Whisper Models: Leverages the power of Whisper models (Tiny model included by default for a lightweight experience).
  • Android Focused: Thoroughly tested and confirmed to be working seamlessly only for Android devices.
  • Offline Functionality: No need for external APIs or cloud services – all processing happens directly on the device.
  • Native Integration: Efficiently integrates the native whisper.cpp library for optimal performance.

Installation #

  1. Add the dependency:

    Open your pubspec.yaml file and add the following line under dependencies:

    whisper_flutter: ^latest_version  # Replace with the latest version (current 0.1.0)
    
  2. Get the packages:

    Run the following command in your terminal within your Flutter project directory:

    flutter pub get
    
  3. Ensure CMake and NDK Support (Android):

    Make sure your Android project is configured to use CMake and the Android NDK. Flutter projects typically include this setup by default. If you encounter build issues related to native code, refer to the Flutter documentation on adding native code to your project.


Platform Support #

Platform Status
Android Working
iOS Planned
Web Not yet

Getting Started #

  1. Import the package:

    In your Dart code, import the whisper_flutter library:

    import 'package:whisper_flutter/whisper_flutter.dart';
    
  2. Use the plugin for transcription:

    Here's a basic example of how to transcribe an audio file. The plugin uses WAV files optimized for Whisper (16kHz, mono, 16-bit PCM):

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      final String audioPath = '/path/to/your/audio.wav';
    
      try {
        final TranscriptionResult? result = await WhisperFlutter.transcribe(audioPath: audioPath);
        if (result != null && result.text.isNotEmpty) {
          print('Transcription: ${result.text}');
        } else {
          print('Transcription failed or returned an empty result.');
        }
      } catch (e) {
        print('Error during transcription: \$e');
      }
    }
    

Screenshots #

Recording Interface #

Recording Screen Configuration Options Model Download Progress
[Main Interface] [Configuration Options] [Model Download Progress]

Transcription Results #

Result Display Model Download
[Transcription Progress] [Transcription Result (original language)]

Additional Features #

Audio Management Status Indicators
[Transcription Result (translated to english)] [Recording Screen]
Progress Widgets Processing Display
[Recording Progress] [Recorded Audio Result]
Main Interface
[English file (already existing) result]

Project Structure #

├── lib/
│ └── whisper_flutter.dart # Dart wrapper and plugin interface
├── src/
│ ├── main.cpp # Native C++ bindings
├── android/
│ ├── build.gradle
│ ├── src/main/
│ │ └── java/com/example/whisper_flutter/ # Android JNI bridge
│ │ └── cpp/ # Compiled native library output
│ ├── CMakeLists.txt
├── example/
│ ├── lib/main.dart # Sample Flutter usage project
├── .gitignore
└── README.md

1
likes
150
points
164
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter library for offline speech-to-text conversion which use whisper.cpp models implementation for Android.

Topics

#audio #speech #transcription #ai-tools

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, freezed_annotation, json_annotation, path_provider, plugin_platform_interface

More

Packages that depend on whisper_kit

Packages that implement whisper_kit