fix: audio playback broken — wrong directory and .wav/.ogg mismatch #11
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_voice#11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Audio directory mismatch
hero_proc launches hero_voice_ui with its own cwd. The WebSocket handler in
ws.rs:227uses a client-provided relative path (data/audio) to write audio files, which resolves against hero_proc's cwd. ButServeDirinmain.rs:138serves from the absolutedata_dir()path (~/hero/var/voice/audio/). Files are written to one location, served from another — playback returns 404..wav/.ogg filename mismatch
register_audio_via_rpcinws.rs:144registers the.wavfilename. Thenconvert_in_backgroundconverts the file to.oggand deletes the original.wav. The UI requests the.wavfilename from but only the.oggfile exists on disk — playback fails with "no supported source found".same issue of wav and ogg mismatch when deleting audio
Implementation Spec for Issue #11
Objective
Fix audio playback failures caused by two distinct issues:
data/audio/{topic_sid}) that resolves against the process's current working directory, butServeDirserves from an absolute path (~/hero/var/voice/audio/)..wavextension but converted to.ogg(with the original.wavdeleted), causing playback to fail because the registered filename no longer exists.Requirements
ServeDirserves from (~/hero/var/voice/audio/{topic_sid})voiceservice.get_audio_pathmust return an absolute path that is consistent with where the UI server expects files.oggextension after conversion completes, not.wavbefore conversionvoiceservice.delete_audiomust handle the.oggextension correctly.wavfiles that may exist)Files to Modify
crates/hero_voice/src/voice/server/rpc.rsDATA_DIRusage anddelete_audioto handle both.wavand.oggcrates/hero_voice_ui/src/ws.rs.oggextension after conversion completesImplementation Plan
Step 1: Fix the data directory path resolution in
rpc.rsFile:
crates/hero_voice/src/voice/server/rpc.rsDATA_DIRconstant with a function that returns an absolute pathconst DATA_DIR: &str = "data";which creates relative pathsdata_dir()function that returns~/hero/var/voice(or reads fromHERO_VOICE_DATAenv var), matching the logic inhero_voice_ui/src/main.rsaudio_dir_for()andtransforms_dir_for()to use the new absolute path functionStep 2: Fix
delete_audioto handle both.wavand.oggfilesFile:
crates/hero_voice/src/voice/server/rpc.rs.wav, try the.oggversion.ogg, try the.wavversion.wavfiles while also handling the new.oggfiles correctlyStep 3: Register audio with
.oggextension after conversion completesFile:
crates/hero_voice_ui/src/ws.rsstop_register_convert, change the filename from.wavto.oggbefore callingregister_audio_via_rpc"wav"to"ogg"Acceptance Criteria
~/hero/var/voice/audio/{topic_sid}/regardless of wherehero_procstarts the servervoiceservice.get_audio_pathreturns an absolute pathServeDirat/files/audiosuccessfully serves audio files after recording.oggextension, matching the final file on diskvoiceservice.delete_audiosuccessfully deletes.oggfiles.wavfiles (if any) can still be deletedNotes
hero_proclauncheshero_voice_ui, the working directory may be different from where the code expects. The fix ensures all paths are absolute, eliminating this dependency.HERO_VOICE_DATAenvironment variable if set, falling back to~/hero/var/voice, matching the existing convention inhero_voice_ui/src/main.rs.sizefield in theAudioFileInfowill reflect the original.wavsize, not the compressed.oggsize. This is acceptable for display purposes.Implementation Complete
Test Results
All tests pass.
Changes Made
1. Fixed data directory path in
rpc.rsconst DATA_DIR: &str = "data"withdata_dir()function~/hero/var/voice(orHERO_VOICE_DATAenv var)audio_dir_for()andtransforms_dir_for()to use the new function2. Fixed
delete_audiofor.wav/.oggextension mismatch.wav↔.ogg)3. Fixed audio registration in
ws.rsstop_register_convert()now registers with.oggextensionconvert_in_background()producesFiles Modified
crates/hero_voice/src/voice/server/rpc.rscrates/hero_voice_ui/src/ws.rsReady for PR.
Acceptance Criteria Verification
1. Audio directory mismatch ✅
ws.rsdefaults tostate.data_dir.join("audio")→~/hero/var/voice/audiorpc.rsnow usesdata_dir()→~/hero/var/voiceServeDirserves from same absolute path2. .wav/.ogg filename mismatch ✅
register_audio_via_rpcnow registers.oggextensionconvert_in_background()output.oggwhich exists on diskBoth issues from the original report are resolved. PR #15 ready for merge.