jbilcke-hf HF staff commited on
Commit
4ddd98f
·
1 Parent(s): ab89c61

test with whisper cpp (warning: might break the prod server)

Browse files
Dockerfile CHANGED
@@ -31,6 +31,7 @@ COPY --chown=user package*.json $HOME/app
31
 
32
  RUN npm install
33
 
 
34
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
35
  COPY --chown=user . $HOME/app
36
 
 
31
 
32
  RUN npm install
33
 
34
+
35
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
36
  COPY --chown=user . $HOME/app
37
 
package-lock.json CHANGED
@@ -23,12 +23,14 @@
23
  "fs-extra": "^11.1.1",
24
  "gpt-tokens": "^1.1.1",
25
  "node-fetch": "^3.3.1",
 
26
  "openai": "^3.3.0",
27
  "puppeteer": "^20.8.0",
28
  "resize-base64": "^1.0.12",
29
  "sharp": "^0.32.4",
30
  "temp-dir": "^3.0.0",
31
  "ts-node": "^10.9.1",
 
32
  "uuid": "^9.0.0",
33
  "yaml": "^2.3.1"
34
  }
@@ -76,6 +78,20 @@
76
  "node": ">=12"
77
  }
78
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  "node_modules/@gorgonjs/file-provider": {
80
  "version": "1.4.1",
81
  "resolved": "https://registry.npmjs.org/@gorgonjs/file-provider/-/file-provider-1.4.1.tgz",
@@ -897,6 +913,11 @@
897
  "node": "*"
898
  }
899
  },
 
 
 
 
 
900
  "node_modules/bufferutil": {
901
  "version": "4.0.7",
902
  "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz",
@@ -1153,6 +1174,20 @@
1153
  "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
1154
  "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
1155
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1156
  "node_modules/console-control-strings": {
1157
  "version": "1.1.0",
1158
  "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
@@ -1974,6 +2009,65 @@
1974
  "execa": "^0.10.0"
1975
  }
1976
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1977
  "node_modules/file-uri-to-path": {
1978
  "version": "1.0.0",
1979
  "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@@ -2646,6 +2740,19 @@
2646
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
2647
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
2648
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
2649
  "node_modules/http-signature": {
2650
  "version": "1.2.0",
2651
  "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
@@ -2797,6 +2904,14 @@
2797
  "kind-of": "^6.0.2"
2798
  }
2799
  },
 
 
 
 
 
 
 
 
2800
  "node_modules/iota-array": {
2801
  "version": "1.0.0",
2802
  "resolved": "https://registry.npmjs.org/iota-array/-/iota-array-1.0.0.tgz",
@@ -2825,6 +2940,17 @@
2825
  "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
2826
  "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
2827
  },
 
 
 
 
 
 
 
 
 
 
 
2828
  "node_modules/is-empty-iterable": {
2829
  "version": "2.1.0",
2830
  "resolved": "https://registry.npmjs.org/is-empty-iterable/-/is-empty-iterable-2.1.0.tgz",
@@ -3041,6 +3167,18 @@
3041
  "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
3042
  "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
3043
  },
 
 
 
 
 
 
 
 
 
 
 
 
3044
  "node_modules/lru-cache": {
3045
  "version": "7.18.3",
3046
  "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
@@ -3636,6 +3774,19 @@
3636
  "node": ">= 8"
3637
  }
3638
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
3639
  "node_modules/nopt": {
3640
  "version": "6.0.0",
3641
  "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz",
@@ -3853,6 +4004,11 @@
3853
  "node": ">=6"
3854
  }
3855
  },
 
 
 
 
 
3856
  "node_modules/parse-data-uri": {
3857
  "version": "0.2.0",
3858
  "resolved": "https://registry.npmjs.org/parse-data-uri/-/parse-data-uri-0.2.0.tgz",
@@ -3907,6 +4063,11 @@
3907
  "node": ">=4"
3908
  }
3909
  },
 
 
 
 
 
