### Install Capacitor MLKit Whisper Plugin from npm Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Instructions to install the Capacitor MLKit Whisper plugin from npm once it's published, followed by Capacitor project synchronization. ```bash npm install @capacitor-mlkit/whisper npx cap sync ``` -------------------------------- ### Install Capacitor MLKit Whisper Plugin for Local Development Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Steps to set up the Capacitor MLKit Whisper plugin for local development, including cloning the repository and installing the package from a local path, then syncing with Capacitor. ```bash # Clone the repository git clone https://github.com/ceramicwhite/capacitor-mlkit.git # Install from local path npm install ./capacitor-mlkit/packages/whisper npx cap sync ``` -------------------------------- ### Install Node.js Dependencies for Capacitor Plugin Development Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/CONTRIBUTING.md This command installs all necessary Node.js packages and dependencies defined in the `package.json` file for the Capacitor plugin project, preparing the environment for development. ```shell npm install ``` -------------------------------- ### Install Capacitor MLKit Whisper Plugin from GitHub Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Instructions to install the Capacitor MLKit Whisper plugin directly from its GitHub repository, including options for the main repository or the specific whisper package, followed by Capacitor project synchronization. ```bash # Install directly from GitHub repository npm install https://github.com/ceramicwhite/capacitor-mlkit.git#main --save # or install the specific whisper package npm install git+https://github.com/ceramicwhite/capacitor-mlkit.git#main:packages/whisper # Sync with your Capacitor project npx cap sync ``` -------------------------------- ### Install SwiftLint for macOS Code Quality Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/CONTRIBUTING.md This command installs SwiftLint, a static analysis tool for Swift code, using Homebrew on macOS. It ensures consistent code style and quality for the native iOS part of the Capacitor plugin. ```shell brew install swiftlint ``` -------------------------------- ### Perform Advanced Audio Transcription with Word Timestamps Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md TypeScript example showing advanced usage of the Capacitor MLKit Whisper plugin, including transcribing an audio file with language specification, word timestamps, and suppression of non-speech tokens, then iterating through segments and words to display detailed timing and confidence. ```typescript const result = await Whisper.transcribeFile({ filePath: '/path/to/audio/file.wav', language: 'en', wordTimestamps: true, suppressNonSpeechTokens: true }); result.segments.forEach(segment => { console.log(`[${segment.startTime}s - ${segment.endTime}s]: ${segment.text}`); segment.words?.forEach(word => { console.log(` "${word.word}" (${word.confidence.toFixed(2)})`); }); }); ``` -------------------------------- ### Download Core ML Whisper Models for iOS Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Commands to download Core ML models from WhisperKit, recommended for optimal performance on iOS, including instructions to unzip the downloaded files. ```bash # Download Core ML models (better performance on iOS) # Base English model (~74MB) curl -L -o openai_whisper-base.en.mlmodelc.zip https://huggingface.co/argmaxinc/whisperkit-coreml/resolve/main/openai_whisper-base.en/openai_whisper-base.en.mlmodelc.zip unzip openai_whisper-base.en.mlmodelc.zip # Tiny English model (~39MB) - fastest # curl -L -o openai_whisper-tiny.en.mlmodelc.zip https://huggingface.co/argmaxinc/whisperkit-coreml/resolve/main/openai_whisper-tiny.en/openai_whisper-tiny.en.mlmodelc.zip # Small English model (~244MB) - better accuracy # curl -L -o openai_whisper-small.en.mlmodelc.zip https://huggingface.co/argmaxinc/whisperkit-coreml/resolve/main/openai_whisper-small.en/openai_whisper-small.en.mlmodelc.zip ``` -------------------------------- ### Performance Optimization Tips for Whisper Plugin Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Provides practical advice for optimizing the performance of the Whisper plugin, focusing on model selection (Core ML, English-only, smaller models), acceleration techniques, preloading, thread management, and balancing model size with accuracy requirements. ```APIDOC 1. Use Core ML models (.mlmodelc) for maximum performance on iOS 2. Use English-only models when possible for better performance 3. Start with smaller models (tiny, base) and upgrade if needed 4. Enable Core ML acceleration for significant performance improvements 5. Preload models during app initialization for faster transcription 6. Use appropriate thread counts based on device capabilities 7. Consider model size vs accuracy tradeoffs based on your use case ``` -------------------------------- ### Download GGML Whisper Models for iOS Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Commands to download standard GGML (whisper.cpp format) models, such as `base.en`, for use with the iOS application bundle. ```bash # Download a model (example: base.en model ~74MB) curl -L -o ggml-base.en.bin https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-base.en.bin # Other available models: # curl -L -o ggml-tiny.en.bin https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-tiny.en.bin # curl -L -o ggml-small.en.bin https://huggingface.co/ggml-org/whisper.cpp/resolve/main/ggml-small.en.bin ``` -------------------------------- ### Build Capacitor Plugin Web Assets and API Documentation Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/CONTRIBUTING.md This script compiles TypeScript source code into ESM JavaScript, bundles it for browser usage, and generates API documentation using `@capacitor/docgen`. It prepares the plugin's web assets for use in applications. ```shell npm run build ``` -------------------------------- ### Perform Basic Audio Transcription with Capacitor MLKit Whisper Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md TypeScript code demonstrating how to load a Whisper model and transcribe an audio file using the Capacitor MLKit Whisper plugin, then log the transcription text and processing time. ```typescript import { Whisper } from '@capacitor-mlkit/whisper'; // Load a model await Whisper.loadModel({ modelName: 'base.en', useCoreML: true }); // Transcribe an audio file const result = await Whisper.transcribeFile({ filePath: '/path/to/audio/file.wav' }); console.log('Transcription:', result.text); console.log('Processing time:', result.processingTime, 'ms'); ``` -------------------------------- ### Plugin License Information Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md States the licensing terms for the Capacitor MLKit Whisper plugin, indicating it is distributed under the Apache-2.0 license. ```APIDOC Apache-2.0 ``` -------------------------------- ### Supported Whisper Models (GGML & Core ML) Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Lists the various GGML (whisper.cpp) and Core ML models supported by the plugin, detailing their sizes and characteristics (e.g., speed, accuracy, English-only vs. multilingual). It also provides a recommendation to use Core ML models for optimal iOS performance. ```APIDOC GGML Models (whisper.cpp format): - tiny (39 MB) - Fastest, lowest accuracy - tiny.en (39 MB) - English-only, faster than multilingual tiny - base (74 MB) - Good balance of speed and accuracy - base.en (74 MB) - English-only, better accuracy than multilingual base - small (244 MB) - Better accuracy, slower processing - small.en (244 MB) - English-only small model - medium (769 MB) - High accuracy, slower processing - large-v3 (1550 MB) - Highest accuracy, slowest processing Core ML Models (iOS Optimized): Available from WhisperKit Core ML Models: - openai_whisper-tiny.en (39 MB) - Hardware-accelerated tiny model - openai_whisper-base.en (74 MB) - Hardware-accelerated base model - openai_whisper-small.en (244 MB) - Hardware-accelerated small model - openai_whisper-large-v3 (1550 MB) - Hardware-accelerated large model Recommendation: Use Core ML models (.mlmodelc) for best performance on iOS devices with Apple Neural Engine acceleration. ``` -------------------------------- ### LoadModelOptions Interface Reference Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Specifies the parameters for loading a Whisper model, including the model name, whether to utilize Core ML acceleration on iOS, and if the plugin is allowed to download the model if it's not found locally. ```APIDOC LoadModelOptions: modelName: string Name of the model to load. useCoreML: boolean Whether to use Core ML acceleration (iOS only). Default: true allowDownload: boolean Whether to download the model if not available locally. Default: true ``` -------------------------------- ### Whisper Plugin API Methods Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md This section outlines the core methods available in the Capacitor MLKit Whisper plugin. It includes functions for transcribing audio files, loading and unloading models, retrieving model information, checking and requesting permissions, and verifying plugin support on the device. ```APIDOC transcribeFile(options: TranscribeFileOptions) => Promise Transcribe audio from a file path. loadModel(options: LoadModelOptions) => Promise Load a Whisper model for transcription. unloadModel() => Promise Unload the currently loaded model to free up memory. getModelInfo() => Promise Get information about the currently loaded model. isSupported() => Promise Check if whisper.cpp is supported on this device. checkPermissions() => Promise Check microphone permission status. requestPermissions() => Promise Request microphone permission. ``` -------------------------------- ### Verify Capacitor Plugin Builds Across Platforms Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/CONTRIBUTING.md This script builds and validates both the web and native projects of the Capacitor plugin. It is primarily used in CI environments to ensure the plugin compiles correctly for all target platforms. ```shell npm run verify ``` -------------------------------- ### Manage Whisper Model Lifecycle in Capacitor Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md This snippet demonstrates how to check Whisper.cpp and Core ML support, retrieve information about the currently loaded model (name, Core ML usage, size), and unload the model to free up memory. It covers essential operations for managing the Whisper transcription model within a Capacitor application. ```typescript // Check if whisper.cpp is supported const { supported, coreMLSupported } = await Whisper.isSupported(); console.log('Whisper supported:', supported); console.log('Core ML supported:', coreMLSupported); // Get model information const modelInfo = await Whisper.getModelInfo(); console.log('Current model:', modelInfo.modelName); console.log('Using Core ML:', modelInfo.usingCoreML); console.log('Model size:', modelInfo.modelSize, 'bytes'); // Unload model to free memory await Whisper.unloadModel(); ``` -------------------------------- ### Check and Autoformat Capacitor Plugin Code Quality Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/CONTRIBUTING.md These scripts check code formatting and quality using ESLint, Prettier, and SwiftLint, and attempt to autoformat or autofix issues. They enforce a consistent style and structure for easier collaboration. ```shell npm run lint npm run fmt ``` -------------------------------- ### Configure iOS Info.plist for Microphone Access Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md XML snippet to add the `NSMicrophoneUsageDescription` key to your iOS `Info.plist` file, which is required for microphone access for audio recording and transcription. ```xml NSMicrophoneUsageDescription This app needs access to the microphone to record audio for transcription. ``` -------------------------------- ### TranscribeFileOptions Interface Reference Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Defines the options available for the `transcribeFile` method, allowing customization of transcription parameters such as file path, language, word timestamps, translation, thread count, context length, beam search, and non-speech token suppression. ```APIDOC TranscribeFileOptions: filePath: string Path to the audio file to transcribe. language: string Language code for transcription (e.g., 'en', 'es', 'fr'). wordTimestamps: boolean Whether to include word-level timestamps. Default: false translate: boolean Whether to translate to English. Default: false threadCount: number Number of threads to use (iOS only). maxContext: number Maximum context length. Default: 224 beamSearch: boolean Whether to use beam search decoding. Default: false suppressNonSpeechTokens: boolean Whether to suppress non-speech tokens. Default: true ``` -------------------------------- ### Handle Transcription Errors in Capacitor Whisper Plugin Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Demonstrates a `try-catch` block for handling potential errors during audio transcription. It shows how to catch generic errors and specifically check for a 'MODEL_NOT_LOADED' error to attempt model loading and retry the operation, ensuring robust application behavior. ```typescript try { const result = await Whisper.transcribeFile({ filePath: '/path/to/audio.wav' }); } catch (error) { console.error('Transcription failed:', error); // Handle specific error types if (error.message.includes('MODEL_NOT_LOADED')) { await Whisper.loadModel({ modelName: 'base.en' }); // Retry transcription } } ``` -------------------------------- ### TranscribeResult Interface Reference Source: https://github.com/ceramicwhite/capacitor-mlkit-whisper/blob/main/packages/whisper/README.md Describes the structure of the result returned after an audio transcription, including the full transcribed text, an array of segments with timestamps, the detected language code, and the total processing time in milliseconds. ```APIDOC TranscribeResult: text: string The transcribed text. segments: TranscriptionSegment[] Array of transcribed segments with timestamps. language: string Detected language code. processingTime: number Total processing time in milliseconds. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.