Skip to content

Commit c10d596

Browse files
docs(ipc): document audio playback and source options
1 parent 98e2b28 commit c10d596

2 files changed

Lines changed: 60 additions & 6 deletions

File tree

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ audio_df = dataset.get_audio_dataframe()
3838

3939
```python
4040
import asyncio
41-
from open_wearable import OpenWearableIPCClient
41+
from open_wearables import OpenWearableIPCClient
4242

4343

4444
async def main() -> None:
@@ -58,6 +58,27 @@ async def main() -> None:
5858
await stream.close()
5959

6060

61+
asyncio.run(main())
62+
```
63+
64+
## IPC Audio Example
65+
66+
```python
67+
import asyncio
68+
from open_wearables import OpenWearableIPCClient
69+
70+
71+
async def main() -> None:
72+
async with OpenWearableIPCClient("ws://192.168.1.23:8765/ws") as client:
73+
await client.audio.store_sound_file("beep_ok", "beep.wav", codec="wav")
74+
await client.audio.play_sound("beep_ok", volume=1.0, codec="wav")
75+
await client.audio.play_sound(url="https://example.org/alert.wav", volume=0.7)
76+
77+
async with client.audio.stream(volume=0.8) as stream:
78+
stream_bytes = b"...raw chunk bytes..."
79+
await stream.push(stream_bytes)
80+
81+
6182
asyncio.run(main())
6283
```
6384

@@ -72,12 +93,12 @@ asyncio.run(main())
7293

7394
The library is organized into focused layers:
7495

75-
- `open_wearable.schema`: sensor schema types and default schema builders.
76-
- `open_wearable.parsing`: stream parsing, payload parsers, and microphone helpers.
77-
- `open_wearable.data`: high-level dataset API (`SensorDataset`) and sensor accessors.
78-
- `open_wearable.ipc`: asynchronous WebSocket IPC client and protocol models.
96+
- `open_wearables.schema`: sensor schema types and default schema builders.
97+
- `open_wearables.parsing`: stream parsing, payload parsers, and microphone helpers.
98+
- `open_wearables.data`: high-level dataset API (`SensorDataset`) and sensor accessors.
99+
- `open_wearables.ipc`: asynchronous WebSocket IPC client and protocol models.
79100

80-
Legacy flat modules (`open_wearable.scheme`, `open_wearable.parser`, `open_wearable.dataset`) remain available as compatibility facades.
101+
Legacy flat modules (`open_wearables.scheme`, `open_wearables.parser`, `open_wearables.dataset`) remain available as compatibility facades.
81102

82103
## License
83104

docs/api-reference.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,39 @@ Other helpers:
7070
- `wearable.streams.battery_health_status()`
7171
- `wearable.streams.battery_energy_status()`
7272

73+
### Audio Playback
74+
75+
Raw websocket-aligned methods:
76+
77+
- `store_sound(sound_id, audio_base64, codec=None, sample_rate=None, num_channels=None, interleaved=None, buffer_size=None)`
78+
- `play_sound(sound_id=None, url=None, volume=None, codec=None, sample_rate=None, num_channels=None)` (exactly one of `sound_id` or `url`)
79+
- `start_audio_stream(volume=None)`
80+
- `push_audio_stream_chunk(audio_base64)`
81+
- `stop_audio_stream()`
82+
83+
Python-friendly helpers:
84+
85+
- `store_sound_bytes(sound_id, audio_bytes, codec=None, sample_rate=None, num_channels=None, interleaved=None, buffer_size=None)`
86+
- `store_sound_file(sound_id, file_path, codec=None, sample_rate=None, num_channels=None, interleaved=None, buffer_size=None)`
87+
- `push_audio_stream_chunk_bytes(audio_chunk)`
88+
- `push_audio_stream_chunk_file(file_path)`
89+
- `client.audio.store_sound(...)`
90+
- `client.audio.store_sound_file(...)`
91+
- `client.audio.play_sound(...)`
92+
- `client.audio.stream(volume=...)` (context-managed `AudioStreamSession`)
93+
94+
Example:
95+
96+
```python
97+
async with OpenWearableIPCClient("ws://192.168.1.23:8765/ws") as client:
98+
await client.audio.store_sound_file("beep_ok", "beep.wav")
99+
await client.audio.play_sound("beep_ok", volume=1.0)
100+
await client.audio.play_sound(url="https://example.org/alert.wav", volume=0.7)
101+
102+
async with client.audio.stream(volume=0.8) as stream:
103+
await stream.push(chunk_bytes)
104+
```
105+
73106
## `SensorDataset`
74107

75108
High-level API for loading and analyzing a single `.oe` recording.

0 commit comments

Comments
 (0)