You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Offline/WAL sync uploads decoded WAV instead of raw opus — 16x unnecessary bandwidth and storage #5363
The live streaming path (BLE → WebSocket) correctly sends opus frames to the backend, which decodes server-side via opuslib. However, the offline/WAL sync path (/v1/sync-local-files) decodes opus → PCM on the phone, converts to WAV, then uploads the WAV file.
This means:
~16x larger uploads (opus ~7 MB/hr vs WAV ~115 MB/hr at 16kHz mono 16-bit)
~16x more GCS storage per conversation for audio chunks
Unnecessary phone CPU usage decoding opus before upload
Longer sync times on cellular/slow connections
For all-day recorders, this adds up to nearly 1 GB/day of raw PCM stored per user vs ~60 MB if kept as opus.
Root Cause
The two audio paths (live streaming vs offline sync) were built independently:
Live streaming ( WebSocket): accepts param, decodes server-side ✅
Status check (2026-08-05) — upload half of this issue is already fixed on main
Re-verified against current main (07494f52): the stated bug (“phone decodes opus → WAV then uploads WAV to /v1/sync-local-files”) no longer matches the shipping paths.
What the code does now
App (Flutter / shared WAL sync) writes length-prefixed opus frames to disk and uploads those .bin files via POST /v2/sync-local-files:
Native phone-mic / batch writers (iOS BaseBatchAudioWriter, Android BaseBatchAudioWriter + PhoneMicOpusEncoder) also emit the same length-prefixed .bin layout.
Backend rejects non-.bin uploads and decodes server-side:
backend/utils/sync/files.pyretrieve_file_paths / v2 equivalent — endswith('.bin') only
decode_opus_file_to_wav — opus → WAV for VAD/STT
GCS chunks are stored as .opus via upload_audio_chunk → encode_pcm_to_opus (after the server decode)
Local WAV decode in the app (audio_player_utils._decodeOpusToWav) is for playback/share, not sync upload.
What remains (separate from the 16× upload claim)
Sync still does opus → WAV → PCM → opus on the server for STT then storage. That is CPU / latency waste, not a 16× wire/GCS blowup from client WAV uploads. Fixing that would be a new scoped change (“store original WAL opus framing without re-encode” or share AAC/opus) — not the original proposed app-side “stop uploading WAV.”
Suggest closing this issue as fixed for the upload path, or retitling/splitting if maintainers want a follow-up for the server re-encode.
— verified by @aryanorastar (no PR needed for the original claim)
Fixed by #12893 (merge commit d324a95): the WAL sync path now rejects decoded WAV and any non-framed name via assertWalSyncFilesAreFramedBins before /v2/sync-local-files, keeping uploads framed opus/PCM .bin.
Activity
feat(wal-sync): sync.py — add POST /v1/sync/force endpoint
aryanorastar commentedon Aug 5, 2026
Status check (2026-08-05) — upload half of this issue is already fixed on
mainRe-verified against current
main(07494f52): the stated bug (“phone decodes opus → WAV then uploads WAV to/v1/sync-local-files”) no longer matches the shipping paths.What the code does now
App (Flutter / shared WAL sync) writes length-prefixed opus frames to disk and uploads those
.binfiles viaPOST /v2/sync-local-files:app/lib/services/wals/local_wal_sync.dart— flush builds length-prefixed frames →.binapp/lib/services/wals/wal.dart— filenames likeaudio_*_opus_*_fsN_*.binapp/lib/backend/http/api/conversations.dart—uploadLocalFilesV2→v2/sync-local-filesNative phone-mic / batch writers (iOS
BaseBatchAudioWriter, AndroidBaseBatchAudioWriter+PhoneMicOpusEncoder) also emit the same length-prefixed.binlayout.Backend rejects non-
.binuploads and decodes server-side:backend/utils/sync/files.pyretrieve_file_paths/ v2 equivalent —endswith('.bin')onlydecode_opus_file_to_wav— opus → WAV for VAD/STT.opusviaupload_audio_chunk→encode_pcm_to_opus(after the server decode)Local WAV decode in the app (
audio_player_utils._decodeOpusToWav) is for playback/share, not sync upload.What remains (separate from the 16× upload claim)
Sync still does opus → WAV → PCM → opus on the server for STT then storage. That is CPU / latency waste, not a 16× wire/GCS blowup from client WAV uploads. Fixing that would be a new scoped change (“store original WAL opus framing without re-encode” or share AAC/opus) — not the original proposed app-side “stop uploading WAV.”
Suggest closing this issue as fixed for the upload path, or retitling/splitting if maintainers want a follow-up for the server re-encode.
— verified by @aryanorastar (no PR needed for the original claim)
fix(app,backend): disconnect nags, WAL opus sync, speech-profile iden…
fix(app,backend): disconnect nags, WAL opus sync, speech-profile iden…
Git-on-my-level commentedon Sep 9, 2026
Fixed by #12893 (merge commit d324a95): the WAL sync path now rejects decoded WAV and any non-framed name via assertWalSyncFilesAreFramedBins before /v2/sync-local-files, keeping uploads framed opus/PCM .bin.