Skip to content

Commit 5cc6624

Browse files
committed
feat: add function to download models directly
1 parent 8f5c8bf commit 5cc6624

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodejs-whisper",
3-
"version": "0.0.8",
3+
"version": "0.0.10",
44
"description": "Node bindings for OpenAI's Whisper. Optimized for CPU.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/downloadModel.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ export default async function downloadModel() {
3636
try {
3737
shell.cd(path.join(__dirname, '..', './cpp/whisper.cpp/models'))
3838

39+
const args = process.argv.slice(2)
40+
if (args.length > 0) {
41+
const modelName = args[0]
42+
console.log('Downloading model:', modelName)
43+
if (!MODELS_LIST.includes(modelName)) {
44+
throw `[Nodejs-whisper] Error: Model name not found. Check your spelling.`
45+
}
46+
let scriptPath = './download-ggml-model.sh'
47+
48+
if (process.platform === 'win32') scriptPath = 'download-ggml-model.cmd'
49+
shell.chmod('+x', scriptPath)
50+
shell.exec(`${scriptPath} ${modelName}`)
51+
console.log('[Nodejs-whisper] Attempting to compile model...\n')
52+
shell.cd('../')
53+
shell.exec('make')
54+
process.exit(0)
55+
}
56+
3957
let anyModelExist = []
4058

4159
MODELS.forEach(model => {

0 commit comments

Comments
 (0)