id: whisper-audio-transcript-notes
namespace: company.team
description: |
Transcribe an audio file with faster-whisper in a container, emit the
transcript, and only alert Slack when the audio actually produced speech.
triggers:
- id: new_recording_webhook
type: io.kestra.plugin.core.trigger.Webhook
description: Call from your storage or upload pipeline when a new recording lands.
key: transcribe-audio
- id: weekly_batch
type: io.kestra.plugin.core.trigger.Schedule
description: Optional weekly re-transcription of a URL; shipped disabled.
cron: "0 6 * * 2"
disabled: true
inputs:
- id: audio_url
type: STRING
defaults: https://example.com/sample.mp3
description: Direct URL to the audio file (mp3, wav, m4a).
- id: language
type: STRING
defaults: en
description: Expected language code; set empty string for auto-detect.
- id: model_size
type: STRING
defaults: base
description: faster-whisper model size — tiny, base, small, medium, large-v3.
tasks:
- id: transcribe
type: io.kestra.plugin.scripts.shell.Commands
description: Download the audio and run faster-whisper inside the official
image; emit segment count, duration, and the transcript path via the
stdout outputs protocol. Empty transcripts are a first-class result, not
an exception.
containerImage: python:3.11-slim
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
commands:
- |
set -eu
pip install --quiet faster-whisper==1.0.3
apt-get update -qq >/dev/null 2>&1 || true
apt-get install -y -qq ffmpeg >/dev/null 2>&1 || true
curl -fsSL "{{ inputs.audio_url }}" -o audio.bin
python3 -c "
import json
from faster_whisper import WhisperModel
model = WhisperModel('{{ inputs.model_size }}', device='cpu', compute_type='int8')
segments, info = model.transcribe('audio.bin', language='{{ inputs.language }}' or None)
texts = [s.text.strip() for s in segments]
with open('transcript.txt', 'w') as f:
f.write('\n'.join(texts))
spoken = sum(len(t) for t in texts) > 0
print(f'duration {info.duration:.1f}s, segments {len(texts)}')
print('::' + json.dumps({'outputs': {'segments': len(texts), 'duration': round(info.duration, 1), 'has_speech': spoken}}) + '::')
"
outputFiles:
- transcript.txt
- id: check_transcript
type: io.kestra.plugin.core.flow.If
description: Speech present → transcript notification; empty → a separate alert
so silence is never confused with success.
condition: "{{ outputs.transcribe.vars.has_speech }}"
then:
- id: notify_transcript_ready
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Announce the transcript with segment count and duration.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": ":microphone: Transcript ready for {{ inputs.audio_url }} — {{ outputs.transcribe.vars.segments }} segments over {{ outputs.transcribe.vars.duration }}s ({{ inputs.model_size }} model). Execution {{ execution.id }}."
}
else:
- id: alert_empty_transcript
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: A silent recording is usually a mic problem — say so explicitly.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": ":warning: Transcription of {{ inputs.audio_url }} produced NO speech ({{ outputs.transcribe.vars.duration }}s of audio). Check the recording source or language setting. Execution {{ execution.id }}."
}
errors:
- id: alert_transcription_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Alert when transcription itself fails — a crash must not look like
an empty transcript.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": "Transcription FAILED in flow {{ flow.id }} (execution {{ execution.id }}) for {{ inputs.audio_url }}. Check the audio URL and model_size."
}
outputs:
- id: transcription_meta
type: JSON
description: 'Segment count, duration, and speech flag, e.g. {"segments": 42,
"duration": 318.5, "has_speech": true}.'
value: "{{ outputs.transcribe.vars | toJson }}"