3910
  "node_modules/path-scurry": {
3911
  "version": "1.10.1",
3912
  "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz",
@@ -4272,6 +4433,31 @@
4272
  "rc": "cli.js"
4273
  }
4274
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4275
  "node_modules/readable-stream": {
4276
  "version": "3.6.2",
4277
  "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
@@ -4285,6 +4471,25 @@
4285
  "node": ">= 6"
4286
  }
4287
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4288
  "node_modules/repeat-string": {
4289
  "version": "1.6.1",
4290
  "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
@@ -4370,6 +4575,22 @@
4370
  "create-readme": "^1.1.0"
4371
  }
4372
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4373
  "node_modules/resolve-from": {
4374
  "version": "4.0.0",
4375
  "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@@ -4478,6 +4699,15 @@
4478
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
4479
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
4480
  },
 
 
 
 
 
 
 
 
 
4481
  "node_modules/semiver": {
4482
  "version": "1.1.0",
4483
  "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
@@ -4622,6 +4852,22 @@
4622
  "node": ">=0.10.0"
4623
  }
4624
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4625
  "node_modules/side-channel": {
4626
  "version": "1.0.4",
4627
  "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@@ -4908,6 +5154,17 @@
4908
  "node": ">=4"
4909
  }
4910
  },
 
 
 
 
 
 
 
 
 
 
 
4911
  "node_modules/tar": {
4912
  "version": "6.1.15",
4913
  "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz",
@@ -5107,6 +5364,19 @@
5107
  "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
5108
  "integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA=="
5109
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
5110
  "node_modules/tunnel-agent": {
5111
  "version": "0.6.0",
5112
  "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@@ -5146,6 +5416,11 @@
5146
  "node": ">= 0.6"
5147
  }
5148
  },
 
 
 
 
 
5149
  "node_modules/typedarray-pool": {
5150
  "version": "1.2.0",
5151
  "resolved": "https://registry.npmjs.org/typedarray-pool/-/typedarray-pool-1.2.0.tgz",
 
23
  "fs-extra": "^11.1.1",
24
  "gpt-tokens": "^1.1.1",
25
  "node-fetch": "^3.3.1",
26
+ "nodejs-whisper": "^0.1.4",
27
  "openai": "^3.3.0",
28
  "puppeteer": "^20.8.0",
29
  "resize-base64": "^1.0.12",
30
  "sharp": "^0.32.4",
31
  "temp-dir": "^3.0.0",
32
  "ts-node": "^10.9.1",
33
+ "tts-react": "^3.0.1",
34
  "uuid": "^9.0.0",
35
  "yaml": "^2.3.1"
36
  }
 
78
  "node": ">=12"
79
  }
80
  },
81
+ "node_modules/@derhuerst/http-basic": {
82
+ "version": "8.2.4",
83
+ "resolved": "https://registry.npmjs.org/@derhuerst/http-basic/-/http-basic-8.2.4.tgz",
84
+ "integrity": "sha512-F9rL9k9Xjf5blCz8HsJRO4diy111cayL2vkY2XE4r4t3n0yPXVYy3KD3nJ1qbrSn9743UWSXH4IwuCa/HWlGFw==",
85
+ "dependencies": {
86
+ "caseless": "^0.12.0",
87
+ "concat-stream": "^2.0.0",
88
+ "http-response-object": "^3.0.1",
89
+ "parse-cache-control": "^1.0.1"
90
+ },
91
+ "engines": {
92
+ "node": ">=6.0.0"
93
+ }
94
+ },
95
  "node_modules/@gorgonjs/file-provider": {
96
  "version": "1.4.1",
97
  "resolved": "https://registry.npmjs.org/@gorgonjs/file-provider/-/file-provider-1.4.1.tgz",
 
913
  "node": "*"
914
  }
915
  },
916
+ "node_modules/buffer-from": {
917
+ "version": "1.1.2",
918
+ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
919
+ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
920
+ },
921
  "node_modules/bufferutil": {
922
  "version": "4.0.7",
923
  "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz",
 
1174
  "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
1175
  "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
1176
  },
