cleanVoiceTranscript (utils/voice-transcript.ts)

agav · source/utils/voice-transcript.ts · typescript · Apache-2.0
voice

Removes recognizer annotations and special tokens from voice transcripts to prepare text for downstream natural language processing tasks.

// Source: https://github.com/prapaa-ai/agav | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/** Remove only known recognizer annotations, never arbitrary bracketed/code text. */
export function cleanVoiceTranscript(text: string): string {
  const annotation = "(?:blank[ _-]*audio|no[ _-]*speech|silence|silent|music|background[ _-]*music|applause|clapping|laughter|laughing|inaudible(?: speech)?|unintelligible(?: speech)?|foreign[ _-]*language|speaking[ _-]*foreign[ _-]*language|noise|background[ _-]*noise|whooshing|wind|rustling|static|sighs?|coughs?|breathing|whispering)";
  return text
    .replace(new RegExp(`\\[\\s*${annotation}\\s*\\]|\\(\\s*${annotation}\\s*\\)`, "gi"), " ")

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

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

Get a free API key