Skip to content

remove dead audio accumulation - #198

Merged
raghavm243512 merged 3 commits into
refactor/phase1_code_path_consolidationfrom
refactor/phase2_recording_consolidation
Aug 4, 2026
Merged

remove dead audio accumulation#198
raghavm243512 merged 3 commits into
refactor/phase1_code_path_consolidationfrom
refactor/phase2_recording_consolidation

Conversation

@raghavm243512

@raghavm243512 raghavm243512 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Removed some duplicate implementations of saving audio
Removed buffers being tracked but unused
Remove duplicate saving of audio

Tested end to end locally, net change in behavior is none

@JosephMarinier JosephMarinier 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.

We can accumulate the user_clean_audio chunks in a contiguous bytearray with .extend() to avoid the list[bytes]'s per-chunk pointer overhead and the final b"".join(). This is already used for the equivalent buffers in base_server.py and its subclasses.

Comment thread src/eva/user_simulator/base.py Outdated

self._user_audio_chunks: list[bytes] = []
self._assistant_audio_chunks: list[bytes] = []
self._user_clean_audio_chunks: list[bytes] = []

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.

Suggested change
self._user_clean_audio_chunks: list[bytes] = []
self._user_clean_audio = bytearray()

Comment thread src/eva/user_simulator/base.py Outdated
self._assistant_audio_chunks.append(audio_data)
elif source == "user_clean":
if source == "user_clean":
self._user_clean_audio_chunks.append(audio_data)

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.

Suggested change
self._user_clean_audio_chunks.append(audio_data)
self._user_clean_audio.extend(audio_data)

Comment thread src/eva/user_simulator/base.py Outdated
Comment on lines +181 to +185
if save_audio_track(
self._user_clean_audio_chunks,
self.output_dir / "audio_user_clean.wav",
sample_rate,
):

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.

Suggested change
if save_audio_track(
self._user_clean_audio_chunks,
self.output_dir / "audio_user_clean.wav",
sample_rate,
):
if save_audio_track(bytes(self._user_clean_audio), self.output_dir / "audio_user_clean.wav", sample_rate):

Comment thread src/eva/utils/audio_utils.py Outdated


def save_audio_track(
data: bytes | list[bytes],

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.

Suggested change
data: bytes | list[bytes],
audio_bytes: bytes,

Comment thread src/eva/utils/audio_utils.py Outdated
) -> bool:
"""Save a single-track PCM recording to a WAV file, skipping empty audio.

Accepts either raw PCM bytes or a list of PCM chunks (which are joined).

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.

Suggested change
Accepts either raw PCM bytes or a list of PCM chunks (which are joined).

Comment thread src/eva/utils/audio_utils.py Outdated
This is the shared entry point for both the assistant server's deferred
audio saving and the user simulator's clean-track saving.
"""
audio_bytes = b"".join(data) if isinstance(data, list) else data

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.

Suggested change
audio_bytes = b"".join(data) if isinstance(data, list) else data

user_audio, assistant_audio = sim.get_recorded_audio()
assert user_audio == b"\x01\x02\x03"
assert assistant_audio == b"\xaa\xbb\xcc"
assert sim._user_clean_audio_chunks == [b"\x03\x04", b"\x05\x06"]

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.

Suggested change
assert sim._user_clean_audio_chunks == [b"\x03\x04", b"\x05\x06"]
assert sim._user_clean_audio == b"\x03\x04\x05\x06"

@JosephMarinier JosephMarinier 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.

Nice cleanup! Thank you very much!

…idation' into refactor/phase2_recording_consolidation

# Conflicts:
#	src/eva/assistant/base_server.py
@raghavm243512
raghavm243512 merged commit 08e32bd into refactor/phase1_code_path_consolidation Aug 4, 2026
2 checks passed
@raghavm243512
raghavm243512 deleted the refactor/phase2_recording_consolidation branch August 4, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants