ProsodyClient
Constructor and method reference
Constructor
import { ProsodyClient } from '@prosodyai/sdk';
const prosody = new ProsodyClient({
apiKey: process.env.PROSODY_API_KEY!,
});new ProsodyClient(config: ProsodyClientConfig | string)| Option | Type | Default |
|---|---|---|
apiKey | string | required |
baseUrl | string | https://api.prosodyai.app |
timeoutMs | number | 30000 |
retry | Partial<RetryConfig> | 2 retries, 500 ms initial delay |
headers | Record<string, string> | {} |
debug | boolean | false |
onRequest | (url, init) => void | None |
onResponse | (url, response) => void | None |
A string config is shorthand for the API key:
const prosody = new ProsodyClient(process.env.PROSODY_API_KEY!);transcribe
transcribe(
audio: string | Buffer,
options?: TranscribeOptions,
signal?: AbortSignal,
): Promise<Transcription>audio accepts a local path, an http(s) URL the API can fetch from a public address, or a Node.js Buffer.
| Option | Type | Default |
|---|---|---|
language | string | en |
sessionId | string | generated |
diarize | boolean | true |
prosody | boolean | true |
const result = await prosody.transcribe('./call.wav');stream.session
stream.session(options?: LiveSessionStartOptions & {
onUpdate?, onError?, onClose?, onEvent?, WebSocketImpl?
}): LiveSessionCreates a stateful live session over WS /v1/stream/realtime that owns the
WebSocket and maintains a Conversation.
const session = prosody.stream.session({
encoding: 'pcm16',
sampleRate: 16_000,
onUpdate: (current) => render(current.snapshot()),
});stream.connect
stream.connect(
handlers?: ProsodyRealtimeHandlers,
options?: {
sessionId?, encoding?, sampleRate?, container?, analysisMode?, source?,
sourceOffsetMs?, chunkSeconds?, capabilities?, WebSocketImpl?
},
): ProsodyRealtimeStreamCreates the low-level live transport. Handlers receive parsed wire events
and VoiceFrame objects (onVoiceFrame).
speakers
speakers.list(
limit?: number,
signal?: AbortSignal,
): Promise<SpeakerDirectoryResult>
speakers.previewEnrollment(
audio: string | Buffer,
signal?: AbortSignal,
): Promise<VoiceEnrollmentPreview>
speakers.confirmEnrollment(
audio: string | Buffer,
previewSha256: string,
mappings: VoiceEnrollmentMapping[],
signal?: AbortSignal,
): Promise<VoiceEnrollmentResult>previewEnrollment returns diarized lanes without writing identity.
confirmEnrollment persists the supplied lane-to-speaker mappings.
memory.recall
memory.recall.post(
personId: string,
topK?: number,
signal?: AbortSignal,
): Promise<RecallResult>Returns a saved person's top-K significant moments, recency-ranked, each with the measured facts that selected it.
Measurement helpers
import { measurementSeries, voiceFrames } from '@prosodyai/sdk';
voiceFrames(result: AnalysisResult): ProsodyTimelinePoint[]
measurementSeries(result: AnalysisResult, path: MeasurementPath): {
start_ms: number; end_ms: number; speaker_id?: string; value: number;
}[]voiceFrames returns the measured frames of a raw prosody.analyze() result.
measurementSeries reads one quantity across the call by its family path,
such as 'intonation.pitch' or 'stress.loudness', skipping frames where it
was not measurable.
feedback
submitCorrection(
options: FeedbackCorrectionOptions,
signal?: AbortSignal,
): Promise<{ status: string }>
submitSessionOutcome(
options: SessionOutcomeOptions,
signal?: AbortSignal,
): Promise<{ status: string }>