Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 915 Bytes
4ddd98f f67d756 4ddd98f f67d756 4ddd98f f67d756 4ddd98f f67d756 4ddd98f f67d756 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import path from "node:path"
import { nodewhisper } from "nodejs-whisper"
import { convertMp3ToWavFilePath } from "../utils/convertMp3ToWavFilePath.mts"
export async function speechToText(sound: string): Promise<string> {
console.log("/speechToText: calling whisper binding..")
// for some reason our mp3 is unreadable on Mac
// (too short?)
// but ffmpeg manages to convert it to a valid wav
const wavFilePath = await convertMp3ToWavFilePath(sound)
const result = await nodewhisper(wavFilePath, {
modelName: "large", //Downloaded models name
autoDownloadModelName: "large"
})
console.log("result:" + JSON.stringify(result, null, 2))
return "TODO"
}
/*
async function warmup() {
try {
await nodewhisper("./", {
modelName: "large", //Downloaded models name
autoDownloadModelName: "large"
})
} catch (err) {
}
}
setTimeout(() => {
warmup()
}, 1000)
*/ |