Made the transcribing callable and per-call for the transcribing protocol in the Recording package target.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import Foundation
|
||||
|
||||
/// The transcribing service used for development, which simulates the transcription work.
|
||||
///
|
||||
/// The service is internal on purpose: it only backs the feature's previews and the default values of its model, and is not part of the
|
||||
/// package's public interface.
|
||||
struct DummyTranscribing: Transcribing {
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
/// Simulates the transcription of the given recorded audio with a two-second delay.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - audio: The recorded audio to transcribe.
|
||||
/// - locale: The locale of the spoken language to transcribe.
|
||||
/// - Returns: A dummy transcription.
|
||||
func callAsFunction(
|
||||
_ audio: Data,
|
||||
locale: Locale
|
||||
) async throws -> Transcription {
|
||||
try await Task.sleep(for: Constant.Delay.transcribing)
|
||||
|
||||
return .init(text: Constant.Text.transcription)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// The constant values used across the transcribing services.
|
||||
private enum Constant {
|
||||
/// The delay constants.
|
||||
enum Delay {
|
||||
/// The duration of the simulated transcription work.
|
||||
static let transcribing: Duration = .seconds(2)
|
||||
}
|
||||
|
||||
/// The text constants.
|
||||
enum Text {
|
||||
/// The dummy transcription of a recorded audio.
|
||||
static let transcription = "This is a dummy transcription of the recorded audio."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user