1177
+ "node_modules/concat-stream": {
1178
+ "version": "2.0.0",
1179
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
1180
+ "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
1181
+ "engines": [
1182
+ "node >= 6.0"
1183
+ ],
1184
+ "dependencies": {
1185
+ "buffer-from": "^1.0.0",
1186
+ "inherits": "^2.0.3",
1187
+ "readable-stream": "^3.0.2",
1188
+ "typedarray": "^0.0.6"
1189
+ }
1190
+ },
1191
  "node_modules/console-control-strings": {
1192
  "version": "1.1.0",
1193
  "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
 
2009
  "execa": "^0.10.0"
2010
  }
2011
  },
2012
+ "node_modules/ffmpeg-static": {
2013
+ "version": "5.2.0",
2014
+ "resolved": "https://registry.npmjs.org/ffmpeg-static/-/ffmpeg-static-5.2.0.tgz",
2015
+ "integrity": "sha512-WrM7kLW+do9HLr+H6tk7LzQ7kPqbAgLjdzNE32+u3Ff11gXt9Kkkd2nusGFrlWMIe+XaA97t+I8JS7sZIrvRgA==",
2016
+ "hasInstallScript": true,
2017
+ "dependencies": {
2018
+ "@derhuerst/http-basic": "^8.2.0",
2019
+ "env-paths": "^2.2.0",
2020
+ "https-proxy-agent": "^5.0.0",
2021
+ "progress": "^2.0.3"
2022
+ },
2023
+ "engines": {
2024
+ "node": ">=16"
2025
+ }
2026
+ },
2027
+ "node_modules/ffmpeg-static/node_modules/agent-base": {
2028
+ "version": "6.0.2",
2029
+ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
2030
+ "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
2031
+ "dependencies": {
2032
+ "debug": "4"
2033
+ },
2034
+ "engines": {
2035
+ "node": ">= 6.0.0"
2036
+ }
2037
+ },
2038
+ "node_modules/ffmpeg-static/node_modules/debug": {
2039
+ "version": "4.3.4",
2040
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
2041
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
2042
+ "dependencies": {
2043
+ "ms": "2.1.2"
2044
+ },
2045
+ "engines": {
2046
+ "node": ">=6.0"
2047
+ },
2048
+ "peerDependenciesMeta": {
2049
+ "supports-color": {
2050
+ "optional": true
2051
+ }
2052
+ }
2053
+ },
2054
+ "node_modules/ffmpeg-static/node_modules/https-proxy-agent": {
2055
+ "version": "5.0.1",
2056
+ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
2057
+ "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
2058
+ "dependencies": {
2059
+ "agent-base": "6",
2060
+ "debug": "4"
2061
+ },
2062
+ "engines": {
2063
+ "node": ">= 6"
2064
+ }
2065
+ },
2066
+ "node_modules/ffmpeg-static/node_modules/ms": {
2067
+ "version": "2.1.2",
2068
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
2069
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
2070
+ },
2071
  "node_modules/file-uri-to-path": {
2072
  "version": "1.0.0",
2073
  "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
 
2740
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
2741
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
2742
  },
2743
+ "node_modules/http-response-object": {
2744
+ "version": "3.0.2",
2745
+ "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.2.tgz",
2746
+ "integrity": "sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==",
2747
+ "dependencies": {
2748
+ "@types/node": "^10.0.3"
2749
+ }
2750
+ },
2751
+ "node_modules/http-response-object/node_modules/@types/node": {
2752
+ "version": "10.17.60",
2753
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz",
2754
+ "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw=="
2755
+ },
2756
  "node_modules/http-signature": {
2757
  "version": "1.2.0",
2758
  "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
 
2904
  "kind-of": "^6.0.2"
2905
  }
2906
  },
