Made the transcribing callable and per-call for the transcribing protocol in the Recording package target.

This commit is contained in:
2026-07-04 12:03:19 +02:00
parent 8b46c4e7d1
commit 68c070948e
9 changed files with 60 additions and 57 deletions
@@ -6,6 +6,8 @@ import Foundation
/// state machine for example, with a real microphone backend in the app, or with a mock in unit tests.
public protocol RecordingService: Sendable {
// MARK: Methods
/// Starts a new audio recording from the microphone.
func start() async throws
@@ -4,12 +4,19 @@ import Foundation
///
/// ``RecordingView`` attaches the service to its model at initialization, so the transcription can be swapped without touching the feature's
/// state machine for example, with a real transcription backend in the app, or with a fast mock in unit tests.
public protocol TranscribingService: Sendable {
public protocol Transcribing: Sendable {
/// Transcribes the given recorded audio into text.
// MARK: Methods
/// Transcribes the given recorded audio into text, letting the service be called directly as a function.
///
/// - Parameter audio: The recorded audio to transcribe.
/// - Parameters:
/// - audio: The recorded audio to transcribe.
/// - locale: The locale of the spoken language to transcribe.
/// - Returns: The transcription of the recorded audio.
func transcribe(_ audio: Data) async throws -> String
func callAsFunction(
_ audio: Data,
locale: Locale
) async throws -> Transcription
}