transcribe_cpp 0.1.2
transcribe_cpp: ^0.1.2 copied to clipboard
Offline, on-device speech-to-text for Flutter. Hands-free dictation with live text on iOS and Android: no network, no API keys, audio never leaves the phone.
transcribe_cpp #
Offline speech-to-text for Flutter. The user talks, your app gets text, and the audio never leaves the phone.
Built on transcribe.cpp, which does the speech recognition. This package brings it to Flutter, with microphone capture, voice detection and live text around it.
- Private. Everything runs on the device: no server, no account, no API key.
- Hands-free. Voice detection decides when each sentence ends. No button to hold.
- Live text. Words appear while the user is still speaking, and settle in place without flickering.
- Fast. About 40 times faster than real time on a mid-range phone.
- Resilient. Keeps going through calls, Siri, headphones being plugged in, and the app going to the background.
- Your audio, too. Already record audio yourself? Feed it in at any sample rate.
Install #
flutter pub add transcribe_cpp
Then let your app use the microphone. On iOS, add a reason to
ios/Runner/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>Your speech is transcribed on this device.</string>
On Android, add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
Use it #
import 'package:transcribe_cpp/transcribe_cpp.dart';
// Download a model once (90 MB). Later calls return it straight away.
final models = await ModelManager.open();
final model = await models.ensure(const ModelId('parakeet-tdt_ctc-110m-Q4_K_M'));
// Load it, and listen.
final session = await TranscribeSession.open(model);
await session.start();
// Show the text as the user speaks.
ValueListenableBuilder(
valueListenable: session.text,
builder: (context, text, _) => Text(text.full),
);
await session.stop();
Already capture audio yourself? Hand it over instead of using the microphone:
await session.transcribeStream(
myAudio,
format: const AudioFormat(sampleRate: 48000),
);
Models #
Models are downloaded at runtime, not bundled with your app. Two good places to start:
| Model | Download | Word error rate* |
|---|---|---|
parakeet-tdt_ctc-110m-Q4_K_M |
90 MB | 2.5% |
moonshine-streaming-tiny-Q8_0 |
50 MB | 4.5% |
* LibriSpeech test-clean, from the models' published benchmarks.
Many more are available, including other languages: every model transcribe.cpp publishes up to 1 GB.
Platforms #
| iOS | 16.0 or later. Runs on the GPU. |
| Android | 7.0 (API 24) or later, 64-bit. Runs on the CPU. |
Documentation #
The full guide is at ishangavidusha.github.io/transcribe_cpp: choosing and downloading models, live text and sentences, interruptions, listening in the background, tuning, and how it all works.
The example app is a complete app with a model picker.
Contributing #
Bug reports, ideas and pull requests are welcome. See CONTRIBUTING.md.
Acknowledgements #
transcribe_cpp stands on the work of others:
- transcribe.cpp by the transcribe.cpp authors, the engine that runs the models, and the source of the model catalogue and the converted models on Hugging Face.
- ggml, the machine-learning library underneath it.
- Silero VAD, the voice detector, ported to C for this package.
- The model authors, including NVIDIA for Parakeet and the Moonshine team for Moonshine.
transcribe_cpp is an independent project, not an official part of transcribe.cpp.
License #
MIT. The package includes builds of transcribe.cpp and ggml, and weights derived from Silero VAD, all MIT; see THIRD-PARTY-LICENSES.md.
Speech models are downloaded by your app and carry their own licences, and
some are non-commercial. Parakeet, for example, is CC-BY-4.0, which asks apps
that use it to credit NVIDIA. Check ModelDescriptor.license for each model
you ship.
