pipecat.limit module¶
Functions to limit the output of a Pipecat pipeline.
-
pipecat.limit.
count
(source, count, name=None)¶ Limits the number of records returned from a source.
Examples
Produce seven records at one-second intervals:
>>> pipe = pipecat.device.clock.metronome() >>> pipe = pipecat.limit.count(pipe, count=7) >>> for record in pipe: ... print record
Parameters: - source (Record generator, required)
- count (int, required) – The number of records that will be returned from source.
- name (string, optional.) – Optional name for this Record generator to use in log output. Defaults to the function name.
-
pipecat.limit.
duration
(source, duration, timeout=<Quantity(0.1, 'second')>, name=None)¶ Return records from a source until a fixed time duration has expired.
Examples
Produce records at one-second intervals for three minutes:
>>> pipe = pipecat.device.clock.metronome() >>> pipe = pipecat.limit.duration(pipe, pipecat.quantity(3, pipecat.units.minutes)) >>> for record in pipe: ... print record
Parameters: - source (Record generator, required)
- duration (time quantity, required) – Maximum amount of time that records will be returned from source.
- timeout (time quantity, optional.) – Limits the amount of time to block while waiting for output from source. This affects the accuracy of when the function exits.
- name (string, optional.) – Optional name for this Record generator to use in log output. Defaults to the function name.
-
pipecat.limit.
timeout
(source, timeout, initial=<Quantity(1, 'hour')>, name=None)¶ Return records from another source until they stop arriving.
Parameters: - source (Record generator, required)
- timeout (time quantity, required) – Maximum time to wait for the next record before exiting.
- initial (time quantity, optional) – Maximum time to wait for the first record.
- name (string, optional.) – Optional name for this Record generator to use in log output. Defaults to the function name.
-
pipecat.limit.
until
(source, key, value, name=None)¶ Return records from another source until a record occurs with a specific key and value.
Examples
Print output from a battery charger until its mode changes to “finished”:
>>> pipe = <battery charger pipeline> >>> pipe = pipecat.limit.until(pipe, "mode", "finished") >>> for record in pipe: ... print record
Parameters: - source (Record generator, required)
- key (Record key, required)
- value (anything, required)
- name (string, optional.) – Optional name for this Record generator to use in log output. Defaults to the function name.