Could not find a declaration file for module 'whisper-node'.
Opened this issue · 2 comments
Following the instructions in the Readme, I get:
╰─(base) ⠠⠵ ts-node src/process_scenes.ts --node on master↑1|✚16…17
Error preparing scenes: src/lib/Bark.ts:5:32 - error TS7016: Could not find a declaration file for module 'whisper-node'. '/home/arthur/dev/ai/manga/node_modules/whisper-node/dist/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/whisper-node` if it exists or add a new declaration (.d.ts) file containing `declare module 'whisper-node';`
5 import whisper from 'whisper-node';
~~~~~~~~~~~~~~
I tried npm i --save-dev @types/whisper-node
and got nothing more.
Any ideas?
Thanks.
PS: My tsconfig in case it's relevant:
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
}
}
PS: doing:
// @ts-ignore
import whisper from 'whisper-node';
solves the problem temporarily, but I'd really like a "clean" way out.
then when I am able to run it I have another problem:
/ram/runner/bark-text-reader-2ksgcnjtjt6//example.wav
[whisper-node] Transcribing: /ram/runner/bark-text-reader-2ksgcnjtjt6//example.wav
[whisper-node] No 'modelName' or 'modelPath' provided. Trying default model: base.en
[whisper-node] Problem: TypeError: Cannot read properties of null (reading 'shift')
at parseTranscript (/home/arthur/dev/ai/manga/node_modules/whisper-node/src/tsToArray.ts:12:9)
at /home/arthur/dev/ai/manga/node_modules/whisper-node/src/index.ts:35:46
at Generator.next (<anonymous>)
at fulfilled (/home/arthur/dev/ai/manga/node_modules/whisper-node/dist/index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
undefined
Not sure about the original error.
But with regards to the last problem, it seems it's related to the file path provided to whisper
.
Here's the comment that pointed that out, also providing the fix.
#36 (comment)
Also noticed that in your case you have:
Transcribing: /ram/runner/bark-text-reader-2ksgcnjtjt6//example.wav
And //example.wav
part with a double slash doesn't look right.
Hi, regarding the first error, the project does not provide type declaration files.
You can create your own declaration, somewhere in you project (for example src/typing/whisper-node.d.ts
) with following content:
declare module 'whisper-node' {
export type IShellOptions = {
silent: boolean // true: won't print to console
async: boolean
}
export type IOptions = {
modelName?: string // name of model stored in node_modules/whisper-node/lib/whisper.cpp/models
modelPath?: string // custom path for model
whisperOptions?: IFlagTypes
shellOptions?: IShellOptions
}
export type IFlagTypes = {
gen_file_txt?: boolean
gen_file_subtitle?: boolean
gen_file_vtt?: boolean
timestamp_size?: number
word_timestamps?: boolean
language?: string
}
export type ITranscriptLine = {
start: string
end: string
speech: string
}
export function whisper(filePath: string, options?: IOptions): Promise<ITranscriptLine[]>
}
I could create a PR, exporting type declarations from original code, but I can't see any CI/CD related config in the project