Prioritize external transcription endpoint over browser Web Speech API
Previously the on-device Web Speech API (Chrome/Edge/Safari) was always preferred, and the configured external transcription endpoint was only used as a fallback when the browser had no speech API at all (Firefox). Flip the priority in Composer.tsx: if a transcription endpoint is configured in Settings, use it for dictation regardless of browser support, since it's generally far more accurate. Fall back to the browser's on-device SpeechRecognition only when no endpoint is set. Update the Settings hint text and README to describe the new behavior. Rebuilt and redeployed to the repo root.
This commit is contained in:
1 parent
c7b653ff6a
commit
ea1aeed1da
6 files changed
+29
-21
No files matched your search
@@ -45,8 +45,10 @@ export function Composer() {
|
||||
const speech = useSpeechRecognition();
|
||||
const recorder = useRecorder();
|
||||
|
||||
const serverDictation = !speech.supported && !!transcribeUrl.trim();
|
||||
const dictationAvailable = speech.supported || serverDictation;
|
||||
// Prefer an explicitly-configured external transcription endpoint (usually
|
||||
// far more accurate) over the browser's on-device Web Speech API.
|
||||
const serverDictation = !!transcribeUrl.trim();
|
||||
const dictationAvailable = serverDictation || speech.supported;
|
||||
const active = speech.listening || recorder.recording;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -129,6 +131,13 @@ export function Composer() {
|
||||
await stopDictation();
|
||||
return;
|
||||
}
|
||||
// External transcription endpoint (if configured) takes priority over the
|
||||
// browser's on-device Web Speech API, which tends to be lower quality.
|
||||
if (serverDictation) {
|
||||
const ok = await recorder.start();
|
||||
if (!ok) setToast("Could not access the microphone.");
|
||||
return;
|
||||
}
|
||||
if (speech.supported) {
|
||||
if (!window.isSecureContext) {
|
||||
setToast("Dictation needs a secure context (HTTPS or localhost).");
|
||||
@@ -137,11 +146,6 @@ export function Composer() {
|
||||
speech.start(append);
|
||||
return;
|
||||
}
|
||||
if (serverDictation) {
|
||||
const ok = await recorder.start();
|
||||
if (!ok) setToast("Could not access the microphone.");
|
||||
return;
|
||||
}
|
||||
setToast(
|
||||
"Dictation isn't available in this browser. Use Chrome, Edge, or Safari — or set a transcription endpoint in Settings.",
|
||||
);
|
||||
|
||||
@@ -130,8 +130,9 @@ export function SettingsPanel() {
|
||||
<div className="section">
|
||||
<h3>Dictation</h3>
|
||||
<div className="hint" style={{ marginTop: 0, marginBottom: 10 }}>
|
||||
Chrome, Edge, and Safari dictate on-device via the Web Speech API. Firefox has no speech
|
||||
API, so set an OpenAI-compatible transcription endpoint below to dictate there.
|
||||
If a transcription endpoint is set below, it's used for dictation (usually far more
|
||||
accurate). Otherwise Chrome, Edge, and Safari fall back to on-device dictation via the
|
||||
Web Speech API — Firefox has no speech API, so it needs an endpoint set here.
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Transcription endpoint</label>
|
||||
|
||||
Reference in new issue
Block a user