项目文件夹

文件
wehub-resource-sync c48612c494
CI / E2E Tests (push) Has been cancelled
CI / Lint, Typecheck & Unit Tests (push) Has been cancelled
Docs Build / Build docs site (push) Has been cancelled
Publish @openmaic packages / Build, validate & publish (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:23 +08:00

34 行
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import {
buildAutoVoxCPMVoicePrompt,
voxCPMBackendSupportsVoiceRegistration,
} from '@/lib/audio/voxcpm';
import { buildVoiceDesignPrompt, type VoiceDesign } from '@/lib/audio/voice-design';
const design: VoiceDesign = {
identity: 'middle-aged male teacher',
texture: 'warm low-pitched resonant',
delivery: 'calm measured encouraging',
};
describe('buildAutoVoxCPMVoicePrompt fallback chain', () => {
it('prefers voiceDesign over persona', () => {
expect(buildAutoVoxCPMVoicePrompt({ voiceDesign: design, persona: 'loves cats' })).toBe(
buildVoiceDesignPrompt(design),
);
});
it('falls back to persona, then role/name, then default', () => {
expect(buildAutoVoxCPMVoicePrompt({ persona: 'patient mentor' })).toBe('patient mentor');
expect(buildAutoVoxCPMVoicePrompt({ role: 'teacher', agentName: 'Lin' })).toBe('teacher Lin');
expect(buildAutoVoxCPMVoicePrompt({})).toBe('natural classroom voice');
});
});
describe('voxCPMBackendSupportsVoiceRegistration', () => {
it('is true only for vllm-omni', () => {
expect(voxCPMBackendSupportsVoiceRegistration('vllm-omni')).toBe(true);
expect(voxCPMBackendSupportsVoiceRegistration('nano-vllm')).toBe(false);
expect(voxCPMBackendSupportsVoiceRegistration('python-api')).toBe(false);
});
});