AssetInventory
Manages the assets that are necessary for transcription or other analyses.
Declaration
final class AssetInventoryOverview
Before using the SpeechAnalyzer class, you must install assets required by the modules you plan to use. These assets are machine-learning models downloaded from Apple’s servers and managed by the system. Once you download, install, or use an asset, the system retains and updates it automatically, and shares it with other apps. The system makes a certain number of locale-specific asset reservations available to your app to limit storage space and network usage.
Your app does not work with assets directly. Instead, your app configures module objects. The system uses the modules’ configuration to determine what assets are relevant.
Install assets
Installing an asset is a four-step process:
Create analyzer modules in the configurations that you wish to use. These modules can be discarded when no longer needed; the system installs assets using the modules’ configuration, not their object identity.
Assign your app’s asset reservations to those locales. The class does this automatically if needed, but you can also call reserve(locale:) to do this manually. This step is only necessary for modules with locale-specific assets; that is, modules conforming to LocaleDependentSpeechModule. You can skip this step for other modules.
Start downloading the required assets for the modules’ configuration. Call assetInstallationRequest(supporting:) to obtain an instance of AssetInstallationRequest and call its downloadAndInstall() method.
Wait for the download to finish. Note that the download may finish immediately; the assets may have already been downloaded if the assets were preinstalled on the system, another app already downloaded them, or a previous module configuration used the same assets.
Once assets are downloaded, they persist between app launches and are shared between apps. The system may unsubscribe your app from assets that haven’t been used in a while.
Manage assets
When your app no longer needs assets for a particular locale, call release(reservedLocale:) to free up that reservation. The system will remove the assets at a later time.