clock (utils/diarization.js)

LocalAI · addons/studio/ui/src/utils/diarization.js · javascript · MIT
voice

Utility functions for converting diarization results into time formats, RTTM, SRT, and speaker statistics.

// Source: https://github.com/mudler/LocalAI | License: MIT | Copyright 2023-2025 Ettore Di Giacinto (mudler@localai.io)
// Provided via justclaw.it.com; keep this notice with the code.
// What a diarization run says, as numbers and as the files people already use
// for it. Plain functions with no React, so they can be tested with `node --test`.
//
// A segment is { start, end, speaker, label, name?, text? } in seconds. `label`
// is the stable key of a speaker inside one run; `speaker` is the id the server
// prints (SPEAKER_00).

const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0)

// m:ss, or h:mm:ss for a long recording.
export function clock(seconds) {
  const total = Math.max(0, Math.round(num(seconds)))
  const h = Math.floor(total / 3600)
  const m = Math.floor((total 

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

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

Get a free API key