Merge configurable OpenAI transcription model

This commit is contained in:
Blendman974 committed 2026-11-08 00:37:07 +01:00
commit 2a607b32d0
11 files changed
+113 -17

No files matched your search

+40
View File
@@ -242,3 +242,43 @@ test('a spoken-language hint reaches each provider on the wire, and is left out
assert.equal(transcription.language, language || undefined);
}
});
test('OpenAI selected transcription models preserve French hints, manual commits and final transcripts', () => {
for (const model of ['gpt-realtime-whisper', 'gpt-4o-mini-transcribe', 'gpt-4o-transcribe']) {
const h = harness('openai', true, { model, language: 'fr' });
h.open();
const input = JSON.parse(h.sockets[0].sent[0]).session.audio.input;
assert.equal(input.transcription.model, model);
assert.equal(input.transcription.language, 'fr');
assert.equal(input.turn_detection, null);
h.client.acceptPcm(pcm(1200, 150));
h.client.acceptPcm(pcm(0, 1500));
assert.ok(h.sockets[0].sent.some(value => JSON.parse(value).type === 'input_audio_buffer.commit'));
h.message({ type: 'input_audio_buffer.committed', item_id: 'one' });
h.message({ type: 'conversation.item.input_audio_transcription.delta', item_id: 'one', delta: 'Bonjour' });
h.message({ type: 'conversation.item.input_audio_transcription.completed', item_id: 'one', transcript: 'Bonjour à tous.' });
assert.equal(h.events.at(-1).text, 'Bonjour à tous.');
assert.equal(h.events.at(-1).isFinal, true);
h.message({ type: 'error', error: { code: 'model_not_found', message: 'Project private-id does not have access' } });
assert.ok(h.errors[0].includes(model));
assert.ok(h.errors[0].includes('OpenAI transcription model'));
}
});
test('OpenAI model selection reaches the factory and separates shared captures only for OpenAI', () => {
const created = [];
const load = loader({ setTimeout, clearTimeout }, {
'./openai-stt': {
DEFAULT_OPENAI_STT_MODEL: 'gpt-realtime-whisper',
OpenAiRealtimeSttClient: class { constructor(options) { created.push(options); } start() {} stop() {} },
},
});
const { createCloudSttClient, transcriptionKey } = load('app/native/cloud-stt-provider.ts');
const selection = { provider: 'whisper', language: 'fr', openAiApiKey: 'test', openAiTranscriptionModel: 'gpt-4o-mini-transcribe' };
createCloudSttClient(selection, { onStatus() {}, onError() {}, onTranscript() {} }, () => false).start();
assert.equal(created[0].model, selection.openAiTranscriptionModel);
assert.equal(created[0].language, 'fr');
assert.notEqual(transcriptionKey(selection), transcriptionKey({ ...selection, openAiTranscriptionModel: 'gpt-realtime-whisper' }));
assert.equal(transcriptionKey({ provider: 'whisper' }), transcriptionKey({ provider: 'whisper', openAiTranscriptionModel: 'gpt-realtime-whisper' }));
assert.equal(transcriptionKey({ ...selection, provider: 'soniox' }), transcriptionKey({ ...selection, provider: 'soniox', openAiTranscriptionModel: 'gpt-4o-transcribe' }));
});
+1 -1
View File
@@ -7,7 +7,7 @@ const path = require('node:path');
// The provider settings ios-preview-controller hands the voice bridge.
const voiceSettings = { voiceProviderSetting: { get: () => 'onboard' }, elevenLabsApiKeySetting: { get: () => '' },
getVoiceTranscriptionLanguage: () => '',
openAiApiKeySetting: { get: () => '' }, sonioxApiKeySetting: { get: () => '' },
openAiTranscriptionModelSetting: { get: () => 'gpt-realtime-whisper' }, openAiApiKeySetting: { get: () => '' }, sonioxApiKeySetting: { get: () => '' },
whisperServerUrlSetting: { get: () => '' }, whisperServerModelSetting: { get: () => '' },
whisperServerLanguageSetting: { get: () => '' }, whisperServerApiKeySetting: { get: () => '' } };
function load(file, context) {
+15
View File
@@ -62,6 +62,7 @@ test('Android and iOS capture options use the shared language and preserve Trans
const s = settings();
s.voiceLanguageSetting.set('fr');
s.voiceProviderSetting.set('whisper');
s.openAiTranscriptionModelSetting.set('gpt-4o-mini-transcribe');
for (const [file, name, method] of [
['app/g2/dashboard-controller.ts', 'DashboardController', 'voiceCaptureOptions'],
['app/g2/ios-preview-controller.ts', 'IosPreviewController', 'voiceProvider'],
@@ -75,11 +76,13 @@ test('Android and iOS capture options use the shared language and preserve Trans
const member = declaration.members.find(n => n.name?.getText(tree) === method);
const capture = loadBody(member.body.getText(tree), s, host);
assert.equal(capture().language, 'fr');
assert.equal(capture().openAiTranscriptionModel, 'gpt-4o-mini-transcribe');
host.continuousClients.set('translate', { transcription: { provider: 'soniox', language: 'ja' } });
assert.equal(capture().provider, 'soniox');
assert.equal(capture().language, 'ja');
host.continuousClients.clear();
assert.equal(capture().language, 'fr');
assert.equal(capture().openAiTranscriptionModel, 'gpt-4o-mini-transcribe');
}
});
@@ -129,3 +132,15 @@ test('multilingual downloads and deletion leave an existing English model intact
assert.equal(asr.isAsrModelReady('whisper-base'), false);
assert.equal(asr.isAsrModelReady('whisper-base-en'), true);
});
test('OpenAI transcription model preserves legacy default and persists independently of language', () => {
const values = new Map();
let s = settings(values);
assert.equal(s.openAiTranscriptionModelSetting.get(), 'gpt-realtime-whisper');
s.openAiTranscriptionModelSetting.set('gpt-4o-mini-transcribe');
s.voiceLanguageSetting.set('fr');
s = settings(values);
assert.equal(s.openAiTranscriptionModelSetting.get(), 'gpt-4o-mini-transcribe');
assert.equal(s.voiceLanguageSetting.get(), 'fr');
assert.equal(settings(new Map([['voice.openAiTranscriptionModel', 'invalid']])).openAiTranscriptionModelSetting.get(), 'gpt-realtime-whisper');
});