Defined the RecordingService and the TranscribingService protocols in the Recording package tracker.
This commit is contained in:
@@ -41,6 +41,8 @@ Attendi/
|
||||
│ ├── RecordingView.swift
|
||||
│ ├── RecordingViewModel.swift
|
||||
│ ├── RecordingButtonStyle.swift
|
||||
│ ├── RecordingService.swift
|
||||
│ ├── TranscribingService.swift
|
||||
│ └── Images.xcassets # Record, pause, and send icons
|
||||
└── Tests/
|
||||
├── Recording/
|
||||
@@ -81,6 +83,21 @@ text content transition.
|
||||
background, shrinks while pressed, and dims while disabled. The label and its padding scale with Dynamic Type
|
||||
via `@ScaledMetric`, and an `invertStyle` flag controls whether the label's color scheme is inverted for contrast.
|
||||
|
||||
### Services
|
||||
|
||||
The actual recording work is abstracted behind two protocols, injected into `RecordingView` at initialization and
|
||||
attached to its view model:
|
||||
|
||||
- **`RecordingService`** — captures the audio from a microphone, with throwing async `start`, `pause`, `resume`, and
|
||||
`stop` methods; `stop` returns the captured audio.
|
||||
- **`TranscribingService`** — transcribes the captured audio into text through a throwing async `transcribe` method;
|
||||
the view model stores the result once processing finishes.
|
||||
|
||||
The default `SimulatedRecordingService` and `SimulatedTranscribingService` fake the work (the latter with a two-second
|
||||
delay and a dummy transcription); the unit tests inject fast mocks, and real backends can be plugged in the same way
|
||||
without touching the feature's state machine. When either service fails, the view model falls back to the
|
||||
not-recording state.
|
||||
|
||||
## Testing
|
||||
|
||||
The view model is covered by Swift Testing suites in `RecordingViewModelTests.swift`, grouped with nested `@Suite`
|
||||
|
||||
Reference in New Issue
Block a user