2907
+ "node_modules/interpret": {
2908
+ "version": "1.4.0",
2909
+ "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
2910
+ "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
2911
+ "engines": {
2912
+ "node": ">= 0.10"
2913
+ }
2914
+ },
2915
  "node_modules/iota-array": {
2916
  "version": "1.0.0",
2917
  "resolved": "https://registry.npmjs.org/iota-array/-/iota-array-1.0.0.tgz",
 
2940
  "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
2941
  "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
2942
  },
2943
+ "node_modules/is-core-module": {
2944
+ "version": "2.13.0",
2945
+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz",
2946
+ "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==",
2947
+ "dependencies": {
2948
+ "has": "^1.0.3"
2949
+ },
2950
+ "funding": {
2951
+ "url": "https://github.com/sponsors/ljharb"
2952
+ }
2953
+ },
2954
  "node_modules/is-empty-iterable": {
2955
  "version": "2.1.0",
2956
  "resolved": "https://registry.npmjs.org/is-empty-iterable/-/is-empty-iterable-2.1.0.tgz",
 
3167
  "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
3168
  "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
3169
  },
3170
+ "node_modules/loose-envify": {
3171
+ "version": "1.4.0",
3172
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
3173
+ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
3174
+ "peer": true,
3175
+ "dependencies": {
3176
+ "js-tokens": "^3.0.0 || ^4.0.0"
3177
+ },
3178
+ "bin": {
3179
+ "loose-envify": "cli.js"
3180
+ }
3181
+ },
3182
  "node_modules/lru-cache": {
3183
  "version": "7.18.3",
3184
  "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
 
3774
  "node": ">= 8"
3775
  }
3776
  },
3777
+ "node_modules/nodejs-whisper": {
3778
+ "version": "0.1.4",
3779
+ "resolved": "https://registry.npmjs.org/nodejs-whisper/-/nodejs-whisper-0.1.4.tgz",
3780
+ "integrity": "sha512-V3cRV+K4hA4TGTgGxAcz3+zDPfPgD2e82KXojgS3Tgbw4RLnirzE1DdiW9hFrcuR3/6pyr7sXvctYhZUV4asvQ==",
3781
+ "dependencies": {
3782
+ "ffmpeg-static": "^5.2.0",
3783
+ "readline-sync": "^1.4.10",
3784
+ "shelljs": "^0.8.5"
3785
+ },
3786
+ "bin": {
3787
+ "download": "dist/downloadModel.js"
3788
+ }
3789
+ },
3790
  "node_modules/nopt": {
3791
  "version": "6.0.0",
3792
  "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz",
 
4004
  "node": ">=6"
4005
  }
4006
  },
4007
+ "node_modules/parse-cache-control": {
4008
+ "version": "1.0.1",
4009
+ "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz",
4010
+ "integrity": "sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg=="
4011
+ },
4012
  "node_modules/parse-data-uri": {
4013
  "version": "0.2.0",
4014
  "resolved": "https://registry.npmjs.org/parse-data-uri/-/parse-data-uri-0.2.0.tgz",
 
4063
  "node": ">=4"
4064
  }
4065
  },
4066
+ "node_modules/path-parse": {
4067
+ "version": "1.0.7",
4068
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
4069
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
4070
+ },
4071
  "node_modules/path-scurry": {
4072
  "version": "1.10.1",
4073
  "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz",
 
4433
  "rc": "cli.js"
4434
  }
4435
  },
4436
+ "node_modules/react": {
4437
+ "version": "18.2.0",
4438
+ "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
4439
+ "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
4440
+ "peer": true,
4441
+ "dependencies": {
4442
+ "loose-envify": "^1.1.0"
4443
+ },
4444
+ "engines": {
4445
+ "node": ">=0.10.0"
4446
+ }
4447
+ },
4448
+ "node_modules/react-dom": {
4449
+ "version": "18.2.0",
4450
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
4451
+ "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
4452
+ "peer": true,
4453
+ "dependencies": {
4454
+ "loose-envify": "^1.1.0",
4455
+ "scheduler": "^0.23.0"
4456
+ },
4457
+ "peerDependencies": {
4458
+ "react": "^18.2.0"
4459
+ }
4460
+ },
4461
  "node_modules/readable-stream": {
4462
  "version": "3.6.2",
4463
  "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
 
4471
  "node": ">= 6"
4472
  }
