fix: 语音模型下载

This commit is contained in:
Wxw-Gu
2026-08-05 10:21:13 +08:00
parent c2f9d352db
commit 55da2e2e67
+5 -1
View File
@@ -1,4 +1,5 @@
import { createHash } from 'crypto' import { createHash } from 'crypto'
import { net } from 'electron'
import { createReadStream } from 'fs' import { createReadStream } from 'fs'
import { mkdir, open, readFile, rename, rm, stat, writeFile } from 'fs/promises' import { mkdir, open, readFile, rename, rm, stat, writeFile } from 'fs/promises'
import { join } from 'path' import { join } from 'path'
@@ -163,7 +164,10 @@ export class VoiceModelManager {
const target = join(this.modelRoot, file.name) const target = join(this.modelRoot, file.name)
const partial = `${target}.partial` const partial = `${target}.partial`
await rm(partial, { force: true }) await rm(partial, { force: true })
const response = await fetch(file.url, { signal }) // Use Chromium's network stack rather than Node's global fetch so model
// downloads follow the operating system proxy configuration. This matters
// on networks where Hugging Face is only reachable through a system proxy.
const response = await net.fetch(file.url, { signal })
if (!response.ok || !response.body) throw new Error(`模型下载失败:HTTP ${response.status}`) if (!response.ok || !response.body) throw new Error(`模型下载失败:HTTP ${response.status}`)
const handle = await open(partial, 'w') const handle = await open(partial, 'w')