requireLiteRtLmWebAudioEncoder function

Future<void> requireLiteRtLmWebAudioEncoder(
  1. LiteRtLmWebRuntime runtime,
  2. String url, {
  3. required String fileName,
})

Throws EmbedderLoadException unless the .litertlm bundle at url has an audio encoder, read from its container header through runtime's readPrefix (a few KB) — D23, the native rule (litertlm_container.dart): ModelInfo claims audio on the 270m and the 440m, and the web has no ModelInfo at all. A header that cannot be read or parsed is a load failure naming fileName, never "no audio".

Implementation

Future<void> requireLiteRtLmWebAudioEncoder(
  LiteRtLmWebRuntime runtime,
  String url, {
  required String fileName,
}) async {
  final types = await _modelTypes(runtime, url, fileName: fileName);
  if (!litertlmHasAudioEncoder(types)) {
    throw EmbedderLoadException(liteRtLmNoAudioEncoderMessage(fileName));
  }
}