class

CrystalAudio::Transcription::Pipeline

Inherits Reference < Object

Constants

CLAUDE_API_URL = "https://api.anthropic.com/v1/messages"
CODE_SYSTEM_PROMPT = " You are a technical dictation assistant. The user is dictating code,\n technical documentation, or developer notes. Your job is to:\n - Convert spoken programming constructs to correct syntax\n (e.g., \"def foo open paren bar close paren\" → \"def foo(bar)\")\n - Format code blocks with appropriate fencing (```language)\n - Fix speech-to-text errors in technical terms\n - Preserve technical precision — do not paraphrase technical statements\n - For prose sections: clean up punctuation and remove fillers\n Output only the cleaned text/code with no commentary."
DICTATION_MODEL = "claude-haiku-4-5-20251001"

Model choices: balance speed vs quality per mode

DICTATION_SYSTEM_PROMPT = " You are a dictation cleanup assistant. The user has spoken text and you\n are receiving the raw speech-to-text output. Your job is to:\n - Fix obvious transcription errors (e.g., homophones used incorrectly)\n - Add correct punctuation and capitalization\n - Remove filler words (um, uh, like, you know) unless they seem intentional\n - Preserve paragraph breaks where the speaker paused meaningfully\n - Do NOT add content, elaborate, or change the meaning\n Output only the cleaned text with no commentary or preamble."
MEETING_MODEL = "claude-opus-4-6"
MEETING_SYSTEM_PROMPT = " You are a meeting notes assistant. You will receive a raw transcript\n of a meeting. Produce structured meeting notes with these sections:\n\n ## Summary\n 2-3 sentence overview of what was discussed.\n\n ## Key Discussion Points\n Bullet points of the main topics, in order of discussion.\n\n ## Decisions Made\n Bullet list of decisions reached. Write \"None recorded.\" if none.\n\n ## Action Items\n Each action item: \"- [Owner if known] Action (by deadline if mentioned)\"\n\n ## Open Questions\n Questions raised but not resolved.\n\n Rules:\n - Do not invent details not present in the transcript\n - Note unclear sections with [unclear]\n - Attribute to [SPEAKER CHANGE] markers if present"

Constructors

new(mode : PipelineMode = PipelineMode::Dictation, api_key : String = ENV["ANTHROPIC_API_KEY"]? || "", max_tokens : Int32 = 2048)
Source

Instance methods

api_key
Source
api_key=(api_key : String)
Source
format(segments : Array(Segment)) : String

Format an array of whisper segments into polished output. For dictation: call this per utterance (low latency). For meetings: call this once on the full transcript.

Source
format(text : String) : String

Convenience: format raw text (already joined)

Source
max_tokens
Source
max_tokens=(max_tokens : Int32)
Source
mode
Source
mode=(mode : PipelineMode)
Source
system_prompt
Source
system_prompt=(system_prompt : String | Nil)
Source