gate browser speech recognition setting

This commit is contained in:
Daniel 2026-05-08 08:05:23 +02:00
parent 56a5f16e5a
commit c1c0cfe1d5
2 changed files with 7 additions and 0 deletions

View file

@ -894,6 +894,7 @@ function exportToNextcloud(elementId, docType) {
}
function createSpeechRecognition() {
if (window.WebSpeechRecognition && !window.WebSpeechRecognition.isEnabled()) return null;
if (!(window.SpeechRecognition || window.webkitSpeechRecognition)) return null;
var SR = window.SpeechRecognition || window.webkitSpeechRecognition;
var rec = new SR();

View file

@ -56,3 +56,9 @@ test('browser Whisper is removed from public runtime and user settings', () => {
const server = read('server.js');
assert.doesNotMatch(server, /wasm-unsafe-eval|unsafe-eval|huggingface\.co|cdn-lfs|transformers/);
});
test('browser speech recognition is gated by explicit user setting', () => {
const app = read('public/js/app.js');
const speechFactory = app.match(/function createSpeechRecognition\(\) \{[\s\S]*?\n\}/)[0];
assert.match(speechFactory, /window\.WebSpeechRecognition && !window\.WebSpeechRecognition\.isEnabled\(\)/);
});