mirror of
https://github.com/blackajiro/Resonance.git
synced 2026-07-22 06:51:15 +00:00
fix whisper download
This commit is contained in:
parent
63a9002dea
commit
6ad5f20725
2 changed files with 28 additions and 18 deletions
|
|
@ -588,10 +588,12 @@ export class RecorderService {
|
|||
const lang = (whisperLanguage || "auto").trim();
|
||||
if (lang && lang !== "auto") { args.push("-l", lang); }
|
||||
|
||||
// Parametri anti-loop per chunk
|
||||
// Parametri anti-loop + accuratezza
|
||||
args.push("--max-context", "128", "--entropy-thold", "2.4", "--logprob-thold", "-1.0", "--max-len", "0");
|
||||
args.push("--max-context", "128", "--entropy-thold", "2.4", "--logprob-thold", "-1.0", "--max-len", "0");
|
||||
args.push("--best-of", "1", "--no-timestamps", "--word-thold", "0.01");
|
||||
// Beam search per maggiore accuratezza (più lento)
|
||||
args.push("-bs", "5");
|
||||
// Manteniamo i timestamp (niente --no-timestamps) per aiutare il decoder
|
||||
args.push("--word-thold", "0.01");
|
||||
|
||||
// Output su file temporaneo
|
||||
const tempTxtPath = chunkPath.replace(/\.mp3$/i, ".txt");
|
||||
|
|
|
|||
38
settings.ts
38
settings.ts
|
|
@ -531,11 +531,13 @@ export class ResonanceSettingTab extends PluginSettingTab {
|
|||
|
||||
private async downloadModelPreset(): Promise<string | null> {
|
||||
const preset = this.settings.whisperModelPreset || 'medium';
|
||||
const url = preset === 'small'
|
||||
? 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin'
|
||||
const fileName = preset === 'small'
|
||||
? 'ggml-small.bin'
|
||||
: preset === 'large'
|
||||
? 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large.bin'
|
||||
: 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin';
|
||||
? 'ggml-large-v3.bin'
|
||||
: 'ggml-medium.bin';
|
||||
const baseUrl = 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/';
|
||||
const url = `${baseUrl}${fileName}?download=true`;
|
||||
|
||||
const path = (window as any).require('path');
|
||||
const fs = (window as any).require('fs');
|
||||
|
|
@ -546,19 +548,25 @@ export class ResonanceSettingTab extends PluginSettingTab {
|
|||
if (!modelsDir) throw new Error('Set the repo folder first or provide a model path');
|
||||
try { fs.mkdirSync(modelsDir, { recursive: true }); } catch {}
|
||||
|
||||
const outFile = path.join(modelsDir, url.split('/').pop());
|
||||
const outFile = path.join(modelsDir, fileName);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const file = fs.createWriteStream(outFile);
|
||||
https.get(url, (res: any) => {
|
||||
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
||||
https.get(res.headers.location, (res2: any) => res2.pipe(file).on('finish', resolve)).on('error', reject);
|
||||
} else if (res.statusCode === 200) {
|
||||
res.pipe(file).on('finish', resolve);
|
||||
} else {
|
||||
reject(new Error('HTTP ' + res.statusCode));
|
||||
}
|
||||
}).on('error', reject);
|
||||
const follow = (u: string, depth: number) => {
|
||||
if (depth > 5) return reject(new Error('Too many redirects'));
|
||||
https.get(u, (res: any) => {
|
||||
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
||||
const next = res.headers.location.startsWith('http') ? res.headers.location : new URL(res.headers.location, u).toString();
|
||||
return follow(next, depth + 1);
|
||||
}
|
||||
if (res.statusCode === 200) {
|
||||
const file = fs.createWriteStream(outFile);
|
||||
res.pipe(file).on('finish', resolve).on('error', reject);
|
||||
} else {
|
||||
reject(new Error('HTTP ' + res.statusCode));
|
||||
}
|
||||
}).on('error', reject);
|
||||
};
|
||||
follow(url, 0);
|
||||
});
|
||||
|
||||
return outFile;
|
||||
|
|
|
|||
Loading…
Reference in a new issue