Skip to content

Getting started

  1. Add the package.

    Terminal window
    flutter pub add transcribe_cpp

    It runs on iOS 16+ and Android 7+ (API 24, 64-bit). See Platforms for the details.

  2. Let the app use the microphone and the network.

    The package declares no permissions of its own. Your app asks for the microphone, and needs the network once, to download a model.

    In ios/Runner/Info.plist, say why you need the microphone. iOS shows this text in the permission prompt:

    <key>NSMicrophoneUsageDescription</key>
    <string>Your speech is transcribed on this device.</string>
  3. Download a model.

    Models are not bundled with your app. ModelManager downloads the one you ask for, checks it, and keeps it for next time:

    final models = await ModelManager.open();
    final model = await models.ensure(
    const ModelId('parakeet-tdt_ctc-110m-Q4_K_M'), // 90 MB, English
    );

    The first call downloads; after that it returns immediately. See Models for choosing one and showing progress.

  4. Transcribe.

    final session = await TranscribeSession.open(model);
    await session.start(); // asks for the microphone the first time
    // ...the user speaks; each sentence is transcribed when they pause...
    await session.stop(); // waits for the last sentence
    await session.dispose(); // when you no longer need the model

    Show the text with a ValueListenableBuilder. It updates as the user speaks:

    ValueListenableBuilder(
    valueListenable: session.text,
    builder: (context, text, _) => Text(text.full),
    )