Cameleer

Google Speech-to-Text component

The google-speech-to-text component transcribes audio to text with the Google Cloud Speech-to-Text v1 API, from audio bytes or a gs:// file.

Scheme: google-speech-to-text: · Crate: cameleer-cloud · Cargo feature: cloud · Consumer: no · Producer: yes · Apache Camel: none (Cameleer component)

When to use it

  • Transcribe voice notes, call recordings or voicemail dropped into a folder or bucket.
  • Turn spoken commands from an edge device into text, then route on the text.
  • Feed transcripts to an LLM for summarization or classification (OpenAI, Vertex AI).

URI format

text
google-speech-to-text://label[?options]

The label is free text that names the endpoint; it is not sent to the API.

Example

Transcribe every .wav file in a folder and write the transcript next to it as a .txt file:

yaml example: google-speech-to-text-transcribe-folder
- route:
    id: transcribe-voice-notes
    from:
      uri: "file:{{env:INBOX_DIR:voice-notes}}?include=.*\\.wav&move=.done"
      steps:
        - to: "google-speech-to-text://notes?languageCode={{env:LANGUAGE:en-US}}&sampleRateHertz=16000&enableAutomaticPunctuation=true"
        - log: "transcribed ${file:name} (confidence ${header.CamelGoogleSpeechToTextConfidence})"
        - setHeader:
            name: CamelFileName
            simple: "${file:onlyname.noext}.txt"
        - to: "file:{{env:OUT_DIR:transcripts}}"

Rust DSL

rust
ctx.add_routes(|b| {
    b.from("file:voice-notes?include=.*\\.wav")
        .to("google-speech-to-text://notes?sampleRateHertz=16000")
        .log("${body}");
})?;

Options

optiondefaultdescription
operationrecognizerecognize, longRunningRecognize, getOperation. Header CamelGoogleSpeechToTextOperation.
encodingLINEAR16Audio encoding (LINEAR16, FLAC, MULAW, OGG_OPUS, ...).
sampleRateHertzSample rate of the audio.
languageCodeen-USLanguage of the speech.
modelRecognition model, for example latest_long or phone_call.
enableAutomaticPunctuationfalseAdd punctuation to the transcript.

Credentials are shared by all Google components: see credentials.

Operations

  • recognize: the body is the audio bytes, or a text gs://bucket/file URI. Body = the best transcript (results joined with spaces).
  • longRunningRecognize: starts an asynchronous recognition (for audio longer than a minute); body and CamelGoogleSpeechToTextOperationName = the operation name.
  • getOperation: checks the operation in CamelGoogleSpeechToTextOperationName; sets CamelGoogleSpeechToTextDone, and the body is the transcript once done.

Message headers

headerdirectiondescription
CamelGoogleSpeechToTextOperationinOperation.
CamelGoogleSpeechToTextConfidenceoutConfidence of the first result.
CamelGoogleSpeechToTextResultsoutAll results returned by the API.
CamelGoogleSpeechToTextOperationNamein / outLong-running operation name.
CamelGoogleSpeechToTextDoneoutgetOperation: whether the operation finished.

Run it with Docker

sh
docker run --rm -v "$PWD:/routes:ro" -v "$PWD/voice-notes:/in" -v "$PWD/transcripts:/out" \
  -v "$HOME/keys/sa.json:/keys/sa.json:ro" -e GOOGLE_APPLICATION_CREDENTIALS=/keys/sa.json \
  -e INBOX_DIR=/in -e OUT_DIR=/out \
  pmsudhi/cameleer run /routes/transcribe-voice-notes.camel.yaml

Common questions

How do I transcribe a file stored in Cloud Storage?

Send its URI as the body text, for example gs://my-bucket/call.wav.

How do I transcribe long recordings?

Use operation=longRunningRecognize, then poll with operation=getOperation (for example from a timer route) until CamelGoogleSpeechToTextDone is true.

Is streaming recognition supported?

No. Only the recognize and longrunningrecognize REST calls are implemented.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub