feat(voice): add dedicated offline French Whisper model

This commit is contained in:
Blendman974 committed 2026-11-10 23:20:31 +01:00
1 parent a80d6697b5
commit b4b073412f
18 files changed
+621 -17

No files matched your search

+64
View File
@@ -144,3 +144,67 @@ test('OpenAI transcription model preserves legacy default and persists independe
assert.equal(s.voiceLanguageSetting.get(), 'fr');
assert.equal(settings(new Map([['voice.openAiTranscriptionModel', 'invalid']])).openAiTranscriptionModelSetting.get(), 'gpt-realtime-whisper');
});
test('French provider persists independently and never overwrites shared language preferences', () => {
const values = new Map([['voice.language', 'ja'], ['voice.provider', 'onboard-whisper']]);
let s = settings(values);
s.voiceProviderSetting.set('onboard-whisper-fr');
s = settings(values);
assert.equal(s.voiceProviderSetting.get(), 'onboard-whisper-fr');
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper-fr'), 'fr');
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper'), 'ja');
assert.equal(s.voiceLanguageSetting.get(), 'ja');
s.voiceProviderSetting.set('onboard-whisper');
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper'), 'ja');
});
test('French model download resumes, verifies every file including its license, and preserves other models', () => {
const files = new Map(), downloads = [];
const asr = load('app/native/asr-model.ts', () => ({
Utils: { android: { getApplicationContext: () => ({ getFilesDir: () => ({ getAbsolutePath: () => '/files' }) }) } },
}), {
java: { io: { File: class {
constructor(name) { this.name = name; }
exists() { return files.has(this.name); }
length() { return files.get(this.name) ?? 0; }
delete() { return files.delete(this.name); }
} } },
com: { faceclaw: { app: {
FaceclawModelDownloaderListener: function(listener) { return listener; },
FaceclawModelDownloader: class {
constructor(url, destination, hash, size, listener) {
Object.assign(this, { url, destination, hash, size, listener }); downloads.push(this);
}
start() {}
cancel() {}
},
} } },
});
for (const id of ['moonshine', 'whisper-base-en', 'whisper-base']) {
const model = asr.ASR_MODELS[id];
for (const file of model.files) files.set(`/files/faceclaw-voice-asr/${model.dirName}/${file.name}`, file.sizeBytes);
}
const model = asr.ASR_MODELS['whisper-small-fr'];
const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, '../docs/models/whisper-small-fr/manifest.json')));
assert.deepEqual(JSON.parse(JSON.stringify(model.files)), manifest.files);
assert.equal(model.totalBytes, model.files.reduce((total, file) => total + file.sizeBytes, 0));
assert.equal(asr.isAsrModelReady('whisper-small-fr'), false);
asr.startAsrModelDownload('whisper-small-fr');
files.set(downloads[0].destination, downloads[0].size);
downloads[0].listener.onDone();
downloads[1].listener.onError('network unavailable');
assert.equal(asr.asrModelState('whisper-small-fr').status, 'absent');
asr.startAsrModelDownload('whisper-small-fr');
assert.equal(downloads[2].destination, downloads[1].destination, 'resume the missing decoder');
for (let index = 2; index < 5; index++) {
const download = downloads[index];
assert.match(download.url, /api\/packages\/Blendman974\/generic\/faceclaw-asr\/whisper-small-fr-v1\//);
assert.match(download.hash, /^[a-f0-9]{64}$/);
files.set(download.destination, download.size);
download.listener.onDone();
}
assert.equal(asr.isAsrModelReady('whisper-small-fr'), true);
asr.deleteAsrModel('whisper-small-fr');
assert.equal(asr.isAsrModelReady('whisper-small-fr'), false);
for (const id of ['moonshine', 'whisper-base-en', 'whisper-base']) assert.equal(asr.isAsrModelReady(id), true);
});