whisper.cpp transcribe

swaleio/[email protected]

whisper.cpp transcribe

Runs whisper-cli from whisper.cpp, the C/C++ implementation of OpenAI's Whisper speech recognition, on one audio file. It writes the transcript four ways next to output_prefix: plain text (.txt), SubRip and WebVTT subtitles with timestamps (.srt, .vtt), and JSON with each segment's text and times (.json).

The model is a file in whisper.cpp's own format. Fetch one with swaleio/hf-download from ggerganov/whisper.cpp (MIT), which holds every Whisper size from tiny to large-v3-turbo, in full precision and quantized; the *.en models are English-only and a little more accurate on English. The task reads WAV, MP3 and FLAC directly; convert video or other audio formats with swaleio/ffmpeg first.

Inputs

Input Required Default Description
model yes โ€” Absolute path of a whisper.cpp model file (ggml-*.bin), such as one swaleio/hf-download placed on the workspace.
audio yes โ€” Absolute path of the WAV, MP3 or FLAC file to transcribe.
output_prefix yes โ€” Absolute path without an extension; the task writes <prefix>.txt, .srt, .vtt and .json. The directory must already exist: whisper-cli does not create it. Point it at the mounted workspace (e.g. ${{env.WORKFLOW_STORAGE}}/talk) to share them with later tasks.
language no en Spoken language as a two-letter code, or auto to detect it. en is whisper.cpp's own default.

Outputs

None. The transcripts are at output_prefix plus their extensions, a path the workflow chose; pass it to the next task.

Compute

GPU recommended. The image carries both a CUDA and a CPU build of whisper.cpp and uses the GPU when the compute type has one. On a CPU compute type the task runs on the CPU build, many times slower, where the base and small models are the practical sizes.

Example

Fetch the quantized large-v3-turbo model and a sample recording, then transcribe it on a GPU:

name: whisper.cpp example
compute_type: cpu-4
entry_point: main

blocks:
  main:
    tasks:
      model:
        name: Fetch model
        uses: swaleio/hf-download
        args:
          repo: ggerganov/whisper.cpp
          include: "ggml-large-v3-turbo-q5_0.bin"
          dest: ${{env.WORKFLOW_STORAGE}}/whisper
      audio:
        name: Fetch audio
        uses: swaleio/http-request
        args:
          url: https://raw.githubusercontent.com/ggml-org/whisper.cpp/v1.9.6/samples/jfk.wav
          response_path: ${{env.WORKFLOW_STORAGE}}/jfk.wav
      transcribe:
        name: Transcribe
        uses: swaleio/whisper-cpp
        compute_type: a100-1
        start_on:
          - model
          - audio
        args:
          model: ${{env.WORKFLOW_STORAGE}}/whisper/ggml-large-v3-turbo-q5_0.bin
          audio: ${{env.WORKFLOW_STORAGE}}/jfk.wav
          output_prefix: ${{env.WORKFLOW_STORAGE}}/jfk
          language: auto

Later tasks read ${{env.WORKFLOW_STORAGE}}/jfk.txt and its .srt, .vtt and .json siblings.


For the workflow syntax these examples use, see the workflow definition reference in the Swale documentation.

Licensed under the MIT License.