4473
  },
4474
+ "node_modules/readline-sync": {
4475
+ "version": "1.4.10",
4476
+ "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz",
4477
+ "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==",
4478
+ "engines": {
4479
+ "node": ">= 0.8.0"
4480
+ }
4481
+ },
4482
+ "node_modules/rechoir": {
4483
+ "version": "0.6.2",
4484
+ "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
4485
+ "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
4486
+ "dependencies": {
4487
+ "resolve": "^1.1.6"
4488
+ },
4489
+ "engines": {
4490
+ "node": ">= 0.10"
4491
+ }
4492
+ },
4493
  "node_modules/repeat-string": {
4494
  "version": "1.6.1",
4495
  "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
 
4575
  "create-readme": "^1.1.0"
4576
  }
4577
  },
4578
+ "node_modules/resolve": {
4579
+ "version": "1.22.4",
4580
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz",
4581
+ "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==",
4582
+ "dependencies": {
4583
+ "is-core-module": "^2.13.0",
4584
+ "path-parse": "^1.0.7",
4585
+ "supports-preserve-symlinks-flag": "^1.0.0"
4586
+ },
4587
+ "bin": {
4588
+ "resolve": "bin/resolve"
4589
+ },
4590
+ "funding": {
4591
+ "url": "https://github.com/sponsors/ljharb"
4592
+ }
4593
+ },
4594
  "node_modules/resolve-from": {
4595
  "version": "4.0.0",
4596
  "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
 
4699
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
4700
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
4701
  },
4702
+ "node_modules/scheduler": {
4703
+ "version": "0.23.0",
4704
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
4705
+ "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
4706
+ "peer": true,
4707
+ "dependencies": {
4708
+ "loose-envify": "^1.1.0"
4709
+ }
4710
+ },
4711
  "node_modules/semiver": {
4712
  "version": "1.1.0",
4713
  "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
 
4852
  "node": ">=0.10.0"
4853
  }
4854
  },
4855
+ "node_modules/shelljs": {
4856
+ "version": "0.8.5",
4857
+ "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz",
4858
+ "integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==",
4859
+ "dependencies": {
4860
+ "glob": "^7.0.0",
4861
+ "interpret": "^1.0.0",
4862
+ "rechoir": "^0.6.2"
4863
+ },
4864
+ "bin": {
4865
+ "shjs": "bin/shjs"
4866
+ },
4867
+ "engines": {
4868
+ "node": ">=4"
4869
+ }
4870
+ },
4871
  "node_modules/side-channel": {
4872
  "version": "1.0.4",
4873
  "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
 
5154
  "node": ">=4"
5155
  }
5156
  },
5157
+ "node_modules/supports-preserve-symlinks-flag": {
5158
+ "version": "1.0.0",
5159
+ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
5160
+ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
5161
+ "engines": {
5162
+ "node": ">= 0.4"
5163
+ },
5164
+ "funding": {
5165
+ "url": "https://github.com/sponsors/ljharb"
5166
+ }
5167
+ },
5168
  "node_modules/tar": {
5169
  "version": "6.1.15",
5170
  "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz",
 
5364
  "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
5365
  "integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA=="
5366
  },
5367
+ "node_modules/tts-react": {
5368
+ "version": "3.0.1",
5369
+ "resolved": "https://registry.npmjs.org/tts-react/-/tts-react-3.0.1.tgz",
5370
+ "integrity": "sha512-v/kUYPyLHB9xAUtI+EF/dU1fEqzP6BByg8fLI9+BcZGJyT+tfT4Yv/cTE7bzhPBS9W90a79XujyikMrG1QqR9g==",
5371
+ "engines": {
5372
+ "node": ">=18.16.0",
5373
+ "npm": ">=9.5.1"
5374
+ },
5375
+ "peerDependencies": {
5376
+ "react": ">=17.0.0",
5377
+ "react-dom": ">=17.0.0"
5378
+ }
5379
+ },
5380
  "node_modules/tunnel-agent": {
5381
  "version": "0.6.0",
5382
  "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
 
5416
  "node": ">= 0.6"
5417
  }
