Skip to content

fix(discord): transcribe inbound audio attachments#2700

Merged
theonlyhennygod merged 1 commit intodevfrom
issue-2686-discord-transcription
Mar 4, 2026
Merged

fix(discord): transcribe inbound audio attachments#2700
theonlyhennygod merged 1 commit intodevfrom
issue-2686-discord-transcription

Conversation

@theonlyhennygod
Copy link
Collaborator

@theonlyhennygod theonlyhennygod commented Mar 4, 2026

Summary

  • add Discord channel transcription config wiring via .with_transcription(config.transcription.clone())
  • extend inbound Discord attachment processing to detect audio attachments and transcribe them with the shared Whisper-compatible transcription module
  • enforce configured duration limits when Discord exposes duration_secs, while preserving existing image/text attachment behavior

Root Cause

Discord inbound attachments only handled images and text; audio attachments were skipped, so no transcription path was ever invoked.

Validation

  • cargo fmt --all -- --check
  • cargo test --lib discord::tests::process_attachments_ -- --nocapture
  • cargo test --lib discord::tests::is_audio_attachment -- --nocapture
  • cargo test --lib discord::tests::infer_audio_filename_ -- --nocapture
  • cargo test --lib discord::tests::with_transcription_ -- --nocapture
  • cargo check --package zeroclaw --lib

Notes

  • process_attachments_transcribes_audio_when_enabled is included as an ignored test because this sandbox disallows loopback TCP binds; it can run in unrestricted CI/dev environments.

Closes #2686

Summary by CodeRabbit

  • New Features

    • Added voice transcription for Discord audio attachments. Audio files are now automatically transcribed to text and included in message content when enabled per channel. Supports configurable maximum duration limits to control transcription processing.
  • Tests

    • Extended test coverage for voice transcription functionality, including configuration options and various enabled/disabled scenarios.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Thanks for contributing to ZeroClaw.

For faster review, please ensure:

  • PR template sections are fully completed
  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings, and cargo test are included
  • If automation/agents were used heavily, add brief workflow notes
  • Scope is focused (prefer one concern per PR)

See CONTRIBUTING.md and docs/pr-workflow.md for full collaboration rules.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Warning

Rate limit exceeded

@theonlyhennygod has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6d72bc92-2f89-4996-a890-93529696d23e

📥 Commits

Reviewing files that changed from the base of the PR and between ae41b17 and c7b58b5.

📒 Files selected for processing (2)
  • src/channels/discord.rs
  • src/channels/mod.rs

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'tools', 'path_filters', 'review_instructions'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

This PR implements voice transcription support for Discord channels by introducing a TranscriptionConfig field to DiscordChannel, extending the attachment processing logic to detect, fetch, and transcribe audio files when enabled, and wiring the configuration through the Discord channel initialization.

Changes

Cohort / File(s) Summary
Discord Voice Transcription
src/channels/discord.rs
Added transcription: Option<TranscriptionConfig> field and with_transcription() method to DiscordChannel. Extended process_attachments() to accept optional transcription config, classify audio attachments, apply duration limits, fetch audio data, invoke transcription service, and inject [Voice:<filename>] markers into output. Introduced helper functions for audio detection, content-type normalization, filename inference, and audio extension mapping. Updated call-sites and added tests for transcription flows.
Channel Configuration
src/channels/mod.rs
Chained .with_transcription(config.transcription.clone()) to the Discord channel construction in collect_configured_channels to apply transcription settings from config.

Sequence Diagram(s)

sequenceDiagram
    participant Discord as Discord Channel Handler
    participant Fetch as HTTP Client
    participant Transcribe as Transcription Service
    participant Output as Message Output

    rect rgba(100, 150, 200, 0.5)
    Note over Discord,Output: Audio Transcription Flow
    Discord->>Discord: Detect audio attachment
    Discord->>Discord: Check duration limits
    Discord->>Fetch: Fetch audio file
    Fetch-->>Discord: Audio data
    Discord->>Transcribe: transcribe_audio(data, config)
    Transcribe-->>Discord: Transcript text
    Discord->>Output: Inject [Voice:filename] transcript
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

