19 lines
1.4 KiB
Markdown
19 lines
1.4 KiB
Markdown
# Hermes Watch PTT Foundation
|
|
|
|
These files are intended to be added to a standalone watchOS SwiftUI app target:
|
|
|
|
- `AudioCaptureManager.swift`: captures microphone audio with `AVAudioEngine`, converts it to 16 kHz, 16-bit, mono PCM, and emits raw `Data` chunks.
|
|
- `AudioStreamManager.swift`: opens a `URLSessionWebSocketTask`, sends binary PCM chunks, receives binary response audio, and plays either complete WAV blobs or raw 16 kHz PCM chunks.
|
|
- `ContentView.swift`: minimal push-to-talk UI using `DragGesture(minimumDistance: 0)` for press/release.
|
|
- `InfoPlistAdditions.xml`: exact plist entries for microphone, LAN access, and background audio.
|
|
|
|
The referenced ESP32 demo posts a complete WAV file to `http://192.168.68.126:8642/api/esp32/voice` with 16 kHz, 16-bit, mono PCM and receives WAV audio back. The watch implementation here follows your requested WebSocket model: it streams raw PCM chunks while the button is held, sends simple `{"type":"start"}` and `{"type":"stop"}` text control messages, and accepts either WAV or raw PCM binary responses.
|
|
|
|
Update the endpoint in `ContentView.init()`:
|
|
|
|
```swift
|
|
AudioStreamManager(endpoint: URL(string: "ws://YOUR_LOCAL_IP:PORT/stream")!)
|
|
```
|
|
|
|
If your Hermes WebSocket endpoint expects authentication headers, create a `URLRequest`, set the headers, and pass that request into `session.webSocketTask(with:)` in `AudioStreamManager.connect()`.
|