5418
  },
5419
+ "node_modules/typedarray": {
5420
+ "version": "0.0.6",
5421
+ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
5422
+ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
5423
+ },
5424
  "node_modules/typedarray-pool": {
5425
  "version": "1.2.0",
5426
  "resolved": "https://registry.npmjs.org/typedarray-pool/-/typedarray-pool-1.2.0.tgz",
package.json CHANGED
@@ -30,12 +30,14 @@
30
  "fs-extra": "^11.1.1",
31
  "gpt-tokens": "^1.1.1",
32
  "node-fetch": "^3.3.1",
 
33
  "openai": "^3.3.0",
34
  "puppeteer": "^20.8.0",
35
  "resize-base64": "^1.0.12",
36
  "sharp": "^0.32.4",
37
  "temp-dir": "^3.0.0",
38
  "ts-node": "^10.9.1",
 
39
  "uuid": "^9.0.0",
40
  "yaml": "^2.3.1"
41
  }
 
30
  "fs-extra": "^11.1.1",
31
  "gpt-tokens": "^1.1.1",
32
  "node-fetch": "^3.3.1",
33
+ "nodejs-whisper": "^0.1.4",
34
  "openai": "^3.3.0",
35
  "puppeteer": "^20.8.0",
36
  "resize-base64": "^1.0.12",
37
  "sharp": "^0.32.4",
38
  "temp-dir": "^3.0.0",
39
  "ts-node": "^10.9.1",
40
+ "tts-react": "^3.0.1",
41
  "uuid": "^9.0.0",
42
  "yaml": "^2.3.1"
43
  }
src/index.mts CHANGED
@@ -3,7 +3,7 @@ import path from "node:path"
3
 
4
  import { validate as uuidValidate } from "uuid"
5
  import express from "express"
6
- import { Video, VideoStatus, VideoAPIRequest, RenderRequest, RenderedScene, ImageAnalysisRequest, ImageAnalysisResponse } from "./types.mts"
7
 
8
  import { parseVideoRequest } from "./utils/parseVideoRequest.mts"
9
  import { savePendingVideo } from "./scheduler/savePendingVideo.mts"
@@ -23,6 +23,7 @@ import { getRenderedScene, renderScene } from "./production/renderScene.mts"
23
  import { parseRenderRequest } from "./utils/parseRenderRequest.mts"
24
  import { loadRenderedSceneFromCache } from "./utils/loadRenderedSceneFromCache.mts"
25
  import { analyzeImage } from "./analysis/analyzeImageWithIDEFICSAndNastyHack.mts"
 
26
 
27
  initFolders()
28
  // to disable all processing (eg. to debug)
