Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

1.1 KB
Raw Blame
// Kept free of imports: the speech engine loads this in plain Node (scripts/whisper-smoke.mjs),
// where the app's translations (import.meta.glob, a bundler feature) can't load.

/** writing with no spaces between words (Japanese, Chinese, Thai…), and its punctuation */
const NO_SPACE = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}\u3000-\u303f\uff01-\uff65]/u
/** written without spaces between words */
export const unspaced = (ch: string | undefined): boolean => !!ch && NO_SPACE.test(ch)

/** Lines read as one text: a space between them, except where neither side is written with spaces */
export function joinSaid(texts: string[]): string {
  let out = ''
  for (const raw of texts) {
    const text = raw.trim()
    if (!text) continue
    const last = [...out].at(-1), first = [...text][0]
    const none = !out || (unspaced(last) && (unspaced(first) || /\p{P}/u.test(first))) || (unspaced(first) && /\p{P}/u.test(last!) && [...out].some(unspaced))
    out += (none ? '' : ' ') + text
  }
  return out
}