fix(settings): ProvidersSection 识别 sherpa-onnx-local 本地引擎

合并 beta 的 #504 引入了第三个本地 ASR 引擎 sherpa-onnx-local,但本分支的
ProvidersSection(早于 #504 拆出)只认 local-qwen3 / foundry-local-whisper。
sherpa-onnx-local 激活时 knownAsr 查不到 → 主 Card 回落显示 volcengine、
凭据字段也错。补齐 5 处:ASR_PRESETS 条目、visibleAsrPresets 过滤、isLocked、
anomalousNameKey、本地引擎不渲染云端凭据字段的分支判断。
This commit is contained in:
baiqing committed 2026-05-22 22:50:22 +08:00
1 parent 8986c5680b
commit 00b2bd0a8d
1 file changed
+14 -7
@@ -143,7 +143,9 @@ const ASR_PRESETS: ReadonlyArray<{ id: AsrPresetId; nameKey: string; baseUrl: st
{ id: 'groq', nameKey: 'asrGroq', baseUrl: 'https://api.groq.com/openai/v1', model: 'whisper-large-v3-turbo' },
{ id: 'whisper', nameKey: 'asrWhisper', baseUrl: 'https://api.openai.com/v1', model: 'whisper-1' },
{ id: 'foundry-local-whisper', nameKey: 'asrFoundryLocalWhisper', baseUrl: '', model: '' },
// 本地 Qwen3-ASR:无 baseUrl/model 配置,模型在「高级 → 本地模型」里下载与切换。
// 本地引擎(Foundry / sherpa-onnx / Qwen3):无 baseUrl/model 配置,
// 模型在「高级 → 本地模型」里下载与切换。
{ id: 'sherpa-onnx-local', nameKey: 'asrSherpaOnnxLocal', baseUrl: '', model: '' },
{ id: 'local-qwen3', nameKey: 'asrLocalQwen3', baseUrl: '', model: '' },
];
@@ -166,10 +168,12 @@ export function ProvidersSection() {
const [llmModelRevision, setLlmModelRevision] = useState(0);
const [asrModelRevision, setAsrModelRevision] = useState(0);
const os = detectOS();
// 主 ASR 下拉只列云端选项;本地推理(local-qwen3 / foundry-local-whisper)
// 移到「高级 → 本地模型」,防止新手误开 CPU 推理。
// 主 ASR 下拉只列云端选项;本地推理(local-qwen3 / foundry-local-whisper /
// sherpa-onnx-local)移到「高级 → 本地模型」,防止新手误开 CPU 推理。
const visibleAsrPresets = ASR_PRESETS.filter(
p => p.id !== 'foundry-local-whisper' && p.id !== 'local-qwen3',
p => p.id !== 'foundry-local-whisper'
&& p.id !== 'local-qwen3'
&& p.id !== 'sherpa-onnx-local',
);
useEffect(() => {
@@ -363,7 +367,8 @@ export function ProvidersSection() {
{(() => {
const isLocked =
committedAsrProvider === 'local-qwen3' ||
committedAsrProvider === 'foundry-local-whisper';
committedAsrProvider === 'foundry-local-whisper' ||
committedAsrProvider === 'sherpa-onnx-local';
const selectedValue: AsrPresetId = isLocked ? committedAsrProvider : asrProvider;
// 跨机器同步异常兜底:committed 是本地但不在 visibleAsrPresets 里时,受控
// select 会回退到首项造成假象 —— 补一个 disabled option 让 select 找到当前值。
@@ -375,7 +380,9 @@ export function ProvidersSection() {
? 'asrLocalQwen3'
: anomalousLocal === 'foundry-local-whisper'
? 'asrFoundryLocalWhisper'
: null;
: anomalousLocal === 'sherpa-onnx-local'
? 'asrSherpaOnnxLocal'
: null;
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, alignItems: 'flex-start', minWidth: 0 }}>
<SelectLite
@@ -433,7 +440,7 @@ export function ProvidersSection() {
{t('settings.providers.volcengineMappingNote')}
</div>
</>
) : committedAsrProvider === 'local-qwen3' || committedAsrProvider === 'foundry-local-whisper' ? (
) : committedAsrProvider === 'local-qwen3' || committedAsrProvider === 'foundry-local-whisper' || committedAsrProvider === 'sherpa-onnx-local' ? (
// 用户已经在用本地 ASR——dropdown 行的 asrProviderTakenOver 已经把
// "在高级中切换或禁用"讲清楚了,body 不再重复。
// 模型管理 UI 唯一入口在「高级 → 本地模型」里的 <LocalAsr embedded />。