size: M, risk: medium, channel, channel: transcription

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is incomplete. While it covers the problem, solution, and validation steps, it lacks required metadata sections including risk level, size label, scope labels, module labels, change type, security impact, privacy status, backward compatibility, and rollback plan. Complete all required sections in the description template: Label Snapshot, Change Metadata, Security Impact, Privacy/Data Hygiene, Compatibility, and Rollback Plan.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(discord): transcribe inbound audio attachments' clearly and concisely describes the main change—adding transcription support for audio attachments in Discord channels.
Linked Issues check ✅ Passed The PR fully addresses issue #2686: it detects audio attachments in Discord, integrates transcription via the shared Whisper module, respects duration limits, and provides functional parity with other channels like Telegram.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to fixing Discord audio transcription: adding transcription config wiring, audio detection, transcription integration, and supporting tests. No unrelated refactoring or scope creep detected.
Docstring Coverage ✅ Passed Docstring coverage is 86.49% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-2686-discord-transcription

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

PR intake checks found warnings (non-blocking)

Fast safe checks found advisory issues. CI lint/test/build gates still enforce merge quality.

  • Missing required PR template sections: ## Validation Evidence (required), ## Security Impact (required), ## Privacy and Data Hygiene (required), ## Rollback Plan (required)
  • Incomplete required PR template fields: summary problem, summary why it matters, summary what changed, validation commands, security risk/mitigation, privacy status, rollback plan
  • Missing Linear issue key reference (RMN-<id>, CDV-<id>, or COM-<id>) in PR title/body (recommended for traceability, non-blocking).

Action items:

  1. Complete required PR template sections/fields.
  2. (Recommended) Link this PR to one active Linear issue key (RMN-xxx/CDV-xxx/COM-xxx) for traceability.
  3. Remove tabs, trailing whitespace, and merge conflict markers from added lines.
  4. Re-run local checks before pushing:
    • ./scripts/ci/rust_quality_gate.sh
    • ./scripts/ci/rust_strict_delta_gate.sh
    • ./scripts/ci/docs_quality_gate.sh

Detected Linear keys: none

Run logs: https://github.com/zeroclaw-labs/zeroclaw/actions/runs/22666032846

Detected blocking line issues (sample):

  • none

Detected advisory line issues (sample):

  • none

@github-actions github-actions bot added channel Auto scope: src/channels/** changed. size: M Auto size: 251-500 non-doc changed lines. risk: medium Auto risk: src/** or dependency/config changes. distinguished contributor Contributor with 50+ merged PRs. channel: discord Auto module: channel/discord changed. and removed channel Auto scope: src/channels/** changed. labels Mar 4, 2026
@theonlyhennygod theonlyhennygod self-assigned this Mar 4, 2026
@theonlyhennygod theonlyhennygod changed the base branch from main to dev March 4, 2026 10:33
@github-actions github-actions bot added ci Auto scope: CI/workflow/hook files changed. docs Auto scope: docs/markdown/template files changed. dependencies Auto scope: dependency manifest/lock/policy changed. core Auto scope: root src/*.rs files changed. agent Auto scope: src/agent/** changed. channel Auto scope: src/channels/** changed. config Auto scope: src/config/** changed. cron Auto scope: src/cron/** changed. daemon Auto scope: src/daemon/** changed. doctor Auto scope: src/doctor/** changed. gateway Auto scope: src/gateway/** changed. integration Auto scope: src/integrations/** changed. memory Auto scope: src/memory/** changed. observability Auto scope: src/observability/** changed. onboard Auto scope: src/onboard/** changed. provider Auto scope: src/providers/** changed. labels Mar 4, 2026
@github-actions github-actions bot added cron: scheduler Auto module: cron/scheduler changed. integration: core Auto module: integration core files changed. service: core Auto module: service core files changed. doctor: core Auto module: doctor core files changed. runtime: native Auto module: runtime/native changed. skillforge: core Auto module: skillforge core files changed. labels Mar 4, 2026
@theonlyhennygod theonlyhennygod force-pushed the issue-2686-discord-transcription branch from ae41b17 to c7b58b5 Compare March 4, 2026 10:47
@github-actions github-actions bot removed ci Auto scope: CI/workflow/hook files changed. docs Auto scope: docs/markdown/template files changed. dependencies Auto scope: dependency manifest/lock/policy changed. core Auto scope: root src/*.rs files changed. agent Auto scope: src/agent/** changed. gateway Auto scope: src/gateway/** changed. memory Auto scope: src/memory/** changed. observability Auto scope: src/observability/** changed. provider Auto scope: src/providers/** changed. security Auto scope: src/security/** changed. skills Auto scope: src/skills/** changed. tool Auto scope: src/tools/** changed. labels Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Auto module: channel/discord changed. distinguished contributor Contributor with 50+ merged PRs. risk: medium Auto risk: src/** or dependency/config changes. size: M Auto size: 251-500 non-doc changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The transcription on the Discord channel isn't working.

1 participant