Skip to content

Commit 35ff553

Browse files
committed
pr comments
1 parent a6e40b5 commit 35ff553

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

src/viam/components/audio_input/audio_input.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616

1717
class AudioInput(ComponentBase, StreamSource[Audio]):
18-
"""AudioInput represents a component that can capture audio.
18+
""" DEPRECATED: AudioInput is deprecated, use AudioIn instead
19+
AudioInput represents a component that can capture audio.
1920
2021
This acts as an abstract base class for any drivers representing specific
2122
audio input implementations. This cannot be used on its own. If the ``__init__()`` function is

src/viam/components/audio_input/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any, AsyncIterator, Dict, List, Mapping, Optional, Union
2+
import warnings
23

34
from grpclib.client import Channel
45

@@ -21,10 +22,17 @@
2122

2223
class AudioInputClient(AudioInput, ReconfigurableResourceRPCClientBase):
2324
"""
25+
DEPRECATED: AudioInput is deprecated, use AudioIn instead.
2426
gRPC client for the AudioInput component.
2527
"""
2628

2729
def __init__(self, name: str, channel: Channel):
30+
warnings.warn(
31+
"AudioInputClient is deprecated and will be removed in a future release. "
32+
"Use AudioIn instead.",
33+
DeprecationWarning,
34+
stacklevel=2,
35+
)
2836
self.channel = channel
2937
self.client = AudioInputServiceStub(channel)
3038
super().__init__(name)

src/viam/components/audio_input/service.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import wave
2+
import warnings
23
from datetime import timedelta
34
from io import BytesIO
45

@@ -25,9 +26,19 @@
2526

2627
class AudioInputRPCService(AudioInputServiceBase, ResourceRPCServiceBase[AudioInput]):
2728
"""
29+
DEPRECATED: AudioInput is deprecated, use AudioIn instead.
2830
gRPC Service for a generic AudioInput
2931
"""
3032

33+
def __init__(self, *args, **kwargs):
34+
warnings.warn(
35+
"AudioInput is deprecated and will be removed in a future release. "
36+
"Use AudioIn instead.",
37+
DeprecationWarning,
38+
stacklevel=2,
39+
)
40+
super().__init__(*args, **kwargs)
41+
3142
RESOURCE_TYPE = AudioInput
3243

3344
async def Chunks(self, stream: Stream[ChunksRequest, ChunksResponse]) -> None:

src/viam/media/audio.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from enum import Enum
23

34
from viam.proto.component.audioinput import AudioChunk, AudioChunkInfo
45
from viam.streams import Stream, StreamReader
@@ -14,3 +15,29 @@ class Audio:
1415

1516
AudioReader = StreamReader[Audio]
1617
AudioStream = Stream[Audio]
18+
19+
class AudioCodec(str, Enum):
20+
"""Common audio codec identifiers.
21+
22+
These constants represent commonly supported audio codecs
23+
for audioin and audioout components.
24+
25+
Example::
26+
27+
from viam.components.codecs import AudioCodec
28+
from viam.proto.common import AudioInfo
29+
30+
audio_info = AudioInfo(
31+
codec=AudioCodec.PCM16,
32+
sample_rate_hz=44100,
33+
num_channels=2
34+
)
35+
"""
36+
37+
PCM16 = "pcm16"
38+
PCM32 = "pcm32"
39+
PCM32_FLOAT = "pcm32float"
40+
MP3 = "mp3"
41+
AAC = "aac"
42+
OPUS = "opus"
43+
FLAC = "flac"

0 commit comments

Comments
 (0)