Skip to content

Conversation

@oliviamiller
Copy link
Member

@oliviamiller oliviamiller commented Oct 20, 2025

Wrappers for this proto update PR https://github.com/viamrobotics/viam-python-sdk/pull/1019/files , adding AudioIn and AudioOut new component types.

Manually tested using server and client example.

@oliviamiller oliviamiller requested a review from a team as a code owner October 20, 2025 16:02
Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

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

Looks good!

I assume we don't want people using AudioInput anymore. Can you add deprecation warnings to the AudioInput classes?

@@ -0,0 +1,26 @@

class AudioCodec:
Copy link
Member

Choose a reason for hiding this comment

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

Move this to media/audio.py

Also, this might be better served as an enum rather than a class

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to allow for flexibility beyond these predefined codecs so changed to inherit from both enum and str

@oliviamiller oliviamiller requested a review from njooma October 24, 2025 17:35
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

nice! Just a couple small comments/questions but otherwise looks good to me!


for sample in range(samples_per_chunk):
time_offset = (i * chunk_duration_ms / 1000) + (sample / self.sample_rate)
amplitude = int(32767 * 0.2 * math.sin(2 * math.pi * 440 * time_offset))
Copy link
Member

Choose a reason for hiding this comment

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

(q) I have absolutely zero idea why any of these numbers were selected though I assume it's all reasoned choices. Would someone who wanted to look at this example to understand how to use an AudioIn be reasonably expected to understand what these numbers are for and if/when they might want to change them? If not, can we add some comments explaining?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, I made most of them variables/added a comment to clarify

Comment on lines 260 to 261
if extra is None:
extra = {}
Copy link
Member

Choose a reason for hiding this comment

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

(q, minor) this isn't actually doing anything, is it worth keeping here? Same with get_properties below.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

return command

async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs):
return []
Copy link
Member

Choose a reason for hiding this comment

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

(minor, nit) could we have this return self.geometries and set self.geometries in the init, akin to what we're doing with MockAudioIn? I'm always a little wary of these test functions returning the zero value of a type because it's hard to distinguish between "everything is working correctly and we got the expected value" and "things are failing but it's silent because we're getting a default zero value which happens to be what we were expecting".

Copy link
Member Author

Choose a reason for hiding this comment

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

changed to match the audioin tests

@oliviamiller oliviamiller requested a review from stuqdog October 31, 2025 16:31
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.

5 participants