Compare commits
33 Commits
v0.0.1
...
0c5c1f647c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c5c1f647c | ||
|
|
77ad40b61a | ||
|
|
09894c4fd0 | ||
|
|
3e2e1e2ff8 | ||
|
|
50058037eb | ||
|
|
a483aaf25c | ||
|
|
be7d85f85e | ||
|
|
60d38c4d5c | ||
|
|
e3a7628acf | ||
|
|
91c7791860 | ||
|
|
247edd2ced | ||
|
|
edd94aef72 | ||
|
|
b4d3e5a27c | ||
|
|
a1436e3bd2 | ||
|
|
410769b8c6 | ||
|
|
5869016de6 | ||
|
|
0955f6c0c0 | ||
|
|
242f4407df | ||
|
|
814a8ae2f3 | ||
|
|
7c369e72d4 | ||
|
|
0aff4f556b | ||
|
|
88bf54d022 | ||
|
|
63fe8e7e9e | ||
|
|
e26e700a21 | ||
|
|
fa23e396f1 | ||
|
|
11789a5c98 | ||
|
|
97006d95c8 | ||
|
|
bb578e98f6 | ||
|
|
465193b60d | ||
|
|
0e6c12a94f | ||
|
|
599f9079d3 | ||
|
|
0805bb6fd8 | ||
|
|
b109b0144d |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,7 @@
|
|||||||
**/*.sw*
|
**/*.sw*
|
||||||
/whisper-cpp-2023/rust.d/target
|
/whisper-cpp-2023/rust.d/target
|
||||||
|
/rust-whisper.d/target
|
||||||
|
/rust-whisper.d/models
|
||||||
snowboy-2022/snowboy
|
snowboy-2022/snowboy
|
||||||
**/*.git.d
|
**/*.git.d
|
||||||
**/*.wav
|
**/*.wav
|
||||||
|
|||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "rust-whisper.d/gitea-whisper-rs"]
|
||||||
|
path = rust-whisper.d/gitea-whisper-rs
|
||||||
|
url = https://gitea.inhome.blapointe.com/bel/whisper-rs.git
|
||||||
@@ -3,16 +3,49 @@
|
|||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "addr2line"
|
||||||
version = "1.1.0"
|
version = "0.21.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
|
||||||
|
dependencies = [
|
||||||
|
"gimli",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "backtrace"
|
||||||
|
version = "0.3.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
|
||||||
|
dependencies = [
|
||||||
|
"addr2line",
|
||||||
|
"cc",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
|
"object",
|
||||||
|
"rustc-demangle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bindgen"
|
name = "bindgen"
|
||||||
version = "0.64.0"
|
version = "0.68.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4"
|
checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
@@ -21,6 +54,7 @@ dependencies = [
|
|||||||
"lazycell",
|
"lazycell",
|
||||||
"log",
|
"log",
|
||||||
"peeking_take_while",
|
"peeking_take_while",
|
||||||
|
"prettyplease",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
@@ -32,9 +66,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "2.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.83"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cexpr"
|
name = "cexpr"
|
||||||
@@ -63,10 +106,41 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "cmake"
|
||||||
version = "1.8.1"
|
version = "0.1.50"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fs_extra"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gimli"
|
||||||
|
version = "0.28.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glob"
|
name = "glob"
|
||||||
@@ -74,6 +148,15 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "home"
|
||||||
|
version = "0.5.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -88,9 +171,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.140"
|
version = "0.2.150"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
@@ -103,19 +186,22 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.17"
|
version = "0.4.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
[[package]]
|
||||||
]
|
name = "log"
|
||||||
|
version = "0.4.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.5.0"
|
version = "2.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minimal-lexical"
|
name = "minimal-lexical"
|
||||||
@@ -123,6 +209,15 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
|
||||||
|
dependencies = [
|
||||||
|
"adler",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "7.1.3"
|
version = "7.1.3"
|
||||||
@@ -134,10 +229,19 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "object"
|
||||||
version = "1.17.1"
|
version = "0.32.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "peeking_take_while"
|
name = "peeking_take_while"
|
||||||
@@ -147,42 +251,66 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.9"
|
version = "0.2.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prettyplease"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.54"
|
version = "1.0.70"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534"
|
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.26"
|
version = "1.0.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.7.3"
|
version = "1.10.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
|
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.6.29"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "riff"
|
name = "riff"
|
||||||
@@ -199,6 +327,12 @@ dependencies = [
|
|||||||
"whisper-rs",
|
"whisper-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-demangle"
|
||||||
|
version = "0.1.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -206,16 +340,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "rustix"
|
||||||
version = "1.1.0"
|
version = "0.38.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.109"
|
version = "2.0.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -224,20 +371,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.27.0"
|
version = "1.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
|
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"backtrace",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"windows-sys",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.8"
|
version = "1.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wav"
|
name = "wav"
|
||||||
@@ -250,31 +396,31 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "which"
|
name = "which"
|
||||||
version = "4.4.0"
|
version = "4.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
"libc",
|
"home",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"rustix",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "whisper-rs"
|
name = "whisper-rs"
|
||||||
version = "0.5.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fa7e1b9b003aa3285a0e4469219566266aa1d51ced1be38587251a4f713a1677"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"whisper-rs-sys",
|
"whisper-rs-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "whisper-rs-sys"
|
name = "whisper-rs-sys"
|
||||||
version = "0.3.1"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97a389dc665c7354ba6b1982850d4ba05b862907e535708ebdec92cbd9c599e8"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
|
"cfg-if",
|
||||||
|
"cmake",
|
||||||
|
"fs_extra",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -301,18 +447,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.45.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
|
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc",
|
||||||
@@ -325,42 +471,42 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.42.2"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
@@ -6,6 +6,9 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
whisper-rs = "0.5"
|
whisper-rs = "0.8.0"
|
||||||
wav = "1"
|
wav = "1"
|
||||||
tokio = "1.27"
|
tokio = "1.27"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
whisper-rs = { path = "./gitea-whisper-rs" }
|
||||||
1
rust-whisper.d/gitea-whisper-rs
Submodule
1
rust-whisper.d/gitea-whisper-rs
Submodule
Submodule rust-whisper.d/gitea-whisper-rs added at dd62f2b9f6
@@ -47,37 +47,60 @@ class Reader(threading.Thread):
|
|||||||
self.name = os.environ.get("MIC_NAME", "pulse_monitor")
|
self.name = os.environ.get("MIC_NAME", "pulse_monitor")
|
||||||
if not self.name:
|
if not self.name:
|
||||||
for index, name in enumerate(sr.Microphone.list_microphone_names()):
|
for index, name in enumerate(sr.Microphone.list_microphone_names()):
|
||||||
print("[{0}] Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name))
|
log("[{0}] Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name))
|
||||||
exit()
|
exit()
|
||||||
self.inq = inq
|
self.inq = inq
|
||||||
self.outq = outq
|
self.outq = outq
|
||||||
|
|
||||||
def run(self):
|
def mic_idx(self):
|
||||||
log("Reader.run: start")
|
mics = []
|
||||||
try:
|
while not mics and not self.should_stop():
|
||||||
idx = [
|
log(f'searching for one of {self.name.split(",")} in {sr.Microphone.list_microphone_names()}...')
|
||||||
|
time.sleep(1)
|
||||||
|
mics = [
|
||||||
idx for idx,v in enumerate(
|
idx for idx,v in enumerate(
|
||||||
sr.Microphone.list_microphone_names(),
|
sr.Microphone.list_microphone_names(),
|
||||||
) if v in self.name.split(",")
|
) if v in self.name.split(",")
|
||||||
][0]
|
]
|
||||||
with sr.Microphone(device_index=idx) as mic:
|
log("mic#", mics[0])
|
||||||
while not self.should_stop():
|
return mics[0]
|
||||||
|
|
||||||
|
def run(self):
|
||||||
try:
|
try:
|
||||||
self.outq.put(self._run(mic))
|
log("Reader.run: start")
|
||||||
|
self._run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not "timed out" in str(e):
|
log("Reader:run: exit:", e)
|
||||||
log("Reader.run: error:", e)
|
|
||||||
except Exception as e:
|
|
||||||
log("Reader.run panic:", e)
|
|
||||||
log("microphones:", sr.Microphone.list_microphone_names())
|
|
||||||
finally:
|
finally:
|
||||||
self.outq.put(None)
|
self.outq.put(None)
|
||||||
log("Reader.run: stop")
|
log("Reader.run: stop")
|
||||||
|
|
||||||
|
def _run(self):
|
||||||
|
while not self.should_stop():
|
||||||
|
time.sleep(3)
|
||||||
|
mic = sr.Microphone(device_index=self.mic_idx())
|
||||||
|
try:
|
||||||
|
mic.__enter__()
|
||||||
|
while not self.should_stop():
|
||||||
|
try:
|
||||||
|
self.outq.put(self.read(mic))
|
||||||
|
except Exception as e:
|
||||||
|
if not "timed out" in str(e):
|
||||||
|
raise e
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exception(e)
|
||||||
|
log("Reader.run: error:", e)
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
mic.__exit__(None, None, None)
|
||||||
|
except Exception as e:
|
||||||
|
log("Reader.run.catch: error:", e)
|
||||||
|
|
||||||
def should_stop(self):
|
def should_stop(self):
|
||||||
return not self.inq.empty()
|
return not self.inq.empty()
|
||||||
|
|
||||||
def _run(self, mic):
|
def read(self, mic):
|
||||||
mic_timeout = int(os.environ.get("MIC_TIMEOUT", 5))
|
mic_timeout = int(os.environ.get("MIC_TIMEOUT", 5))
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
return r.listen(
|
return r.listen(
|
||||||
@@ -113,13 +136,19 @@ class Parser(threading.Thread):
|
|||||||
p = "/tmp/whisper-cpp.wav"
|
p = "/tmp/whisper-cpp.wav"
|
||||||
with open("/tmp/whisper-cpp.wav", "wb") as f:
|
with open("/tmp/whisper-cpp.wav", "wb") as f:
|
||||||
f.write(wav)
|
f.write(wav)
|
||||||
proc = subprocess.run(f"MODEL=./models/ggml-{os.environ.get('MODEL','tiny.en')}.bin WAV={p} P=2 rust-whisper", capture_output=True, shell=True)
|
proc = subprocess.run(f"MODEL=./models/ggml-{os.environ.get('MODEL','tiny.en')}.bin WAV={p} P={os.environ.get('P', '2')} rust-whisper", capture_output=True, shell=True)
|
||||||
result = proc.stdout.decode().strip()
|
result = proc.stdout.decode().strip()
|
||||||
if os.environ.get("DEBUG", None):
|
if os.environ.get("DEBUG", None):
|
||||||
|
log("stderr:", proc.stderr.decode().strip())
|
||||||
log("raw transcript:", result)
|
log("raw transcript:", result)
|
||||||
result = result.replace(">>", "")
|
result = result.replace(">>", "")
|
||||||
result = "".join([i.split("]")[-1] for i in result.split("[")[0]])
|
for pair in [
|
||||||
result = "".join([i.split(")")[-1] for i in result.split("(")[0]])
|
("[", "]"),
|
||||||
|
("(", ")"),
|
||||||
|
("<", ">"),
|
||||||
|
("*", "*"),
|
||||||
|
]:
|
||||||
|
result = "".join([i.split(pair[1])[-1] for i in result.split(pair[0])[0]])
|
||||||
if os.environ.get("DEBUG", None):
|
if os.environ.get("DEBUG", None):
|
||||||
log("annotation-free transcript:", result)
|
log("annotation-free transcript:", result)
|
||||||
return result
|
return result
|
||||||
@@ -156,6 +185,8 @@ def _load_dot_notation(v, items):
|
|||||||
else:
|
else:
|
||||||
result.append(subresult)
|
result.append(subresult)
|
||||||
return result
|
return result
|
||||||
|
elif k == "KEYS":
|
||||||
|
v = [k for k in v]
|
||||||
else:
|
else:
|
||||||
if isinstance(v, list):
|
if isinstance(v, list):
|
||||||
v = v[int(k)]
|
v = v[int(k)]
|
||||||
@@ -200,8 +231,15 @@ class Reactor(threading.Thread):
|
|||||||
def load_hotwords_in_yaml_file():
|
def load_hotwords_in_yaml_file():
|
||||||
with open(p.split("@")[0], "r") as f:
|
with open(p.split("@")[0], "r") as f:
|
||||||
v = yaml.safe_load(f)
|
v = yaml.safe_load(f)
|
||||||
v = load_dot_notation(v, p.split("@")[-1])
|
if os.environ.get("DEBUG", None):
|
||||||
return ["".join(i.strip().lower().split()) for i in v if i]
|
log(f'opened {p.split("@")[0]} and got {v}')
|
||||||
|
result = []
|
||||||
|
for to_find in [i for i in p.split("@")[-1].split(",") if i]:
|
||||||
|
if os.environ.get("DEBUG", None):
|
||||||
|
log(f'finding {to_find} in {v}')
|
||||||
|
v2 = load_dot_notation(v, to_find)
|
||||||
|
result.extend(["".join(i.strip().lower().split()) for i in v2 if i])
|
||||||
|
return result
|
||||||
load_hotwords_in_yaml_file()
|
load_hotwords_in_yaml_file()
|
||||||
return load_hotwords_in_yaml_file
|
return load_hotwords_in_yaml_file
|
||||||
else:
|
else:
|
||||||
@@ -230,13 +268,23 @@ class Reactor(threading.Thread):
|
|||||||
log("Reactor.run: stop")
|
log("Reactor.run: stop")
|
||||||
|
|
||||||
def handle(self, text):
|
def handle(self, text):
|
||||||
|
try:
|
||||||
|
self._handle(text)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _handle(self, text):
|
||||||
hotwords = self.load_hotwords()
|
hotwords = self.load_hotwords()
|
||||||
if os.environ.get("DEBUG", None):
|
if os.environ.get("DEBUG", None):
|
||||||
log(f"seeking {hotwords} in {text}")
|
log(f"seeking {hotwords} in {text}. $HOTWORDS={os.environ.get('HOTWORDS', None)}")
|
||||||
if not hotwords:
|
if not hotwords:
|
||||||
if not os.environ.get("HOTWORDS", None):
|
if not os.environ.get("HOTWORDS", None):
|
||||||
print(text)
|
if os.environ.get("DEBUG", None):
|
||||||
|
log(f"HOTWORDS is False; {text}")
|
||||||
|
print(text, flush=True)
|
||||||
else:
|
else:
|
||||||
|
if os.environ.get("DEBUG", None):
|
||||||
|
log(f"HOTWORDS is True; {text}")
|
||||||
log(text)
|
log(text)
|
||||||
return
|
return
|
||||||
cleantext = "".join([i for i in "".join(text.lower().split()) if i.isalpha()])
|
cleantext = "".join([i for i in "".join(text.lower().split()) if i.isalpha()])
|
||||||
@@ -256,7 +304,7 @@ class Actor(threading.Thread):
|
|||||||
self.pid = int(environ["SIGUSR2"])
|
self.pid = int(environ["SIGUSR2"])
|
||||||
self.handle = self.handle_signal
|
self.handle = self.handle_signal
|
||||||
elif os.environ.get("URL", ""):
|
elif os.environ.get("URL", ""):
|
||||||
self.url = environ["URL"]
|
self.url = os.environ["URL"]
|
||||||
self.handle = self.handle_url
|
self.handle = self.handle_url
|
||||||
self.headers = [i.split("=")[:2] for i in os.environ.get("HEADERS", "").split("//") if i]
|
self.headers = [i.split("=")[:2] for i in os.environ.get("HEADERS", "").split("//") if i]
|
||||||
self.body = os.environ.get("BODY", '{"hotword":"{{hotword}}","context":"{{context}}"}')
|
self.body = os.environ.get("BODY", '{"hotword":"{{hotword}}","context":"{{context}}"}')
|
||||||
@@ -276,7 +324,7 @@ class Actor(threading.Thread):
|
|||||||
|
|
||||||
def handle_stdout(self, hotword, context):
|
def handle_stdout(self, hotword, context):
|
||||||
log(context)
|
log(context)
|
||||||
print(hotword)
|
print(hotword, flush=True)
|
||||||
|
|
||||||
def handle_signal(self, hotword, context):
|
def handle_signal(self, hotword, context):
|
||||||
self.handle_stderr(hotword, context)
|
self.handle_stderr(hotword, context)
|
||||||
@@ -295,9 +343,12 @@ class Actor(threading.Thread):
|
|||||||
body = self.body
|
body = self.body
|
||||||
body = body.replace("{{hotword}}", hotword)
|
body = body.replace("{{hotword}}", hotword)
|
||||||
body = body.replace("{{context}}", context)
|
body = body.replace("{{context}}", context)
|
||||||
|
url = self.url
|
||||||
|
url = url.replace("{{hotword}}", hotword)
|
||||||
|
url = url.replace("{{context}}", context)
|
||||||
if os.environ.get("DEBUG", "") :
|
if os.environ.get("DEBUG", "") :
|
||||||
log("POST", self.url, headers, body)
|
log("POST", url, headers, body)
|
||||||
requests.post(self.url, headers=headers, data=body)
|
requests.post(url, headers=headers, data=body)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log("Actor.handle_url:", e)
|
log("Actor.handle_url:", e)
|
||||||
|
|
||||||
9
rust-whisper.d/models/download_models.sh
Executable file
9
rust-whisper.d/models/download_models.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
src="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml"
|
||||||
|
cd "$(dirname "$(realpath "$BASH_SOURCE")")"
|
||||||
|
|
||||||
|
# Whisper models
|
||||||
|
for model in "tiny.en" "base.en" "small.en" "medium.en"; do
|
||||||
|
test -f ./ggml-$model.bin || wget --quiet --show-progress -O ./ggml-$model.bin "$src-$model.bin"
|
||||||
|
done
|
||||||
@@ -2,3 +2,4 @@ git+https://github.com/openai/whisper.git
|
|||||||
soundfile
|
soundfile
|
||||||
PyAudio
|
PyAudio
|
||||||
SpeechRecognition
|
SpeechRecognition
|
||||||
|
PyYAML
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
use whisper_rs::{WhisperContext, FullParams, SamplingStrategy};
|
use whisper_rs::{WhisperContext, FullParams, SamplingStrategy};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut ctx = WhisperContext::new(
|
let ctx = WhisperContext::new(
|
||||||
&std::env::var("MODEL").unwrap_or(String::from("../models/ggml-tiny.en.bin"))
|
&std::env::var("MODEL").unwrap_or(String::from("../models/ggml-tiny.en.bin"))
|
||||||
).expect("failed to load model");
|
).expect("failed to load model");
|
||||||
|
let mut state = ctx.create_state().expect("failed to create state");
|
||||||
|
|
||||||
// create a params object
|
// create a params object
|
||||||
let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 0 });
|
let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 0 });
|
||||||
@@ -25,12 +26,11 @@ fn main() {
|
|||||||
let data16 = data.as_sixteen().expect("wav is not 32bit floats");
|
let data16 = data.as_sixteen().expect("wav is not 32bit floats");
|
||||||
let audio_data = &whisper_rs::convert_integer_to_float_audio(&data16);
|
let audio_data = &whisper_rs::convert_integer_to_float_audio(&data16);
|
||||||
|
|
||||||
ctx.full(params, &audio_data[..])
|
state.full(params, &audio_data[..]).expect("failed to run model");
|
||||||
.expect("failed to run model");
|
|
||||||
|
|
||||||
let num_segments = ctx.full_n_segments();
|
let num_segments = state.full_n_segments().expect("failed to get number of segments");
|
||||||
for i in 0..num_segments {
|
for i in 0..num_segments {
|
||||||
let segment = ctx.full_get_segment_text(i).expect("failed to get segment");
|
let segment = state.full_get_segment_text(i).expect("failed to get segment");
|
||||||
print!("{} ", segment);
|
print!("{} ", segment);
|
||||||
}
|
}
|
||||||
println!("");
|
println!("");
|
||||||
2
rust-whisper.d/transcript.sh
Normal file
2
rust-whisper.d/transcript.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
echo "pkill -9 -f hotwords.py; MIC_TIMEOUT=30 MODEL=small.en P=4 DEBUG=true HOTWORDS= python3 ./hotwords.py | tee -a $HOME/Sync/drawful/DnD/bdoob/__log.d/$(date +%Y.%m.%d).transcript.txt"
|
||||||
|
echo "pkill -9 -f hotwords.py; MIC_TIMEOUT=30 MODEL=small.en P=4 DEBUG=true HOTWORDS= python3 ./hotwords.py | tee -a $HOME/Sync/drawful/DnD/nessira.d/_log.d/$(date +%Y.%m.%d).transcript.txt"
|
||||||
@@ -1,304 +0,0 @@
|
|||||||
import speech_recognition as sr
|
|
||||||
import time
|
|
||||||
import threading
|
|
||||||
import queue
|
|
||||||
import signal
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import requests
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
def log(*args):
|
|
||||||
print(">", *args, file=sys.stderr)
|
|
||||||
|
|
||||||
class Piper(threading.Thread):
|
|
||||||
def __init__(self, inq, outq):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.inq = inq
|
|
||||||
self.outq = outq
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
while True:
|
|
||||||
got = self.inq.get()
|
|
||||||
if got is None:
|
|
||||||
break
|
|
||||||
self._run(got)
|
|
||||||
self.outq.put(None)
|
|
||||||
|
|
||||||
class Manager(threading.Thread):
|
|
||||||
def __init__(self, outq):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.outq = outq
|
|
||||||
inq = queue.Queue()
|
|
||||||
def catcher(sig, frame):
|
|
||||||
inq.put(None)
|
|
||||||
self.inq = inq
|
|
||||||
signal.signal(signal.SIGINT, catcher)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
log("Manager.run: start")
|
|
||||||
self.inq.get()
|
|
||||||
self.outq.put(None)
|
|
||||||
log("Manager.run: stop")
|
|
||||||
|
|
||||||
class Reader(threading.Thread):
|
|
||||||
def __init__(self, inq, outq):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.name = os.environ.get("MIC_NAME", "pulse_monitor")
|
|
||||||
if not self.name:
|
|
||||||
for index, name in enumerate(sr.Microphone.list_microphone_names()):
|
|
||||||
print("[{0}] Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name))
|
|
||||||
exit()
|
|
||||||
self.inq = inq
|
|
||||||
self.outq = outq
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
log("Reader.run: start")
|
|
||||||
try:
|
|
||||||
idx = [
|
|
||||||
idx for idx,v in enumerate(
|
|
||||||
sr.Microphone.list_microphone_names(),
|
|
||||||
) if v in self.name.split(",")
|
|
||||||
][0]
|
|
||||||
with sr.Microphone(device_index=idx) as mic:
|
|
||||||
while not self.should_stop():
|
|
||||||
try:
|
|
||||||
self.outq.put(self._run(mic))
|
|
||||||
except Exception as e:
|
|
||||||
if not "timed out" in str(e):
|
|
||||||
log("Reader.run: error:", e)
|
|
||||||
except Exception as e:
|
|
||||||
log("Reader.run panic:", e)
|
|
||||||
log("microphones:", sr.Microphone.list_microphone_names())
|
|
||||||
finally:
|
|
||||||
self.outq.put(None)
|
|
||||||
log("Reader.run: stop")
|
|
||||||
|
|
||||||
def should_stop(self):
|
|
||||||
return not self.inq.empty()
|
|
||||||
|
|
||||||
def _run(self, mic):
|
|
||||||
mic_timeout = int(os.environ.get("MIC_TIMEOUT", 5))
|
|
||||||
r = sr.Recognizer()
|
|
||||||
return r.listen(
|
|
||||||
mic,
|
|
||||||
timeout=mic_timeout,
|
|
||||||
phrase_time_limit=mic_timeout,
|
|
||||||
)
|
|
||||||
|
|
||||||
class Parser(threading.Thread):
|
|
||||||
def __init__(self, inq, outq):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.inq = inq
|
|
||||||
self.outq = outq
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
log("Parser.run: start")
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
clip = self.inq.get()
|
|
||||||
backlog = self.inq.qsize()
|
|
||||||
if backlog:
|
|
||||||
log("Parser.run backlog", backlog)
|
|
||||||
if clip is None:
|
|
||||||
break
|
|
||||||
self.outq.put(self._run(clip).strip())
|
|
||||||
except Exception as e:
|
|
||||||
log("Parser.run: error:", e)
|
|
||||||
self.outq.put(None)
|
|
||||||
log("Parser.run: stop")
|
|
||||||
|
|
||||||
def _run(self, clip):
|
|
||||||
r = sr.Recognizer()
|
|
||||||
return r.recognize_whisper(clip, language="english", model=os.environ.get("MODEL", "small.en")) # tiny.en=32x, base.en=16x, small.en=6x, medium.en=x2
|
|
||||||
|
|
||||||
def load_dot_notation(v, s):
|
|
||||||
items = s.replace("[]", ".[]").split(".")
|
|
||||||
return _load_dot_notation(v, items)
|
|
||||||
|
|
||||||
def _load_dot_notation(v, items):
|
|
||||||
for i in range(len(items)):
|
|
||||||
k = items[i]
|
|
||||||
if not k:
|
|
||||||
continue
|
|
||||||
if k == "[]":
|
|
||||||
if isinstance(v, list):
|
|
||||||
result = []
|
|
||||||
for j in v:
|
|
||||||
subresult = _load_dot_notation(j, items[i+1:])
|
|
||||||
if isinstance(subresult, list):
|
|
||||||
result.extend(subresult)
|
|
||||||
else:
|
|
||||||
result.append(subresult)
|
|
||||||
return result
|
|
||||||
else:
|
|
||||||
result = []
|
|
||||||
for j in v.values():
|
|
||||||
subresult = _load_dot_notation(j, items[i+1:])
|
|
||||||
if isinstance(subresult, list):
|
|
||||||
result.extend(subresult)
|
|
||||||
else:
|
|
||||||
result.append(subresult)
|
|
||||||
return result
|
|
||||||
else:
|
|
||||||
if isinstance(v, list):
|
|
||||||
v = v[int(k)]
|
|
||||||
else:
|
|
||||||
v = v[k]
|
|
||||||
return v
|
|
||||||
|
|
||||||
def test_load_dot_notation():
|
|
||||||
for i in [
|
|
||||||
"a" == load_dot_notation("a", "."),
|
|
||||||
["a"] == load_dot_notation(["a"], "."),
|
|
||||||
"b" == load_dot_notation({"a":"b"}, ".a"),
|
|
||||||
"c" == load_dot_notation({"a":{"b":"c"}}, ".a.b"),
|
|
||||||
"c" == load_dot_notation({"a":{"b":["c"]}}, ".a.b.0"),
|
|
||||||
["c","d"] == load_dot_notation({"a":{"b":"c"}, "a2":{"b":"d"}}, ".[].b"),
|
|
||||||
["c","d"] == load_dot_notation({"a":{"b":["c"], "b2":["d"]}}, ".a.[].0"),
|
|
||||||
["c","d"] == load_dot_notation({"a":{"b":["c"], "b2":["d"]}}, ".a[].0"),
|
|
||||||
["c","d"] == load_dot_notation(["c", "d"], "."),
|
|
||||||
["c","d"] == load_dot_notation(["c", "d"], "[]"),
|
|
||||||
]:
|
|
||||||
if not i:
|
|
||||||
raise Exception(i)
|
|
||||||
test_load_dot_notation()
|
|
||||||
|
|
||||||
class Reactor(threading.Thread):
|
|
||||||
def __init__(self, inq, outq):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.inq = inq
|
|
||||||
self.outq = outq
|
|
||||||
self.load_hotwords = Reactor.new_load_hotwords()
|
|
||||||
log(f"hotwords: {self.load_hotwords()}")
|
|
||||||
|
|
||||||
def new_load_hotwords():
|
|
||||||
p = os.environ.get("HOTWORDS", None)
|
|
||||||
if not p:
|
|
||||||
def load_nothing():
|
|
||||||
return []
|
|
||||||
return load_nothing
|
|
||||||
|
|
||||||
try:
|
|
||||||
if "@" in p:
|
|
||||||
def load_hotwords_in_yaml_file():
|
|
||||||
with open(p.split("@")[0], "r") as f:
|
|
||||||
v = yaml.safe_load(f)
|
|
||||||
v = load_dot_notation(v, p.split("@")[-1])
|
|
||||||
return ["".join(i.strip().lower().split()) for i in v if i]
|
|
||||||
load_hotwords_in_yaml_file()
|
|
||||||
return load_hotwords_in_yaml_file
|
|
||||||
else:
|
|
||||||
def load_hotwords_in_file():
|
|
||||||
with open(p, "r") as f:
|
|
||||||
return ["".join(i.strip().lower().split()) for i in f.readlines()]
|
|
||||||
load_hotwords_in_file()
|
|
||||||
return load_hotwords_in_file
|
|
||||||
except Exception as e:
|
|
||||||
log(f"$HOTWORDS {p} is not a file: {e}")
|
|
||||||
|
|
||||||
hotwords = ["".join(i.lower().strip().split()) for i in p.split("\/\/")]
|
|
||||||
log(f'$HOTWORDS: {hotwords}')
|
|
||||||
def load_hotwords_as_literal():
|
|
||||||
return hotwords
|
|
||||||
return load_hotwords_as_literal
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
log("Reactor.run: start")
|
|
||||||
while True:
|
|
||||||
text = self.inq.get()
|
|
||||||
if text is None:
|
|
||||||
break
|
|
||||||
self.handle(text)
|
|
||||||
self.outq.put(None)
|
|
||||||
log("Reactor.run: stop")
|
|
||||||
|
|
||||||
def handle(self, text):
|
|
||||||
hotwords = self.load_hotwords()
|
|
||||||
if os.environ.get("DEBUG", None):
|
|
||||||
log(f"seeking {hotwords} in {text}")
|
|
||||||
if not hotwords:
|
|
||||||
if not os.environ.get("HOTWORDS", None):
|
|
||||||
print(text)
|
|
||||||
else:
|
|
||||||
log(text)
|
|
||||||
return
|
|
||||||
cleantext = "".join([i for i in "".join(text.lower().split()) if i.isalpha()])
|
|
||||||
for i in hotwords:
|
|
||||||
if i in cleantext:
|
|
||||||
#log(f"Reactor.handle: found hotword '{i}' in '{text}' as '{cleantext}'")
|
|
||||||
self.outq.put((i, text))
|
|
||||||
|
|
||||||
class Actor(threading.Thread):
|
|
||||||
def __init__(self, inq):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.inq = inq
|
|
||||||
self.handle = self.handle_stderr
|
|
||||||
if os.environ.get("STDOUT", "") == "true":
|
|
||||||
self.handle = self.handle_stdout
|
|
||||||
elif os.environ.get("SIGUSR2", ""):
|
|
||||||
self.pid = int(environ["SIGUSR2"])
|
|
||||||
self.handle = self.handle_signal
|
|
||||||
elif os.environ.get("URL", ""):
|
|
||||||
self.url = environ["URL"]
|
|
||||||
self.handle = self.handle_url
|
|
||||||
self.headers = [i.split("=")[:2] for i in os.environ.get("HEADERS", "").split("//") if i]
|
|
||||||
self.body = os.environ.get("BODY", '{"hotword":"{{hotword}}","context":"{{context}}"}')
|
|
||||||
log(self.headers)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
log("Actor.run: start")
|
|
||||||
while True:
|
|
||||||
got = self.inq.get()
|
|
||||||
if got is None:
|
|
||||||
break
|
|
||||||
self.handle(got[0], got[1])
|
|
||||||
log("Actor.run: stop")
|
|
||||||
|
|
||||||
def handle_stderr(self, hotword, context):
|
|
||||||
log(f"'{hotword}' in '{context}'")
|
|
||||||
|
|
||||||
def handle_stdout(self, hotword, context):
|
|
||||||
log(context)
|
|
||||||
print(hotword)
|
|
||||||
|
|
||||||
def handle_signal(self, hotword, context):
|
|
||||||
self.handle_stderr(hotword, context)
|
|
||||||
os.kill(self.pid, signal.SIGUSR2)
|
|
||||||
|
|
||||||
def handle_url(self, hotword, context):
|
|
||||||
self.handle_stderr(hotword, context)
|
|
||||||
try:
|
|
||||||
headers = {}
|
|
||||||
for i in self.headers:
|
|
||||||
key = i[0]
|
|
||||||
value = i[1]
|
|
||||||
value = value.replace("{{hotword}}", hotword)
|
|
||||||
value = value.replace("{{context}}", context)
|
|
||||||
headers[key] = value
|
|
||||||
body = self.body
|
|
||||||
body = body.replace("{{hotword}}", hotword)
|
|
||||||
body = body.replace("{{context}}", context)
|
|
||||||
if os.environ.get("DEBUG", "") :
|
|
||||||
log("POST", self.url, headers, body)
|
|
||||||
requests.post(self.url, headers=headers, data=body)
|
|
||||||
except Exception as e:
|
|
||||||
log("Actor.handle_url:", e)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
managerToParserQ = queue.Queue(maxsize=1)
|
|
||||||
readerToParserQ = queue.Queue(maxsize=10)
|
|
||||||
parserToReactorQ = queue.Queue(maxsize=10)
|
|
||||||
reactorToActorQ = queue.Queue(maxsize=10)
|
|
||||||
threads = [
|
|
||||||
Manager(managerToParserQ),
|
|
||||||
Reader(managerToParserQ, readerToParserQ),
|
|
||||||
Parser(readerToParserQ, parserToReactorQ),
|
|
||||||
Reactor(parserToReactorQ, reactorToActorQ),
|
|
||||||
Actor(reactorToActorQ),
|
|
||||||
]
|
|
||||||
[t.start() for t in threads]
|
|
||||||
[t.join() for t in threads]
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
|
|
||||||
sudo apt install portaudio19-dev python3-pyaudio
|
|
||||||
python3 -m pip install git+https://github.com/openai/whisper.git soundfile PyAudio SpeechRecognition
|
|
||||||
|
|
||||||
#sudo apt-get install python3 python3-all-dev python3-pip build-essential swig git libpulse-dev libasound2-dev
|
|
||||||
#python3 -m pip install pocketsphinx
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
FROM debian:buster as builder
|
|
||||||
|
|
||||||
RUN apt -y update && apt -y install build-essential wget ffmpeg
|
|
||||||
|
|
||||||
WORKDIR /tmp/whisper-cpp.git.d
|
|
||||||
RUN wget https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v1.2.1.tar.gz \
|
|
||||||
&& tar -xf ./*.tar.gz \
|
|
||||||
&& mv ./whisper*/ ./git.d
|
|
||||||
WORKDIR /tmp/whisper-cpp.git.d/git.d
|
|
||||||
RUN make && make samples
|
|
||||||
|
|
||||||
FROM debian:buster
|
|
||||||
RUN apt -y update && apt -y install curl
|
|
||||||
COPY --from=builder /tmp/whisper-cpp.git.d/git.d/ /whisper-cpp.git.d/
|
|
||||||
WORKDIR /whisper.d
|
|
||||||
RUN bash /whisper-cpp.git.d/models/download-ggml-model.sh tiny.en
|
|
||||||
|
|
||||||
ENTRYPOINT []
|
|
||||||
CMD /whisper-cpp.git.d/main -m /whisper-cpp.git.d/models/ggml-tiny.en.bin -f /whisper-cpp.git.d/samples/gb1.wav -t 4
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
git.d/main
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# git.d/samples/mm0.wav (30s)
|
|
||||||
|
|
||||||
| model | threads | rust | c |
|
|
||||||
| ----- | ------- | ------------- | ----------- |
|
|
||||||
| tiny | 1 | 4.4s@122% | 4.9s@125% |
|
|
||||||
| tiny | 2 | 2.7s@210% | 3.3s@190% |
|
|
||||||
| tiny | 4 | 2.0s@- | 2.9s@400% |
|
|
||||||
| tiny | 8 | 2.0s@- | 3.1s@700% |
|
|
||||||
| small | 1 | 23.9s@175% | 28.5s@205% |
|
|
||||||
| small | 2 | 14.9s@347% | 19.2s@330% |
|
|
||||||
| small | 4 | 12.3s@515% | 22.1s@530% |
|
|
||||||
| base | 1 | 8.7s@150% | 10.2s@155% |
|
|
||||||
| base | 2 | 5.1s@240% | 7.1s@270% |
|
|
||||||
| base | 4 | 3.8s@370% | 6.0s@430% |
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
export P=${1:-1}
|
|
||||||
export MODEL=${2:-models/ggml-tiny.en.bin}
|
|
||||||
export WAV=${3:-git.d/samples/jfk.wav}
|
|
||||||
echo === RUST
|
|
||||||
time rust-whisper 2>&1 | grep -v ^whisper_ | grep ..
|
|
||||||
echo === C
|
|
||||||
time ./c-whisper -m $MODEL -f $WAV -t $P 2>&1 | grep -v ^whisper_ | grep -v ^system_info | grep -v ^main: | grep ..
|
|
||||||
Submodule whisper-cpp-2023/git.d deleted from 0a2d1210bc
@@ -1 +0,0 @@
|
|||||||
git.d/libwhisper.a
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
git.d/models
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
|
|
||||||
if [ ! -d ./git.d/.git ]; then
|
|
||||||
git clone https://github.com/ggerganov/whisper.cpp.git git.d
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ./git.d
|
|
||||||
if [ ! -f ./samples/gb1.wav ]; then
|
|
||||||
make samples
|
|
||||||
fi
|
|
||||||
if [ ! -f ./main ]; then
|
|
||||||
make
|
|
||||||
fi
|
|
||||||
if [ ! -f ./stream ]; then
|
|
||||||
make stream
|
|
||||||
fi
|
|
||||||
if [ ! -f ./models/ggml-${MODEL:-tiny.en}.bin ]; then
|
|
||||||
bash ./models/download-ggml-model.sh ${MODEL:-tiny.en}
|
|
||||||
fi
|
|
||||||
if [ -n "$STREAM" ]; then
|
|
||||||
./stream -m ./models/ggml-${MODEL:-tiny.en}.bin -t 8 --step 500 --length ${MIC_TIMEOUT:-2}000 $(test -n "$MIC_ID" && echo -c "$MIC_ID")
|
|
||||||
else
|
|
||||||
time ./main -m ./models/ggml-${MODEL:-tiny.en}.bin -f ./samples/gb1.wav -t 4
|
|
||||||
fi
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
git.d/whisper.h
|
|
||||||
Reference in New Issue
Block a user