Wraps speech output with OpenTelemetry spans, tracking synthesis, playback, and errors.
// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import type { Span } from '@opentelemetry/api'
import type { SpeechAudio, SpeechOutput, TurnRef } from '@proj-airi/core-agent'
import { errorMessageFrom } from '@moeru/std'
import { SpanStatusCode } from '@opentelemetry/api'
import { IOAttributes, IOSpanNames, IOSubsystems } from '@proj-airi/stage-shared'
import { startSpan } from './use-io-tracer'
/** A traced output for one response. The owner calls `end` once when that response closes. */
export interface SpeechOutputTrace {
readonly output: SpeechOutput
end: () => void
}
function failSpan(span: Span, cause: unknown) {
span.setStatus({ code: SpanStatusCode.ERROR, messag
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key