AudioLiveTokenPolicy constructor

AudioLiveTokenPolicy(
  1. Map<String, int> markers,
  2. int vocabSize
)

Implementation

AudioLiveTokenPolicy(Map<String, int> markers, this.vocabSize)
  : markers = Map.unmodifiable(markers) {
  for (final name in names) {
    final id = markers[name];
    if (id == null || id < 0 || id >= vocabSize) {
      throw FormatException('LiveASR tokenizer lacks $name');
    }
  }
  if (names.map((name) => markers[name]).toSet().length != names.length) {
    throw const FormatException('LiveASR markers must have distinct IDs');
  }
}