Speech Request Handler (src/speech.ts)

aimock · src/speech.ts · typescript · MIT
voice, ai, integration, testing, fw:node

Processes incoming speech generation requests, applies policy decisions, optional chaos testing, records fixtures, and streams audio or error responses. Reuse for mocking or proxying TTS APIs.

// Source: https://github.com/CopilotKit/aimock | License: MIT | Copyright 2025 CopilotKit
// Provided via justclaw.it.com; keep this notice with the code.
import { renderError } from "./response/errors.js";
import { resolveRequestDecisions, strictOverrideField } from "./response/policy.js";
import type * as http from "node:http";
import type { ChatCompletionRequest, Fixture, HandlerDefaults } from "./types.js";
import {
  isAudioResponse,
  isErrorResponse,
  isJsonObject,
  flattenHeaders,
  getTestId,
  FORMAT_TO_CONTENT_TYPE,
  resolveResponse,
  getContext,
  strictNoMatchMessage,
  strictNoMatchLogLine,
} from "./helpers.js";
import { matchFixtureDiagnostic } from "./router.js";
import { writeErrorResponse } from "./sse-writer.js";
import type { Journal } from "./journal.js";
import 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key