Skip to content

Commit

Permalink
Fixed error with timestamp_size
Browse files Browse the repository at this point in the history
  • Loading branch information
ariym committed Nov 19, 2023
1 parent 8b79c97 commit 368ee57
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![npm downloads](https://img.shields.io/npm/dm/whisper-node)](https://npmjs.org/package/whisper-node)
[![npm downloads](https://img.shields.io/npm/l/whisper-node)](https://npmjs.org/package/whisper-node)

Node.js bindings for OpenAI's Whisper.
Node.js bindings for OpenAI's Whisper. Transcription done local.

## Features

Expand Down Expand Up @@ -56,13 +56,13 @@ const filePath = "example/sample.wav"; // required

const options = {
modelName: "tiny.en", // default
modelPath: "/custom/path/to/model.bin", // use model in a custom directory
// modelPath: "/custom/path/to/model.bin", // use model in a custom directory (cannot use along with 'modelName')
whisperOptions: {
gen_file_txt: false, // outputs .txt file
gen_file_subtitle: false, // outputs .srt file
gen_file_vtt: false, // outputs .vtt file
timestamp_size: 10, // amount of dialogue per timestamp pair
word_timestamps: true // timestamp for every word
// timestamp_size: 0 // cannot use along with word_timestamps:true
}
}

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "whisper-node",
"version": "0.3.0",
"description": "Node bindings for OpenAI's Whisper. Optimized for CPU.",
"version": "0.3.1",
"description": "Node.js bindings for OpenAI's Whisper. Runs local on CPU.",
"homepage": "https://npmjs.com/whisper-node",
"author": "ariym",
"main": "dist/index.js",
Expand Down Expand Up @@ -45,6 +45,7 @@
"STT",
"TTS",
"SRT",
"Diarization"
"Diarization",
"local"
]
}
11 changes: 6 additions & 5 deletions src/whisper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ const getFlags = (flags: IFlagTypes): string => {
let s = "";

// output files
if (flags["gen_file_txt"]) s += " -otxt";
if (flags["gen_file_subtitle"]) s += " -osrt";
if (flags["gen_file_vtt"]) s += " -ovtt";
if (flags.gen_file_txt) s += " -otxt";
if (flags.gen_file_subtitle) s += " -osrt";
if (flags.gen_file_vtt) s += " -ovtt";
// timestamps
if (flags["timestamp_size"]) s += " -ml " + flags["timestamp-size"];
if (flags["word_timestamps"]) s += " -ml 1";
if (flags.timestamp_size && flags.word_timestamps) throw "Invalid option. Include 'timestamp_size' OR 'word_timestamps' NOT BOTH!"
if(flags.word_timestamps) s += " -ml 1"; // shorthand for timestamp_size:1
if(flags.timestamp_size) s += " -ml " + flags.timestamp_size;

return s;
}
Expand Down

0 comments on commit 368ee57

Please sign in to comment.