Skip to content

feat(conversations): import audio files to create conversations (#4485) - #17854

Open
TheRWX wants to merge 1 commit into
BasedHardware:mainfrom
TheRWX:feat/import-audio-conversations-4485
Open

TheRWX wants to merge 1 commit into
BasedHardware:mainfrom
TheRWX:feat/import-audio-conversations-4485

Conversation

@TheRWX

@TheRWX TheRWX commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #4485

Description

Adds support for importing audio files to create conversations across iOS and Android (Plaud parity).

  • Backend:

    • Adds POST /v1/conversations/upload-audio accepting mp3, m4a, wav, aac, ogg, and flac files up to 200MB.
    • Normalizes audio to 16kHz mono WAV via pydub.AudioSegment in a worker thread.
    • Transcribes and diarizes speech segments using pre-recorded STT (prerecorded_from_bytes) and post-processes word timestamps.
    • Enriches conversation using LLM summarization and persists to Firestore via process_conversation.
    • Added imported: bool = False field to CreateConversation.
    • Comprehensive unit tests covering all validation rules (unsupported type, empty file, oversized file, corrupted file, STT failure, no speech) and successful pipeline execution.
    • Exported and verified docs/api-reference/app-client-openapi.json.
  • Mobile Client:

    • Added uploadAudioConversation multipart upload in lib/backend/http/api/conversations.dart.
    • Added audio import state and importAudioFile method in lib/providers/conversation_provider.dart.
    • Added UI entry points:
      • Dedicated "Audio Files" card in ImportHistoryPage.
      • "Import Audio" header button and empty-state shortcut in ConversationsPage.
    • Added unit test suite test/unit/audio_import_test.dart verifying extension validation, size limits, progress tracking, and error handling.

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

Line-Count-Exception: app/lib/providers/conversation_provider.dart | 1962 -> 2061 | add audio import state management and uploader workflow
Line-Count-Exception: backend/routers/conversations.py | 2133 -> 2275 | add upload-audio endpoint with audio normalization and conversation processing

PayPal: [email protected]

@TheRWX
TheRWX force-pushed the feat/import-audio-conversations-4485 branch from 520b0eb to 50d1ca5 Compare September 23, 2026 23:21
…dHardware#4485)

Add backend endpoint and mobile app flows to import external audio
files (mp3, m4a, wav, aac, ogg, flac) to create enriched conversations.

- Backend POST /v1/conversations/upload-audio with pydub normalization,
  diarized STT transcription, and conversation enrichment
- Mobile API client and ConversationProvider integration
- UI entry points in ImportHistoryPage and ConversationsPage header
- Desktop Swift and Windows/Web OpenAPI client models regenerated
- Register endpoint in route policy and undocumented public routes
- Comprehensive backend and Flutter test coverage

Resolves BasedHardware#4485
PayPal: [email protected]
@TheRWX
TheRWX force-pushed the feat/import-audio-conversations-4485 branch from 50d1ca5 to 0bfa983 Compare September 24, 2026 00:04
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @TheRWX — this is a well-built feature (resolves #4485) and the full-stack cohesion (backend route + Flutter wiring + generated surfaces + tests on both sides) makes it reviewable as one unit. Walkthrough with a few follow-ups:

Backend — backend/routers/conversations.py

  • New POST /v1/conversations/upload-audio: extension allowlist, 200MB cap, pydub normalization to 16kHz mono on sync_executor, prerecorded_from_bytes(diarize=True), postprocess_words, then process_conversation(trigger=CLIENT_FINALIZE) with the persistence/derived-effects observers. The endpoint tail correctly mirrors create_conversation's contract (re-read when not persisted, TERMINAL_NO_DERIVED_EFFECTS short-circuit, external-integration fan-out), and rate-limit coverage is bumped in backend/tests/unit/test_rate_limiting.py (6 → 7).
  • One safety question: POST /v1/conversations wraps its inline process_conversation call in lifecycle_service.processing_admission_guard(uid, id), whose job is rolling a failed admission back to in_progress instead of stranding the row on "processing". The new route calls process_conversation without that guard — if the guard applies to any synchronous CLIENT_FINALIZE write (not only Redis-admitted ones), a mid-processing failure here could strand an imported conversation on processing. Worth confirming (or wrapping) with someone who owns that lifecycle invariant.
  • Minor: language is passed through unvalidated into Deepgram; an unrecognized value will surface as a generic 502 ("Audio transcription service failed") rather than a 4xx. Consider validating against the known language set, and note process_conversation otherwise receives 'en' when null.
  • Minor: raw_bytes = await file.read() buffers the entire upload before the size check; checking Content-Length/streaming first would avoid holding a rejected oversized POST in memory.

Route surface

  • backend/route_policy_manifest.yaml registers the route with firebase_id_token auth and the conversations:create rate-limit policy (fail_closed, uid-keyed) — reasonable for an expensive STT+LLM route, though it shares the create budget; a dedicated budget is an easy follow-up if throughput/abuse ever warrants it.
  • backend/scripts/export_openapi.py, docs/api-reference/app-client-openapi.json and the four generated TS clients + the Swift client all add the endpoint consistently, and the route is kept out of the Developer API key contract, matching a first-party-app-only surface.

backend/models/conversation.py

  • imported: bool = False flows into Conversation.imported via the existing dict() merge — but source=ConversationSource.phone means imported meetings look exactly like real phone captures downstream. Import audios to create conversations #4485 is the Plaud-parity case and a plaud source value exists; is there a reason not to use a distinct source (and does anything read imported yet)? Maintainer call appreciated here, since the PR description says "Product invariants affected: none" and this is arguably one.

Flutter

  • app/lib/providers/conversation_provider.dart: clean DI via the AudioConversationUploader typedef, client-side extension/size validation mirroring the backend, progress and error state, upsertConversation on success.
  • app/lib/pages/settings/import_history_page.dart and app/lib/pages/conversations/conversations_page.dart wire the picker with mounted-checks and localized strings; app/lib/backend/http/api/conversations.dart upload helper reports non-transient failures to the crash reporter. Note the inline error snackbar falls back to raw English strings from audioImportError ("Unsupported audio format: .txt …") — fine for now; routing those through localized templates would be a nice follow-up.
  • Desktop/web only get the generated API surface, no import UI — reads as intentional mobile-first parity; flag if not.

Tests

  • backend/tests/unit/test_conversations_upload_audio.py covers the reject paths (bad extension, empty, oversize, corrupt audio via a real pydub decode attempt, STT failure → 502, no-speech → 400) and the success pipeline with process_conversation/trigger_external_integrations monkeypatched. app/test/unit/audio_import_test.dart covers client validation, progress tracking, upsert, and failure modes. Good coverage on both sides (CI suites green).

Checklist for the author (none of these block a human look):

  1. Confirm whether processing_admission_guard should wrap the inline processing here.
  2. Validate the language form field.
  3. Consider enforcing the size cap before buffering the full body.
  4. Confirm the source=phone + imported=true provenance choice vs a distinct source.

Since this adds a Firebase-authenticated 200MB data-ingress + transcription route on the core conversations surface (plus the provenance question above), it needs maintainer sign-off on the route/cost posture before merge — leaving for human maintainer review with the notes above. Automated maintainer-assist review on behalf of the Omi maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added backend Backend Task (python) needs-maintainer-review Needs a human maintainer to sign off before merge labels Sep 24, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature (audio file import for conversations) — approve only per policy, large cross-stack diff (backend+app+desktop+web), needs maintainer review before merge.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature (import audio files to create conversations, #4485) — approve-only per policy, not a bug fix. needs-maintainer-review label set.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature (import audio files to create conversations) — approve-only per policy. mergeStateStatus DIRTY, not merging.

@TheRWX

TheRWX commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the approval. This branch now conflicts with main. Happy to rebase it onto current main to clear the conflicts (no behavior changes, tests re-run) — want me to go ahead?

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feat(conversations): import audio files — large feature with tests, backend+mobile; approve-only

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import audios to create conversations

3 participants