addProjected method

Future<void> addProjected(
  1. Float32List rows
)

Implementation

Future<void> addProjected(Float32List rows) async {
  _open();
  final pending = _pending;
  if (pending == null) throw StateError('No conversation turn is active');
  final h = model.config.hiddenSize;
  if (rows.length % h != 0 || rows.any((v) => !v.isFinite)) {
    throw ArgumentError('Expected finite projected audio rows');
  }
  final count = rows.length ~/ h;
  _capacity(pending.length + count + _assistant.length);
  if (count == 0) return;
  final added = [
    for (var i = 0; i < count; i++)
      _Slot(
        _id('<|audio|>'),
        Float32List.fromList(rows.sublist(i * h, (i + 1) * h)),
      ),
  ];
  _busy = true;
  try {
    await _forward(added, logits: false);
    pending.addAll(added);
    _rows += count;
  } catch (_) {
    _pending = null;
    rethrow;
  } finally {
    _busy = false;
  }
}