jbilcke-hf HF staff commited on
Commit
f67d756
β€’
1 Parent(s): c08cffe
samples/un-deux.wav ADDED
Binary file (184 kB). View file
 
src/speechToText/speechToTextWithWhisperLib.mts CHANGED
@@ -1,4 +1,5 @@
1
 
 
2
  import { nodewhisper } from "nodejs-whisper"
3
 
4
  import { convertMp3ToWavFilePath } from "../utils/convertMp3ToWavFilePath.mts"
@@ -7,16 +8,35 @@ export async function speechToText(sound: string): Promise<string> {
7
 
8
  console.log("/speechToText: calling whisper binding..")
9
 
10
- // TODO try a wav? audio/wav
 
 
11
  const wavFilePath = await convertMp3ToWavFilePath(sound)
12
 
13
  const result = await nodewhisper(wavFilePath, {
14
- modelName: "base.en", //Downloaded models name
15
- autoDownloadModelName: "base.en"
16
  })
17
 
18
- console.log(result)
19
 
20
  return "TODO"
21
 
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import path from "node:path"
3
  import { nodewhisper } from "nodejs-whisper"
4
 
5
  import { convertMp3ToWavFilePath } from "../utils/convertMp3ToWavFilePath.mts"
 
8
 
9
  console.log("/speechToText: calling whisper binding..")
10
 
11
+ // for some reason our mp3 is unreadable on Mac
12
+ // (too short?)
13
+ // but ffmpeg manages to convert it to a valid wav
14
  const wavFilePath = await convertMp3ToWavFilePath(sound)
15
 
16
  const result = await nodewhisper(wavFilePath, {
17
+ modelName: "large", //Downloaded models name
18
+ autoDownloadModelName: "large"
19
  })
20
 
21
+ console.log("result:" + JSON.stringify(result, null, 2))
22
 
23
  return "TODO"
24
 
25
+ }
26
+
27
+ /*
28
+ async function warmup() {
29
+ try {
30
+ await nodewhisper("./", {
31
+ modelName: "large", //Downloaded models name
32
+ autoDownloadModelName: "large"
33
+ })
34
+ } catch (err) {
35
+
36
+ }
37
+ }
38
+
39
+ setTimeout(() => {
40
+ warmup()
41
+ }, 1000)
42
+ */