Implemented the AssetPreinstalling service in the Recording package target.
This commit is contained in:
@@ -6,10 +6,15 @@ import Speech
|
||||
///
|
||||
/// The service runs the given recorded audio file through a `SpeechAnalyzer` with a `SpeechTranscriber` module, joining the finalized
|
||||
/// results into the returned transcription. The transcription happens in the locale given at each call — or rather in the closest equivalent
|
||||
/// the transcriber supports. The speech model assets for that locale are downloaded and installed on first use; every transcription after
|
||||
/// that happens entirely offline.
|
||||
/// the transcriber supports. Any speech model assets still missing for that locale are installed first through ``AssetPreinstalling``;
|
||||
/// every transcription after that happens entirely offline.
|
||||
public struct AudioTranscribing: Transcribing {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The preinstalling service that installs any speech model assets still missing when a transcription starts.
|
||||
private let preinstaller = AssetPreinstalling()
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Creates an audio transcribing service.
|
||||
@@ -46,9 +51,7 @@ public struct AudioTranscribing: Transcribing {
|
||||
)
|
||||
|
||||
do {
|
||||
if let request = try await AssetInventory.assetInstallationRequest(supporting: [transcriber]) {
|
||||
try await request.downloadAndInstall()
|
||||
}
|
||||
try await preinstaller.install(for: locale)
|
||||
} catch {
|
||||
logger.error("The speech model assets for the \"\(locale.identifier, privacy: .public)\" locale failed to install: \(String(describing: error), privacy: .public)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user