@@ -75,9 +76,55 @@ app.post("/analyze", async (req, res) => {
75
  try {
76
  response.result = await analyzeImage(request.image, request.prompt)
77
  } catch (err) {
78
- console.log("failed to render scene!")
79
  console.log(err)
80
- response.error = `failed to render scene: ${err}`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  if (response.error.length > 0) {
 
3
 
4
  import { validate as uuidValidate } from "uuid"
5
  import express from "express"
6
+ import { Video, VideoStatus, VideoAPIRequest, RenderRequest, RenderedScene, ImageAnalysisRequest, ImageAnalysisResponse, SoundAnalysisResponse, SoundAnalysisRequest } from "./types.mts"
7
 
8
  import { parseVideoRequest } from "./utils/parseVideoRequest.mts"
9
  import { savePendingVideo } from "./scheduler/savePendingVideo.mts"
 
23
  import { parseRenderRequest } from "./utils/parseRenderRequest.mts"
24
  import { loadRenderedSceneFromCache } from "./utils/loadRenderedSceneFromCache.mts"
25
  import { analyzeImage } from "./analysis/analyzeImageWithIDEFICSAndNastyHack.mts"
26
+ import { speechToText } from "./speechToText/speechToTextWithWhisperLib.mts"
27
 
28
  initFolders()
29
  // to disable all processing (eg. to debug)
 
76
  try {
77
  response.result = await analyzeImage(request.image, request.prompt)
78
  } catch (err) {
79
+ console.log("failed to analyze the image!")
80
  console.log(err)
81
+ response.error = `failed to analyze the image: ${err}`
82
+ }
83
+
84
+ if (response.error.length > 0) {
85
+ // console.log("server error")
86
+ res.status(500)
87
+ res.write(JSON.stringify(response))
88
+ res.end()
89
+ return
90
+ } else {
91
+ // console.log("all good")
92
+ res.status(200)
93
+ res.write(JSON.stringify(response))
94
+ res.end()
95
+ return
96
+ }
97
+ })
98
+
99
+
100
+ // a sound recognition pipeline
101
+ app.post("/listen", async (req, res) => {
102
+
103
+ const request = req.body as SoundAnalysisRequest
104
+
105
+ if (!request.sound) {
106
+ console.log("Invalid sound")
107
+ res.status(400)
108
+ res.write(JSON.stringify({ result: "", error: "invalid sound" }))
109
+ res.end()
110
+ return
111
+ }
112
+
113
+ console.log("/listen called with: ", {
114
+ sound: request.sound.slice(0, 50)
115
+ })
116
+
117
+ const response: SoundAnalysisResponse = {
118
+ result: "",
119
+ error: ""
120
+ }
121
+
122
+ try {
123
+ response.result = await speechToText(request.sound)
124
+ } catch (err) {
125
+ console.log("failed to listen to the sound!")
126
+ console.log(err)
127
+ response.error = `failed to listen to the sound: ${err}`
128
  }
129
 
130
  if (response.error.length > 0) {
src/speechToText/speechToTextWithWhisperLib.mts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import { nodewhisper } from "nodejs-whisper"
3
+
4
+ import { convertMp3ToWavFilePath } from "../utils/convertMp3ToWavFilePath.mts"
5
+
6
+ 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
+ })
16
+
17
+ console.log(result)
18
+
19
+ return "TODO"
20
+
21
+ }
src/speechToText/speechToTextWithWhisperSpace.mts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import { client } from "@gradio/client"
3
+
4
+ import { convertMp3ToWavBase64 } from "../utils/convertMp3ToWavBase64.mts"
5
+
6
+ const instances: string[] = [
7
+ `${process.env.VC_SPEECH_TO_TEXT_SPACE_API_URL_1 || ""}`,
8
+ ].filter(instance => instance?.length > 0)
9
+
10
+ export async function speechToText(sound: string): Promise<string> {
11
+
12
+ const instance = instances.shift()
13
+ instances.push(instance)
14
+
15
+ const api = await client(instance, {
16
+ hf_token: `${process.env.VC_HF_API_TOKEN}` as any
17
+ })
18
+
19
+ console.log("/speechToText: calling Space..")
20
+
21
+ // TODO try a wav? audio/wav
22
+ const wav = await convertMp3ToWavBase64(sound)
23
+
24
+ // const input = sound
25
+ // const input = Buffer.from(sound, "base64")
26
+ // const input = new Blob([sound], { type: 'audio/mpeg' })
27
+ const input = new Blob([wav], { type: 'audio/wav' })
28
+
29
+ const result = await api.predict("/transcribe", [
30
+ input,
31
+ ])
32
+
33
+ console.log(result)
34
+
35
+ return "TODO"
36
+
37
+ }
src/types.mts CHANGED
@@ -320,6 +320,16 @@ export interface ImageAnalysisResponse {
320
  error?: string
321
  }
322
 
 
 
 
 
 
 
 
 
 
 
323
 
324
  export interface ImageSegmentationRequest {
325
  image: string // in base64
 
320
  error?: string
321
  }
322
 
323
+ export interface SoundAnalysisRequest {
324
+ sound: string // in base64
325
+ prompt: string
326
+ }
327
+
328
+ export interface SoundAnalysisResponse {
329
+ result: string
330
+ error?: string
331
+ }
332
+
333
 
334
  export interface ImageSegmentationRequest {
335
  image: string // in base64
src/utils/computeSecretFingerprint.mts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import { computeSha256 } from "./computeSha256.mts"
2
+
3
+ const secretFingerprint = `${process.env.VC_SECRET_FINGERPRINT || ""}`
4
+
5
+ export function computeSecretFingerprint(input: string) {
6
+ return computeSha256(`${secretFingerprint}_${input}`)
7
+ }
src/utils/convertMp3ToWavBase64.mts ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import path from "node:path"
3
+ import * as fs from "node:fs"
4
+
5
+ import { v4 as uuidv4 } from "uuid"
6
+ import tmpDir from "temp-dir"
7
+ import ffmpeg from "fluent-ffmpeg"
8
+
9
+ export function convertMp3ToWavBase64(base64: string) : Promise<string> {
10
+ return new Promise((resolve, reject) => {
11
+
12
+ const inputPath = path.join(tmpDir, `${uuidv4()}.mp3`)
13
+ const outputPath = path.join(tmpDir, `${uuidv4()}.wav`)
14
+
15
+ const base64Header = 'data:audio/mpeg;base64,';
16
+
17
+ fs.writeFile(inputPath, base64.replace(base64Header, ''), { encoding: 'base64' }, (writeError) => {
18
+ if (writeError) {
19
+ reject(writeError);
20
+ return;
21
+ }
22
+
23
+ ffmpeg(inputPath)
24
+ .output(outputPath)
25
+ .on('end', () => {
26
+ fs.readFile(outputPath, { encoding: 'base64' }, (readError, data) => {
27
+ if (readError) {
28
+ reject(readError);
29
+ return;
30
+ }
31
+ resolve(`data:audio/wav;base64,${data}`);
32
+ fs.promises.unlink(inputPath);
33
+ fs.promises.unlink(outputPath);
34
+ });
35
+ })
36
+ .on('error', (conversionError) => {
37
+ reject(conversionError);
38
+ })
39
+ .run();
40
+ });
41
+ });
42
+ }
src/utils/convertMp3ToWavFilePath.mts ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import path from "node:path"
3
+ import * as fs from "node:fs"
4
+
5
+ import { v4 as uuidv4 } from "uuid"
6
+ import tmpDir from "temp-dir"
7
+ import ffmpeg from "fluent-ffmpeg"
8
+
9
+ export function convertMp3ToWavFilePath(base64: string) : Promise<string> {
10
+ return new Promise((resolve, reject) => {
11
+
12
+ // this one will be deleted at the end
13
+ const tmpInputPath = path.join(tmpDir, `${uuidv4()}.mp3`)
14
+
15
+ const tmpOutputPath = path.join(tmpDir, `${uuidv4()}.wav`)
16
+
17
+ const base64Header = 'data:audio/mpeg;base64,';
18
+
19
+ fs.writeFile(tmpInputPath, base64.replace(base64Header, ''), { encoding: 'base64' }, (writeError) => {
20
+ if (writeError) {
21
+ reject(writeError);
22
+ return;
23
+ }
24
+
25
+ ffmpeg(tmpInputPath)
26
+ .output(tmpOutputPath)
27
+ .on('end', () => {
28
+ fs.promises.unlink(tmpInputPath)
29
+ resolve(tmpOutputPath)
30
+
31
+ })
32
+ .on('error', (conversionError) => {
33
+ reject(conversionError);
34
+ })
35
+ .run();
36
+ });
37
+ });
38
+ }