2026-07-03 23:57:49 +02:00
|
|
|
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.
|
2026-07-04 12:03:19 +02:00
|
|
|
struct DummyTranscribing: Transcribing {
|
2026-07-03 23:57:49 +02:00
|
|
|
|
|
|
|
|
// MARK: Methods
|
|
|
|
|
|
|
|
|
|
/// Simulates the transcription of the given recorded audio with a two-second delay.
|
|
|
|
|
///
|
2026-07-04 12:03:19 +02:00
|
|
|
/// - Parameters:
|
2026-07-04 15:06:55 +02:00
|
|
|
/// - audio: The location of the recorded audio file to transcribe.
|
2026-07-04 12:03:19 +02:00
|
|
|
/// - locale: The locale of the spoken language to transcribe.
|
2026-07-03 23:57:49 +02:00
|
|
|
/// - Returns: A dummy transcription.
|
2026-07-04 12:03:19 +02:00
|
|
|
func callAsFunction(
|
2026-07-04 15:06:55 +02:00
|
|
|
_ audio: URL,
|
2026-07-04 12:03:19 +02:00
|
|
|
locale: Locale
|
|
|
|
|
) async throws -> Transcription {
|
2026-07-03 23:57:49 +02:00
|
|
|
try await Task.sleep(for: Constant.Delay.transcribing)
|
|
|
|
|
|
2026-07-04 12:03:19 +02:00
|
|
|
return .init(text: Constant.Text.transcription)
|
2026-07-03 23:57:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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."
|
|
|
|
|
}
|
|
|
|
|
}
|