ChetanXpro / nodejs-whisper

NodeJS Bindings for Whisper - the CPU version of OpenAI's Whisper, as initially crafted in C++ by ggerganov.
https://npmjs.com/nodejs-whisper
MIT License
93 stars 22 forks source link

Current directory remains to be whisper.cpp after nodewhisper #27

Closed 29decibel closed 9 months ago

29decibel commented 1 year ago

Thanks for the project! It's very easy to integrate with NodeJS.

I encouter an issue though, where I found the current dir changed even after the nodewhisper call:

Example code:

  await nodewhisper(filePath, {
    modelName: "tiny", //Downloaded models name
    autoDownloadModelName: "tiny", // (optional) autodownload a model if model is not present
    whisperOptions: {
      outputInText: false, // get output result in txt file
      outputInVtt: false, // get output result in vtt file
      outputInSrt: true, // get output result in srt file
      outputInCsv: true, // get output result in csv file
      translateToEnglish: false, //translate from source language to english
      wordTimestamps: false, // Word-level timestamps
      timestamps_length: 60, // amount of dialogue per timestamp pair
      splitOnWord: true, //split on word rather than on token
    },
  });
  console.log(readdirSync("./*"));

Expected: Showing results in the current dir where I executed the JS

What it shows:

Files under node_modules/.pnpm/nodejs-whisper@0.1.4/node_modules/nodejs-whisper/cpp/whisper.cpp/

29decibel commented 1 year ago

For now the temp workaround would be:

  const originalDirectory = process.cwd();
  await nodewhisper(filePath, {
    modelName: "tiny", //Downloaded models name
    autoDownloadModelName: "tiny", // (optional) autodownload a model if model is not present
    whisperOptions: {
      outputInText: false, // get output result in txt file
      outputInVtt: false, // get output result in vtt file
      outputInSrt: true, // get output result in srt file
      outputInCsv: true, // get output result in csv file
      translateToEnglish: false, //translate from source language to english
      wordTimestamps: false, // Word-level timestamps
      timestamps_length: 60, // amount of dialogue per timestamp pair
      splitOnWord: true, //split on word rather than on token
    },
  });

  process.chdir(originalDirectory);
ChetanXpro commented 1 year ago

@29decibel thanks for raising this , i got the issue , will fix this as soon as possible