Skip to content

[Example] 220 — Django Channels Real-Time Transcription with Deepgram Live STT (Python)#105

Merged
lukeocodes merged 1 commit intomainfrom
example/220-django-channels-live-stt-python
Apr 2, 2026
Merged

[Example] 220 — Django Channels Real-Time Transcription with Deepgram Live STT (Python)#105
lukeocodes merged 1 commit intomainfrom
example/220-django-channels-live-stt-python

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

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

New example: Django Channels Real-Time Transcription with Deepgram Live STT

Integration: Django Channels | Language: Python | Products: STT

What this shows

A Django 5 application using Django Channels that captures browser microphone audio via a simple HTML/JS page, streams it over a WebSocket to a Django Channels async consumer, which forwards the audio to Deepgram's Live STT API (Nova-3) using the official Python SDK. Transcription results (both interim and final) are sent back to the browser and displayed in real-time. The Deepgram API key stays server-side only.

Required secrets

None — only DEEPGRAM_API_KEY required

Closes #34


Built by Engineer on 2026-04-01

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 2, 2026

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_deepgram_stt PASSED
  Deepgram STT integration working
  Transcript preview: 'Yeah. As as much as, it's worth celebrating, the first, spacewalk, with an all f...'
tests/test_example.py::test_django_imports PASSED
  Django settings configured correctly
tests/test_example.py::test_consumer_imports PASSED
  TranscriptionConsumer imports correctly
tests/test_example.py::test_template_exists PASSED
  Template exists and contains expected content

4 passed, 2 warnings in 2.09s

Integration genuineness

Pass.

  • Django Channels SDK imported and used: AsyncWebsocketConsumer, ProtocolTypeRouter, URLRouter, AuthMiddlewareStack
  • Real Deepgram Live STT WebSocket connection via AsyncDeepgramClient.listen.v1.connect() in consumer.py
  • Audio forwarding with send_media() and transcript delivery via EventType.MESSAGE callback — genuine bi-directional streaming
  • Django Channels is a framework (not an external API), so no additional platform credentials needed beyond DEEPGRAM_API_KEY
  • Test makes real Deepgram API call and exits with code 2 if credentials missing

Code quality

  • Official Deepgram Python SDK (deepgram-sdk>=4.0.0) used — no raw HTTP to Deepgram ✅
  • No hardcoded credentials — API key read from os.environ["DEEPGRAM_API_KEY"]
  • Error handling: on_error callback sends error JSON to browser, disconnect gracefully closes Deepgram connection with try/except ✅
  • Credential check in tests runs BEFORE SDK imports ✅
  • ASGI config properly routes HTTP and WebSocket protocols ✅
  • manage.py loads .env via python-dotenv before Django setup ✅
  • Clean separation: consumer, views, urls, settings, ASGI config, template ✅

Documentation

  • README explains what you'll build, architecture diagram, prerequisites, env vars with link to Deepgram console, install/run instructions, key parameters table ✅
  • .env.example present and complete ✅
  • Related links to Deepgram docs, Python SDK, Django Channels docs, and Daphne ✅

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-02

@github-actions github-actions bot added the status:review-passed Self-review passed label Apr 2, 2026
@lukeocodes lukeocodes merged commit 5392afc into main Apr 2, 2026
2 checks passed
@lukeocodes lukeocodes deleted the example/220-django-channels-live-stt-python branch April 2, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:django-channels Integration: Django Channels language:python Language: Python status:review-passed Self-review passed type:example New example

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Suggestion] Django Channels real-time transcription with WebSocket (Python)

1 participant