@ai-ecoverse/pi-audio 1.16.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ import { type AudioChunk, type AudioSource } from './audio.ts';
2
+ import type { AudioOut, Cue } from './soundscape.ts';
3
+ import type { EchoRecommendation } from './turns.ts';
4
+ export type EchoMode = 'browser' | 'wasm' | 'none';
5
+ export interface EchoCanceller {
6
+ cancel(mic: AudioChunk, reference: AudioChunk): AudioChunk;
7
+ }
8
+ export interface EchoControl {
9
+ mode: EchoMode;
10
+ reference: AudioSource;
11
+ canceller?: EchoCanceller;
12
+ }
13
+ export interface EchoReport {
14
+ delayMs: number;
15
+ cancellationDb: number;
16
+ residualDb: number;
17
+ recommendation: EchoRecommendation;
18
+ }
19
+ export interface MicOpen {
20
+ echoCancellation: boolean | 'all';
21
+ playback: 'webaudio' | 'rtc-loopback';
22
+ }
23
+ export declare function micOpen(mode: EchoMode, useAll: boolean): MicOpen;
24
+ export declare function echoRuntime(hasMediaDevices: boolean): 'node' | 'browser';
25
+ export declare function assertNodeEcho(mode: EchoMode, runtime: 'node' | 'browser'): void;
26
+ export declare function chooseCapture(tried: EchoMode, report: EchoReport): EchoMode;
27
+ export declare function openEchoMic(control: EchoControl, mic: AudioSource): AudioSource;
28
+ export declare function measureEcho(reference: Float32Array, mic: Float32Array, sampleRate: number): EchoReport;
29
+ export declare function calibrateEcho(out: AudioOut, mic: AudioSource, probe: Cue, durationMs: number, signal: AbortSignal): Promise<EchoReport>;
@@ -0,0 +1,13 @@
1
+ import type { JsonObject } from '@earendil-works/pi-ai';
2
+ import type { AudioFormat } from '../audio.ts';
3
+ import type { RealtimeEvent } from '../realtime.ts';
4
+ export interface TalkTurn {
5
+ vad: boolean;
6
+ dropAudio: boolean;
7
+ lastInterruptId: number;
8
+ }
9
+ export interface Ingested {
10
+ events: RealtimeEvent[];
11
+ replies: JsonObject[];
12
+ }
13
+ export declare function ingestElevenLabs(turn: TalkTurn, message: Record<string, unknown>, format: AudioFormat): Ingested;
@@ -0,0 +1,9 @@
1
+ import type { RealtimeModel } from '../models.ts';
2
+ import type { ElevenLabsOptions } from './session.ts';
3
+ export declare const elevenLabsAgent: RealtimeModel<'elevenlabs-agents'>;
4
+ export declare function registerElevenLabsAgents(options?: ElevenLabsOptions): () => void;
5
+ export type { CustomLlm, HostedAgent, HostedAgentSpec, HostedCache } from '../hosted-agent.ts';
6
+ export { hashHostedSpec, memoryHostedCache } from '../hosted-agent.ts';
7
+ export type { ProvisionOptions } from './provision.ts';
8
+ export { agentBody, httpsOrigin, provisionAgent } from './provision.ts';
9
+ export type { ElevenLabsOptions, VoiceWireFactory } from './session.ts';
@@ -0,0 +1,11 @@
1
+ import type { JsonObject, ProviderRequestOptions } from '@earendil-works/pi-ai';
2
+ import { type HostedAgent, type HostedAgentSpec, type HostedCache } from '../hosted-agent.ts';
3
+ import type { RealtimeModel } from '../models.ts';
4
+ export interface ProvisionOptions extends ProviderRequestOptions {
5
+ agentId?: string;
6
+ now?: () => number;
7
+ cache?: HostedCache;
8
+ }
9
+ export declare function httpsOrigin(baseUrl: string): string;
10
+ export declare function agentBody(spec: HostedAgentSpec): JsonObject;
11
+ export declare function provisionAgent(model: RealtimeModel<string>, spec: HostedAgentSpec, options?: ProvisionOptions): Promise<HostedAgent>;
@@ -0,0 +1,16 @@
1
+ import type { HostedAgentSpec, HostedCache } from '../hosted-agent.ts';
2
+ import type { RealtimeModel } from '../models.ts';
3
+ import { type VoiceSocketConstructor, type VoiceWire, type VoiceWireTarget } from '../openai-realtime/socket.ts';
4
+ import type { RealtimeContext, RealtimeOptions, RealtimeSession } from '../realtime.ts';
5
+ export type VoiceWireFactory = (target: VoiceWireTarget) => VoiceWire;
6
+ export interface ElevenLabsOptions {
7
+ wire?: VoiceWireFactory;
8
+ socket?: VoiceSocketConstructor;
9
+ cache?: HostedCache;
10
+ agentId?: string;
11
+ now?: () => number;
12
+ firstMessage?: string;
13
+ }
14
+ export declare function talkerLlm(model: RealtimeModel<string>): string;
15
+ export declare function specFromContext(model: RealtimeModel<string>, context: RealtimeContext): HostedAgentSpec;
16
+ export declare function connectElevenLabs(model: RealtimeModel<string>, context: RealtimeContext, options: RealtimeOptions | undefined, settings?: ElevenLabsOptions): Promise<RealtimeSession>;
@@ -0,0 +1,23 @@
1
+ import type { Model, Tool } from '@earendil-works/pi-ai';
2
+ export type CustomLlm = Pick<Model<'openai-completions' | 'openai-responses'>, 'id' | 'api' | 'baseUrl' | 'headers'>;
3
+ export interface HostedAgentSpec {
4
+ name: string;
5
+ instructions: string;
6
+ tools: Tool[];
7
+ voice: string;
8
+ llm: string | CustomLlm;
9
+ firstMessage?: string;
10
+ clientToolTimeoutMs?: number;
11
+ }
12
+ export interface HostedAgent {
13
+ agentId: string;
14
+ specHash: string;
15
+ publishedAt: number;
16
+ }
17
+ export interface HostedCache {
18
+ get(key: string): HostedAgent | undefined;
19
+ set(key: string, agent: HostedAgent): void;
20
+ }
21
+ export declare function memoryHostedCache(): HostedCache;
22
+ export declare function hostedCacheKey(provider: string, name: string): string;
23
+ export declare function hashHostedSpec(spec: HostedAgentSpec): string;
@@ -4,6 +4,8 @@ export { blankUsage } from './blank-usage.ts';
4
4
  export type { CaptionHistoryEntry } from './captions.ts';
