aic_tyto_observer
Audio quality analysis for Pipecat backed by the ai-coustics Tyto model.
- Classes:
AICAudioQualityScores: Audio quality scores for one window of user audio. AICAudioQualitySummary: Summary of the audio quality windows of one call. AICTytoObserver: Scores the user’s audio during a call and summarizes the
scores when the call ends.
- class pipecat.observers.aic_tyto_observer.AICAudioQualityScores(*, risk_score: float, noise: float, speaker_reverb: float, speaker_loudness: float, interfering_speech: float, packet_loss: float, codec_degradation: float)[source]
Bases:
BaseModelAudio quality scores for one window of user audio.
All scores are in the range 0.0 to 1.0. A higher value means more problematic audio.
- Parameters:
risk_score – Likelihood that downstream models (STT, VAD, turn-taking, speech-to-speech) fail on this audio.
noise – Ambient or environmental noise.
speaker_reverb – Speaker distance and reverberation.
speaker_loudness – Level of the main speaker. A neutral level, not a degradation.
interfering_speech – Speech from other speakers, live or from a device.
packet_loss – Dropouts or discontinuities in the stream.
codec_degradation – Artifacts from lossy speech codecs.
- class pipecat.observers.aic_tyto_observer.AICAudioQualitySummary(*, windows: int, mean: AICAudioQualityScores, p95: AICAudioQualityScores, max: AICAudioQualityScores, degraded_threshold: float, degraded_fraction: float, dominant_dimension: str)[source]
Bases:
BaseModelSummary of the audio quality windows of one call.
- Parameters:
windows – Number of analyzed windows.
mean – Mean of each score over all windows.
p95 – 95th percentile of each score over all windows.
max – Maximum of each score over all windows.
degraded_threshold –
risk_scorevalue at or above which a window counts as degraded.degraded_fraction – Fraction of windows that are degraded.
dominant_dimension – Name of the score with the highest mean, without
risk_scoreandspeaker_loudness. It shows the largest degradation, not the cause of the risk score.
- class pipecat.observers.aic_tyto_observer.AICTytoObserver(*, license_key: str, model_id: str | None = 'tyto-1.2-l-16khz', model_path: Path | None = None, model_download_dir: Path | None = None, degraded_threshold: float = 0.3, audio_filter: AICFilter | None = None, **kwargs)[source]
Bases:
BaseObserverScores the quality of the user’s audio with the ai-coustics Tyto model.
The observer buffers the user’s audio and analyzes the latest 5 s window in a background thread after every 5 s of received audio. Each result goes to the
on_analysis_resultevent. When the call ends, the observer combines the results into one summary and gives it to theon_call_summaryevent.Tyto must score the audio before enhancement. When
AICFilteris the transport’saudio_in_filter, give the same filter asaudio_filter. The filter then feeds each block to the analysis before it enhances the block. Without a filter, the observer analyzes theInputAudioRawFrameaudio that the input transport pushes.Event handlers available:
on_analysis_result: Called with an
AICAudioQualityScoresand the seconds of user audio received when the window was analyzed.on_call_summary: Called with an
AICAudioQualitySummarywhen the call ends. Not called when no window was analyzed.
Example:
aic_filter = AICFilter(license_key=key, model_id="quail-vf-2.3-l-16khz") tyto = AICTytoObserver(license_key=key, audio_filter=aic_filter) @tyto.event_handler("on_call_summary") async def on_call_summary(observer, summary): logger.info(f"Mean risk score: {summary.mean.risk_score}") worker = PipelineWorker(pipeline, observers=[tyto])
- __init__(*, license_key: str, model_id: str | None = 'tyto-1.2-l-16khz', model_path: Path | None = None, model_download_dir: Path | None = None, degraded_threshold: float = 0.3, audio_filter: AICFilter | None = None, **kwargs)[source]
Initialize the Tyto observer.
- Parameters:
license_key – ai-coustics SDK license key.
model_id – Tyto model identifier. Defaults to
"tyto-1.2-l-16khz". Ignored ifmodel_pathis set.model_path – Optional path to a local
.aicmodelfile.model_download_dir – Directory for downloaded models. Defaults to
~/.cache/pipecat/aic-models.degraded_threshold –
risk_scorevalue at or above which the summary counts a window as degraded. Calibrate it against the failures that you see in your application.audio_filter – The transport’s
AICFilter. If set, the filter feeds the analysis with the audio before enhancement.**kwargs – Additional arguments passed to parent class.
- Raises:
ValueError – If neither
model_idnormodel_pathis set, or ifdegraded_thresholdis not between 0.0 and 1.0.
- async setup(task_manager: BaseTaskManager)[source]
Load the Tyto model and start a new analysis session.
A failure to load the model is logged, and the call goes on without analysis.
- Parameters:
task_manager – The task manager that runs the analysis tasks.
- async on_push_frame(data: FramePushed)[source]
Buffer the user’s audio and send the summary when the call ends.
- Parameters:
data – The event data containing details about the frame transfer.