Validates base64 audio strings and defines speech parameter constants for dictation services.
// Source: https://github.com/stablyai/orca | License: MIT | Copyright 2026 Lovecast Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from 'zod'
import { OptionalString, requiredString } from './rpc-param-primitives'
export const AUDIO_BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/
export const DICTATION_SAMPLE_RATE = 16_000
export const PCM_BYTES_PER_SAMPLE = 2
export const MAX_DICTATION_AUDIO_SECONDS = 5
export const MAX_DICTATION_AUDIO_CHUNK_BYTES =
DICTATION_SAMPLE_RATE * PCM_BYTES_PER_SAMPLE * MAX_DICTATION_AUDIO_SECONDS
export const MAX_DICTATION_AUDIO_CHUNK_BASE64_LENGTH =
Math.ceil(MAX_DICTATION_AUDIO_CHUNK_BYTES / 3) * 4
export function isValidAudioBase64(value: string): boolean {
return value.length % 4 !== 1 && AUDIO_BASE64_PATTERN.test(v
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key