5
5
  export { captionsFromHistory } from './captions.ts';
6
6
  export { convertAudio, convertAudioSource, decodeAudioBase64, encodeAudioBase64, } from './convert.ts';
7
+ export type { EchoCanceller, EchoControl, EchoMode, EchoReport, MicOpen } from './echo.ts';
8
+ export { assertNodeEcho, calibrateEcho, chooseCapture, echoRuntime, measureEcho, micOpen, openEchoMic, } from './echo.ts';
7
9
  export { VoiceRequestError } from './errors.ts';
8
10
  export type { Delivery, DeliverySupport, KnownRealtimeApi, KnownSpeechApi, KnownTranscriptionApi, RealtimeApi, RealtimeModel, SpeechApi, SpeechModel, TranscriptionApi, TranscriptionModel, VoiceInfo, VoiceModel, VoiceModelType, } from './models.ts';
9
11
  export { getVoiceModel, listVoiceModels, registerVoiceModel, } from './models.ts';
@@ -1,5 +1,6 @@
1
1
  import type { AssistantMessageEvent, JsonObject, ProviderRequestOptions, ToolCall, UserMessage } from '@earendil-works/pi-ai';
2
2
  import { type AudioSink, type AudioSource } from './audio.ts';
3
+ import { type EchoControl } from './echo.ts';
3
4
  import type { SpeechModel, TranscriptionModel } from './models.ts';
4
5
  import { type AudioOut, type Soundscape } from './soundscape.ts';
5
6
  import type { SpeechEvent, SpeechInput } from './speech.ts';
@@ -30,6 +31,7 @@ export interface VoiceTurnOptions {
30
31
  announce?: (call: ToolCall) => string | undefined;
31
32
  bargeIn?: BargeIn;
32
33
  echoRecommendation?: EchoRecommendation;
34
+ echo?: EchoControl;
33
35
  soundscape?: Soundscape;
34
36
  }
35
37
  export interface VoiceModels {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/pi-audio",
3
- "version": "1.16.0",
3
+ "version": "1.18.0",
4
4
  "description": "Voice bindings for pi: speech-to-text, text-to-speech and realtime speech for pi-coding-agent plugins and slicc-agent",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -61,6 +61,10 @@
61
61
  "./gemini-live": {
62
62
  "types": "./dist/types/gemini-live/index.d.ts",
63
63
  "default": "./dist/gemini-live/index.js"
64
+ },
65
+ "./elevenlabs-agents": {
66
+ "types": "./dist/types/elevenlabs-agents/index.d.ts",
67
+ "default": "./dist/elevenlabs-agents/index.js"
64
68
  }
65
69
  },
66
70
  "files": [