Skip to content

Commit 8639b10

Browse files
authored
RSDK-12160 Remove audio input (#1060)
1 parent 59b816d commit 8639b10

File tree

12 files changed

+3
-604
lines changed

12 files changed

+3
-604
lines changed

.github/workflows/code-samples-comment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
- "src/viam/components/sensor/sensor.py"
1313
- "src/viam/components/servo/servo.py"
1414
- "src/viam/components/arm/arm.py"
15-
- "src/viam/components/audio_input/audio_input.py"
1615
- "src/viam/components/gantry/gantry.py"
1716
- "src/viam/components/gripper/gripper.py"
1817
- "src/viam/components/input/input.py"

examples/server/v1/components.py

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from viam.components.arm import Arm
2222
from viam.components.audio_in import AudioIn, AudioResponse
23-
from viam.components.audio_input import AudioInput
2423
from viam.components.audio_out import AudioOut
2524
from viam.components.base import Base
2625
from viam.components.board import Board, TickStream
@@ -35,7 +34,6 @@
3534
from viam.components.sensor import Sensor
3635
from viam.components.servo import Servo
3736
from viam.errors import ResourceNotFoundError
38-
from viam.media.audio import Audio, AudioStream
3937
from viam.media.video import CameraMimeType, NamedImage, ViamImage
4038
from viam.operations import run_with_operation
4139
from viam.proto.common import (
@@ -52,8 +50,6 @@
5250
Vector3,
5351
)
5452
from viam.proto.component.arm import JointPositions
55-
from viam.proto.component.audioin import AudioChunk as AudioInChunk
56-
from viam.proto.component.audioinput import AudioChunk, AudioChunkInfo, SampleFormat
5753
from viam.proto.component.encoder import PositionType
5854
from viam.streams import StreamWithIterator
5955
from viam.utils import SensorReading
@@ -111,73 +107,6 @@ async def get_kinematics(self, extra: Optional[Dict[str, Any]] = None, **kwargs)
111107
async def get_geometries(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> List[Geometry]:
112108
return GEOMETRIES
113109

114-
115-
class ExampleAudioInput(AudioInput):
116-
def __init__(self, name: str):
117-
super().__init__(name)
118-
self.latency = timedelta(milliseconds=20)
119-
self.sample_rate = 48_000
120-
self.channel_count = 1
121-
self.step = 0
122-
self.timer = asyncio.get_event_loop().call_later(self.latency.total_seconds(), self.run_task)
123-
124-
def run_task(self):
125-
self.step += 1
126-
self.timer = asyncio.get_event_loop().call_later(self.latency.total_seconds(), self.run_task)
127-
128-
def __del__(self):
129-
self.timer.cancel()
130-
131-
@run_with_operation
132-
async def stream(self, **kwargs) -> AudioStream:
133-
"""Generate and stream a sine wave at 440Hz"""
134-
operation = self.get_operation(kwargs)
135-
136-
length = self.sample_rate * self.latency.total_seconds() # the length of the sample
137-
num_chunks = self.sample_rate / length # the number of chunks needed
138-
angle = math.pi * 2 / (length * num_chunks)
139-
140-
async def read() -> AsyncIterator[Audio]:
141-
while True:
142-
if await operation.is_cancelled():
143-
break
144-
output = bytes()
145-
step = int(self.step % num_chunks) # current location on the sine wave
146-
for i in range(int(length)):
147-
value = float(10) * math.sin(angle * 440 * (float(length * step) + i)) # calculate the value at the current location
148-
output += bytes(struct.pack("f", value))
149-
150-
yield Audio(
151-
AudioChunkInfo(
152-
sample_format=SampleFormat.SAMPLE_FORMAT_FLOAT32_INTERLEAVED,
153-
channels=self.channel_count,
154-
sampling_rate=self.sample_rate,
155-
),
156-
AudioChunk(
157-
data=output,
158-
length=int(length),
159-
),
160-
)
161-
162-
await asyncio.sleep(self.latency.total_seconds())
163-
164-
return StreamWithIterator(read())
165-
166-
async def get_properties(self) -> AudioInput.Properties:
167-
return AudioInput.Properties(
168-
channel_count=self.channel_count,
169-
latency=self.latency,
170-
sample_rate=self.sample_rate,
171-
sample_size=4,
172-
is_big_endian=sys.byteorder != "little",
173-
is_float=True,
174-
is_interleaved=True,
175-
)
176-
177-
async def get_geometries(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> List[Geometry]:
178-
return GEOMETRIES
179-
180-
181110
class ExampleAudioIn(AudioIn):
182111
def __init__(self, name: str):
183112
super().__init__(name)

examples/server/v1/server.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
ExampleAnalog,
1010
ExampleArm,
1111
ExampleAudioIn,
12-
ExampleAudioInput,
1312
ExampleAudioOut,
1413
ExampleBase,
1514
ExampleBoard,
@@ -31,7 +30,6 @@
3130

3231
async def run(host: str, port: int, log_level: int):
3332
my_arm = ExampleArm("arm0")
34-
my_audio_input = ExampleAudioInput("audio_input0")
3533
my_audio_in = ExampleAudioIn("audio_in0")
3634
my_audio_out = ExampleAudioOut("audio_out0")
3735
my_base = ExampleBase("base0")
@@ -80,7 +78,6 @@ async def run(host: str, port: int, log_level: int):
8078
resources=[
8179
my_arm,
8280
my_audio_in,
83-
my_audio_input,
8481
my_audio_out,
8582
my_base,
8683
my_board,

src/viam/components/audio_input/__init__.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/viam/components/audio_input/audio_input.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/viam/components/audio_input/client.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)