R2
This commit is contained in:
+15
-1
@@ -1,4 +1,5 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const harnessPath = process.env.JARVIS_HARNESS_PATH || path.resolve(new URL('../vendor/agent-harness', import.meta.url).pathname);
|
||||
@@ -18,8 +19,21 @@ export const QVAC_MASTER = Object.freeze({
|
||||
gpuLayers: 99,
|
||||
});
|
||||
|
||||
export function sdkPackagePath() {
|
||||
// Package exports intentionally block @qvac/sdk/package.json in current
|
||||
// releases, so resolve the version file from the two supported install
|
||||
// layouts instead of requiring an exported subpath.
|
||||
const candidates = [
|
||||
path.join(harnessPath, 'node_modules/@qvac/sdk/package.json'),
|
||||
path.resolve(harnessPath, '../../node_modules/@qvac/sdk/package.json'),
|
||||
path.resolve(new URL('../node_modules/@qvac/sdk/package.json', import.meta.url).pathname),
|
||||
];
|
||||
for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate;
|
||||
throw new Error(`Jarvis could not resolve @qvac/sdk from the harness or repository; checked ${candidates.join(', ')}`);
|
||||
}
|
||||
|
||||
export function assertSdkVersion() {
|
||||
const sdkPackage = require(path.join(harnessPath, 'node_modules/@qvac/sdk/package.json'));
|
||||
const sdkPackage = require(sdkPackagePath());
|
||||
if (!/^0\.19\./.test(sdkPackage.version)) {
|
||||
throw new Error(`Jarvis requires vendored @qvac/sdk in the 0.19.x series; found ${sdkPackage.version}`);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import path from 'node:path';
|
||||
import { acquireQvac, releaseQvac, loadAuxiliaryModel, unloadAuxiliaryModel, qvacSdk, withQvacMaster } from './qvac-master.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const harnessPath = process.env.JARVIS_HARNESS_PATH || path.resolve(new URL('../vendor/agent-harness', import.meta.url).pathname);
|
||||
const sdkPackage = require(path.join(harnessPath, 'node_modules/@qvac/sdk/package.json'));
|
||||
import { acquireQvac, releaseQvac, loadAuxiliaryModel, unloadAuxiliaryModel, qvacSdk, withQvacMaster, assertSdkVersion } from './qvac-master.js';
|
||||
|
||||
export class QvacVoiceAdapter extends EventEmitter {
|
||||
constructor({ asrModel = process.env.JARVIS_ASR_MODEL || 'WHISPER_TINY', ttsModel = process.env.JARVIS_TTS_MODEL || 'TTS_EN_SUPERTONIC_Q8_0' } = {}) {
|
||||
@@ -14,7 +8,7 @@ export class QvacVoiceAdapter extends EventEmitter {
|
||||
|
||||
async start() {
|
||||
if (this.acquired) return;
|
||||
if (!/^0\.19\./.test(sdkPackage.version)) throw new Error(`Jarvis voice adapter requires QVAC 0.19.x; found ${sdkPackage.version}`);
|
||||
assertSdkVersion();
|
||||
await acquireQvac(); this.acquired = true;
|
||||
try {
|
||||
this.asrId = await loadAuxiliaryModel(this.asrModel, { vadModelSrc: 'VAD_SILERO_5_1_2', audio_format: 's16le', language: 'en', no_timestamps: true, vad_params: { threshold: 0.6, min_speech_duration_ms: 300, min_silence_duration_ms: 700, max_speech_duration_s: 15, speech_pad_ms: 200 } });
|
||||
|
||||
Reference in New Issue
Block a user