Skip to content

[Example] 370 — Swift iOS Live Transcription#117

Merged
lukeocodes merged 3 commits intomainfrom
example/260-swift-ios-live-transcription
Apr 2, 2026
Merged

[Example] 370 — Swift iOS Live Transcription#117
lukeocodes merged 3 commits intomainfrom
example/260-swift-ios-live-transcription

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 2, 2026

New example: Swift iOS Live Transcription

Integration: Swift iOS (AVAudioEngine + URLSessionWebSocketTask) | Language: Swift | Products: STT

What this shows

A native SwiftUI iOS app that captures microphone audio using AVAudioEngine, streams 16 kHz mono PCM to Deepgram's live STT WebSocket API, and displays real-time transcription with interim and final results. Uses zero third-party dependencies — only Apple frameworks (AVFoundation, SwiftUI, Foundation).

Required secrets

None — only DEEPGRAM_API_KEY required


Built by Engineer on 2026-04-02

@github-actions github-actions bot added type:example New example language:swift Language: Swift integration:swift-ios Integration: Swift iOS labels Apr 2, 2026
@github-actions github-actions bot force-pushed the example/260-swift-ios-live-transcription branch from e7fb75c to 35c9a2d Compare April 2, 2026 13:04
@github-actions github-actions bot changed the title [Example] 260 — Swift iOS Live Transcription with AVAudioEngine [Example] 260 — Swift iOS Live Transcription Apr 2, 2026
@lukeocodes lukeocodes changed the title [Example] 260 — Swift iOS Live Transcription [Example] 370 — Swift iOS Live Transcription Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 2, 2026

Code Review

Overall: CHANGES REQUESTED

Tests ran ❌

tests/test_example.py::test_deepgram_live_stt PASSED
tests/test_example.py::test_deepgram_live_websocket FAILED

test_deepgram_live_websocket:
  AssertionError: WebSocket errors: [{'error': "fin=1 opcode=8 data=b'\\x03\\xe8'"}]
  The on_error handler captures the normal WebSocket close frame (status 1000 = normal closure)
  as an error, causing the test to fail.

STT test output: ✓ Deepgram STT integration working (validates API key + nova-3 model)

Integration genuineness

Pass — The Swift code makes real WebSocket API calls to wss://api.deepgram.com/v1/listen with proper auth headers. Tests use real credentials and exit 2 if missing. There is no official Deepgram Swift SDK, so the raw WebSocket approach via URLSessionWebSocketTask is appropriate and clearly documented.

Code quality

  1. ❌ WebSocket test bugtest_deepgram_live_websocket treats a normal WebSocket close frame (opcode 8, status 1000) as an error. The on_error callback fires on close, but \x03\xe8 = 1000 = normal closure. The error-check logic needs to exclude normal close frames.
  2. ❌ Word-list assertion in testtest_deepgram_live_stt (line 51-53) asserts specific keywords ["spacewalk", "astronaut", "nasa"]. Transcription is non-deterministic; use transcript length or duration proportionality instead of specific word lists to avoid flaky tests.
  3. tag: "deepgram-examples" present in Swift source (DeepgramClient.swift:64) and both test functions.
  4. ✓ No hardcoded credentials — API key read from environment variable.
  5. ✓ Error handling — covers missing API key, microphone failure, WebSocket disconnection, audio conversion errors.
  6. ✓ Credential check before SDK imports — test file checks credentials before importing deepgram.

Documentation

  1. ❌ README path mismatch — README says cd examples/260-swift-ios-live-transcription but the actual directory is 370-swift-ios-live-transcription.
  2. ✓ "What you'll build" section present.
  3. ✓ Env vars table with link to Deepgram console.
  4. ✓ Run instructions with two options (Swift Package and Xcode project).
  5. .env.example present and complete.

Please address the items above. The fix agent will pick this up.


Review by Lead on 2026-04-02

@github-actions github-actions bot added the status:fix-needed Tests failing — fix agent queued label Apr 2, 2026
…-list assertions, correct README path in 370-swift-ios-live-transcription
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 2, 2026

Fix applied

Root cause: Three issues: (1) WebSocket on_error handler treated normal close frames (opcode 8, status 1000) as errors, causing test_deepgram_live_websocket to fail; (2) test_deepgram_live_stt used word-list assertions that are flaky with non-deterministic transcription; (3) README referenced wrong directory path 260- instead of 370-.

Change:

  1. test_example.pyon_error now ignores normal WebSocket close frames (status 1000 / \x03\xe8)
  2. test_example.py — Replaced word-list keyword assertions with transcript length and audio duration proportionality checks
  3. README.md — Corrected path from 260-swift-ios-live-transcription to 370-swift-ios-live-transcription

The lead reviewer will re-run tests and review on the next sweep.


Fix by Lead on 2026-04-02

@github-actions github-actions bot removed the status:fix-needed Tests failing — fix agent queued label Apr 2, 2026
@lukeocodes lukeocodes merged commit 95eb548 into main Apr 2, 2026
@lukeocodes lukeocodes deleted the example/260-swift-ios-live-transcription branch April 2, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:swift-ios Integration: Swift iOS language:swift Language: Swift type:example New example

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant