Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

1.3 KB
Raw Blame
import { expect, test } from 'vitest'
import { paceOfAlignment, PACE_SPEED_MAX_PCT, PACE_SPEED_MIN_PCT, uniformSpeedPct } from './voice-pace.ts'

test('a voice slower than the reference is sped up, a faster one slowed down, within ElevenLabs range', () => {
  // Measured 2026-11-28 with the same German sentence: Susi (the German default) 17.9, Laura 16.6, Mia Swiss 9.9.
  expect(uniformSpeedPct(100, 17.9, 17.9)).toBe(100)
  expect(uniformSpeedPct(100, 16.6, 17.9)).toBe(108)
  expect(uniformSpeedPct(110, 16.6, 17.9)).toBe(119)
  expect(uniformSpeedPct(100, 9.9, 17.9)).toBe(PACE_SPEED_MAX_PCT)
  expect(uniformSpeedPct(80, 30, 17.9)).toBe(PACE_SPEED_MIN_PCT)
})

test('until both paces are known the owner setting goes out unchanged', () => {
  expect(uniformSpeedPct(110, undefined, 17.9)).toBe(110)
  expect(uniformSpeedPct(110, 16.6, undefined)).toBe(110)
})

test('the pace of a sample: characters per second of speech, none for a sample too short to tell', () => {
  const characters = [...'x'.repeat(100)]
  expect(
    paceOfAlignment({ characters, character_start_times_seconds: [0.2], character_end_times_seconds: [5.2] }),
  ).toBe(20)
  expect(
    paceOfAlignment({ characters: ['a'], character_start_times_seconds: [0], character_end_times_seconds: [2] }),
  ).toBeNull()
  expect(paceOfAlignment(undefined)).toBeNull()
})