apptor-tiny-tts-at v0.1: Austrian accent switch, no eSpeak, browser demo
Browse files- .gitattributes +4 -0
- LICENSE +202 -0
- README.md +135 -0
- apptor-g2p-de.json +347 -0
- apptor-g2p-de.onnx +3 -0
- apptor-tiny-tts-at.json +97 -0
- apptor-tiny-tts-at.onnx +3 -0
- apptor-vocos-de.int8.onnx +3 -0
- samples/hobellied-F2-accent-1.0.wav +3 -0
- samples/hobellied-M2-accent-0.wav +3 -0
- samples/hobellied-M2-accent-1.0.wav +3 -0
- samples/hobellied-M2-accent-1.6.wav +3 -0
- speak.py +148 -0
- tinyvoca/__init__.py +3 -0
- tinyvoca/g2p_de.py +182 -0
- tinyvoca/normalize_de.py +66 -0
- tinyvoca/text.py +281 -0
- web/.htaccess +15 -0
- web/apptor-tts.js +336 -0
- web/austrian-de.json +26 -0
- web/exceptions-de.json +66 -0
- web/frontend-de.json +459 -0
- web/index.html +312 -0
- web/models/apptor-g2p-de.json +347 -0
- web/models/apptor-g2p-de.onnx +3 -0
- web/models/apptor-tiny-tts-at.json +97 -0
- web/models/apptor-tiny-tts-at.onnx +3 -0
- web/models/apptor-vocos-de.int8.onnx +3 -0
- web/ort/LICENSE +23 -0
- web/ort/ort-wasm-simd-threaded.mjs +81 -0
- web/ort/ort-wasm-simd-threaded.wasm +3 -0
- web/ort/ort.wasm.min.mjs +7 -0
- web/serve.py +26 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples/hobellied-F2-accent-1.0.wav filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
samples/hobellied-M2-accent-0.wav filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
samples/hobellied-M2-accent-1.0.wav filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
samples/hobellied-M2-accent-1.6.wav filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
| 178 |
+
|
| 179 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 180 |
+
|
| 181 |
+
To apply the Apache License to your work, attach the following
|
| 182 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 183 |
+
replaced with your own identifying information. (Don't include
|
| 184 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 185 |
+
comment syntax for the file format. We also recommend that a
|
| 186 |
+
file or class name and description of purpose be included on the
|
| 187 |
+
same "printed page" as the copyright notice for easier
|
| 188 |
+
identification within third-party archives.
|
| 189 |
+
|
| 190 |
+
Copyright [yyyy] [name of copyright owner]
|
| 191 |
+
|
| 192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 193 |
+
you may not use this file except in compliance with the License.
|
| 194 |
+
You may obtain a copy of the License at
|
| 195 |
+
|
| 196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 197 |
+
|
| 198 |
+
Unless required by applicable law or agreed to in writing, software
|
| 199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 201 |
+
See the License for the specific language governing permissions and
|
| 202 |
+
limitations under the License.
|
README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- de
|
| 5 |
+
pipeline_tag: text-to-speech
|
| 6 |
+
library_name: onnx
|
| 7 |
+
tags:
|
| 8 |
+
- tts
|
| 9 |
+
- text-to-speech
|
| 10 |
+
- german
|
| 11 |
+
- austrian-german
|
| 12 |
+
- onnx
|
| 13 |
+
- cpu
|
| 14 |
+
- browser
|
| 15 |
+
- onnxruntime-web
|
| 16 |
+
- tiny-voca
|
| 17 |
+
- vocos
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# apptor-tiny-tts-at (Austrian German, v0.1)
|
| 21 |
+
|
| 22 |
+
A tiny German text-to-speech model with an **Austrian accent you can turn up or down**: from Hochdeutsch (0) to
|
| 23 |
+
Austrian (1.0) and a bit beyond (up to 1.6). 4.5M parameters, one 21 MB ONNX file, two synthetic voices (`M2`
|
| 24 |
+
male, `F2` female), 24 kHz. Runs on the CPU and **directly in the browser**, without eSpeak, without a server.
|
| 25 |
+
|
| 26 |
+
**Try it:** [tiny-tts.apptor.at](https://tiny-tts.apptor.at) (everything runs on your device).
|
| 27 |
+
|
| 28 |
+
This is **version 0.1, an early preview**. The accent is still mild and does not sit in every word: better than
|
| 29 |
+
nothing, but not fully Austrian yet. It was trained on a single GPU. Feedback is welcome on
|
| 30 |
+
[X @apptor_at](https://x.com/apptor_at).
|
| 31 |
+
|
| 32 |
+
Why: speech output almost always sounds German-German. This model is meant to give Austrians a voice that is
|
| 33 |
+
closer to how they speak, in small, lightweight applications where big models do not fit.
|
| 34 |
+
|
| 35 |
+
Listen: `samples/hobellied-M2-accent-0.wav` (Hochdeutsch), `-accent-1.0.wav` (Austrian), `-accent-1.6.wav`
|
| 36 |
+
(strongest usable setting).
|
| 37 |
+
|
| 38 |
+
## Three ways to use it
|
| 39 |
+
|
| 40 |
+
| you want | use | needs |
|
| 41 |
+
|---|---|---|
|
| 42 |
+
| a voice on your website / web app | the `web/` folder | any web server that can set two headers |
|
| 43 |
+
| a voice in a Python program | `speak.py` and the ONNX files | `pip install onnxruntime numpy num2words` |
|
| 44 |
+
| a complete voice assistant (listen, decide, speak) | [flash-voice](https://github.com/ViktorsGitUser/flash-voice) on GitHub | see there |
|
| 45 |
+
|
| 46 |
+
Download everything: `git clone https://huggingface.co/apptor/apptor-tiny-tts-at` (with git-lfs), or
|
| 47 |
+
`hf download apptor/apptor-tiny-tts-at --local-dir apptor-tiny-tts-at`.
|
| 48 |
+
|
| 49 |
+
### Web
|
| 50 |
+
|
| 51 |
+
`web/` is exactly the demo site: `index.html`, `apptor-tts.js` (front end + synthesis, plain ES module),
|
| 52 |
+
the models and [ONNX Runtime Web](https://onnxruntime.ai) 1.20.1. No build step, no npm. Copy the folder to a web
|
| 53 |
+
server. The included `.htaccess` (Apache) sets the two headers that let the browser use several CPU cores:
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
Cross-Origin-Opener-Policy: same-origin
|
| 57 |
+
Cross-Origin-Embedder-Policy: require-corp
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Without them it still works, just on one core. Opening `index.html` as a file (`file://`) does not work; to try
|
| 61 |
+
it locally run `python web/serve.py` and open http://127.0.0.1:8000/. The first visit downloads about 50 MB, which the page keeps in the browser
|
| 62 |
+
cache. To use it in your own page, see the `<script type="module">` at the end of `index.html`: load the models,
|
| 63 |
+
then
|
| 64 |
+
|
| 65 |
+
```js
|
| 66 |
+
const audio = await voice.speak("Servus!", {voice: "M2", accent: 1.0}); // Float32Array, 24 kHz
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Python
|
| 70 |
+
|
| 71 |
+
```bash
|
| 72 |
+
pip install onnxruntime numpy num2words
|
| 73 |
+
python speak.py "Grüß Gott! Am 3. Mai um 18:30 Uhr kostet das Ticket 12,50 Euro." --out test.wav
|
| 74 |
+
python speak.py "Servus, wie geht's dir?" --voice F2 --accent 0 --out hochdeutsch.wav
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
```python
|
| 78 |
+
from speak import Speaker
|
| 79 |
+
s = Speaker() # finds the models next to speak.py
|
| 80 |
+
audio = s.speak("Servus!", voice="M2", accent=1.0) # float32 numpy array, 24 kHz
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
## Files
|
| 84 |
+
|
| 85 |
+
| file | what | license |
|
| 86 |
+
|---|---|---|
|
| 87 |
+
| `apptor-tiny-tts-at.onnx` / `.json` | speech model: phoneme tokens -> 24 kHz audio, with `accent` input | Apache-2.0 |
|
| 88 |
+
| `apptor-g2p-de.onnx` / `.json` | letters -> phonemes (conv + BiGRU + CTC, 12 MB), replaces eSpeak NG | Apache-2.0 |
|
| 89 |
+
| `apptor-vocos-de.int8.onnx` | sound filter: [Vocos](https://github.com/gemelo-ai/vocos) fine-tuned on the two voices, int8 | MIT |
|
| 90 |
+
| `tinyvoca/` | German text front end: numbers, dates, times, tokens, G2P wrapper, word lists | Apache-2.0 |
|
| 91 |
+
| `speak.py` | Python example and small library | Apache-2.0 |
|
| 92 |
+
| `web/` | the browser demo, complete (same models + ONNX Runtime Web, MIT); `serve.py` for local tests | Apache-2.0 / MIT |
|
| 93 |
+
|
| 94 |
+
ONNX inputs of the speech model: `tokens`, `stress` (int64 [1, N]), `voice` (int64 [1]: 0 = F2, 1 = M2),
|
| 95 |
+
`speed`, `pitch_shift`, `pitch_range` (float32 [1]; normally 1 / 0 / 1), `accent` (float32 [1]: 0 Hochdeutsch,
|
| 96 |
+
1.0 Austrian, up to 1.6; above that it breaks). At most 512 tokens per call; `speak.py` and `apptor-tts.js`
|
| 97 |
+
split long text into sentences. When the accent is on (>= 0.5), a short list of Austrian readings is used
|
| 98 |
+
(Kaffee, Tabak, Mathematik, Chemie, China ...).
|
| 99 |
+
|
| 100 |
+
## How it was made
|
| 101 |
+
|
| 102 |
+
- **Base:** [apptor-tiny-tts](https://huggingface.co/apptor/apptor-tiny-tts), the German model built on the
|
| 103 |
+
[tiny-voca](https://github.com/n4ze3m/tiny-voca) architecture by n4ze3m (not an official tiny-voca release).
|
| 104 |
+
- **Accent:** fine-tuned for 24k steps on one RTX 5060 Ti with 8,208 Austrian recordings from
|
| 105 |
+
[Mozilla Common Voice](https://commonvoice.mozilla.org) German (CC0), next to the two synthetic voices. The
|
| 106 |
+
Austrian speakers share one *style* (pronunciation and melody); the *voice* (timbre) stays F2 or M2. The accent
|
| 107 |
+
slider moves between the voice's own style and the Austrian style. All real speakers were removed from the
|
| 108 |
+
exported model: it can only speak with the two synthetic voices.
|
| 109 |
+
- **Voices:** synthetic, made with Qwen3-TTS (Apache-2.0) built-in voices; not clones of real people.
|
| 110 |
+
- **Front end without eSpeak:** the G2P model learned the eSpeak NG readings of ~480,000 words from the Common
|
| 111 |
+
Voice sentences (98% of words identical on held-out data), plus a hand-written list for first names and
|
| 112 |
+
Austrian readings. So no GPL program is needed at run time.
|
| 113 |
+
|
| 114 |
+
## Limitations
|
| 115 |
+
|
| 116 |
+
- v0.1: the accent is mild, not dialect. Some words and names are still pronounced oddly.
|
| 117 |
+
- German only. English words are read with German pronunciation.
|
| 118 |
+
- Not studio quality; without the sound filter the voice is buzzy.
|
| 119 |
+
|
| 120 |
+
## Deutsch
|
| 121 |
+
|
| 122 |
+
Eine kleine deutsche Stimme, die auch (etwas) österreichisch kann: Akzent stufenlos von Hochdeutsch (0) bis
|
| 123 |
+
österreichisch (1,0, maximal 1,6). 4,5 Mio. Parameter, läuft auf der CPU und direkt im Browser, ohne eSpeak und
|
| 124 |
+
ohne Server. Version 0.1, eine frühe Vorschau, trainiert auf einer einzigen Grafikkarte. Der Akzent ist noch
|
| 125 |
+
dezent: besser als nichts, aber noch nicht ganz österreichisch. Ausprobieren: [tiny-tts.apptor.at](https://tiny-tts.apptor.at).
|
| 126 |
+
Rückmeldungen gern auf [X @apptor_at](https://x.com/apptor_at). Apache 2.0, also auch kommerziell nutzbar.
|
| 127 |
+
|
| 128 |
+
## Credits
|
| 129 |
+
|
| 130 |
+
- [tiny-voca](https://github.com/n4ze3m/tiny-voca) by n4ze3m: architecture, training recipe, text front end (Apache-2.0)
|
| 131 |
+
- [Mozilla Common Voice](https://commonvoice.mozilla.org) German (CC0): Austrian recordings, texts
|
| 132 |
+
- [Vocos](https://github.com/gemelo-ai/vocos), `charactr/vocos-mel-24khz` (MIT)
|
| 133 |
+
- [Qwen3-TTS](https://github.com/QwenLM/Qwen3-TTS) (Apache-2.0): synthetic training voices
|
| 134 |
+
- [ONNX Runtime Web](https://onnxruntime.ai) (MIT), num2words (LGPL-2.1, installed separately)
|
| 135 |
+
- Sample text: Ferdinand Raimund, "Hobellied" (1834, public domain)
|
apptor-g2p-de.json
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"chars": [
|
| 3 |
+
"<pad>",
|
| 4 |
+
"<unk>",
|
| 5 |
+
"'",
|
| 6 |
+
"-",
|
| 7 |
+
".",
|
| 8 |
+
"A",
|
| 9 |
+
"B",
|
| 10 |
+
"C",
|
| 11 |
+
"D",
|
| 12 |
+
"E",
|
| 13 |
+
"F",
|
| 14 |
+
"G",
|
| 15 |
+
"H",
|
| 16 |
+
"I",
|
| 17 |
+
"J",
|
| 18 |
+
"K",
|
| 19 |
+
"L",
|
| 20 |
+
"M",
|
| 21 |
+
"N",
|
| 22 |
+
"O",
|
| 23 |
+
"P",
|
| 24 |
+
"Q",
|
| 25 |
+
"R",
|
| 26 |
+
"S",
|
| 27 |
+
"T",
|
| 28 |
+
"U",
|
| 29 |
+
"V",
|
| 30 |
+
"W",
|
| 31 |
+
"X",
|
| 32 |
+
"Y",
|
| 33 |
+
"Z",
|
| 34 |
+
"a",
|
| 35 |
+
"b",
|
| 36 |
+
"c",
|
| 37 |
+
"d",
|
| 38 |
+
"e",
|
| 39 |
+
"f",
|
| 40 |
+
"g",
|
| 41 |
+
"h",
|
| 42 |
+
"i",
|
| 43 |
+
"j",
|
| 44 |
+
"k",
|
| 45 |
+
"l",
|
| 46 |
+
"m",
|
| 47 |
+
"n",
|
| 48 |
+
"o",
|
| 49 |
+
"p",
|
| 50 |
+
"q",
|
| 51 |
+
"r",
|
| 52 |
+
"s",
|
| 53 |
+
"t",
|
| 54 |
+
"u",
|
| 55 |
+
"v",
|
| 56 |
+
"w",
|
| 57 |
+
"x",
|
| 58 |
+
"y",
|
| 59 |
+
"z",
|
| 60 |
+
"¡",
|
| 61 |
+
"",
|
| 62 |
+
"®",
|
| 63 |
+
"Á",
|
| 64 |
+
"Ä",
|
| 65 |
+
"Æ",
|
| 66 |
+
"Ç",
|
| 67 |
+
"É",
|
| 68 |
+
"Í",
|
| 69 |
+
"Î",
|
| 70 |
+
"Ó",
|
| 71 |
+
"Ö",
|
| 72 |
+
"Ú",
|
| 73 |
+
"Ü",
|
| 74 |
+
"Þ",
|
| 75 |
+
"ß",
|
| 76 |
+
"à",
|
| 77 |
+
"á",
|
| 78 |
+
"â",
|
| 79 |
+
"ã",
|
| 80 |
+
"ä",
|
| 81 |
+
"å",
|
| 82 |
+
"æ",
|
| 83 |
+
"è",
|
| 84 |
+
"é",
|
| 85 |
+
"ê",
|
| 86 |
+
"ë",
|
| 87 |
+
"í",
|
| 88 |
+
"î",
|
| 89 |
+
"ï",
|
| 90 |
+
"ð",
|
| 91 |
+
"ñ",
|
| 92 |
+
"ò",
|
| 93 |
+
"ó",
|
| 94 |
+
"ô",
|
| 95 |
+
"õ",
|
| 96 |
+
"ö",
|
| 97 |
+
"ø",
|
| 98 |
+
"ú",
|
| 99 |
+
"ü",
|
| 100 |
+
"ý",
|
| 101 |
+
"ā",
|
| 102 |
+
"ă",
|
| 103 |
+
"ą",
|
| 104 |
+
"ć",
|
| 105 |
+
"Č",
|
| 106 |
+
"č",
|
| 107 |
+
"Đ",
|
| 108 |
+
"đ",
|
| 109 |
+
"ė",
|
| 110 |
+
"ę",
|
| 111 |
+
"ě",
|
| 112 |
+
"ğ",
|
| 113 |
+
"ġ",
|
| 114 |
+
"ī",
|
| 115 |
+
"İ",
|
| 116 |
+
"ı",
|
| 117 |
+
"Ł",
|
| 118 |
+
"ł",
|
| 119 |
+
"ń",
|
| 120 |
+
"ň",
|
| 121 |
+
"Ō",
|
| 122 |
+
"ō",
|
| 123 |
+
"ő",
|
| 124 |
+
"Œ",
|
| 125 |
+
"œ",
|
| 126 |
+
"Ř",
|
| 127 |
+
"ř",
|
| 128 |
+
"Ś",
|
| 129 |
+
"ś",
|
| 130 |
+
"Ş",
|
| 131 |
+
"ş",
|
| 132 |
+
"Š",
|
| 133 |
+
"š",
|
| 134 |
+
"ţ",
|
| 135 |
+
"ū",
|
| 136 |
+
"ŭ",
|
| 137 |
+
"ů",
|
| 138 |
+
"Ż",
|
| 139 |
+
"Ž",
|
| 140 |
+
"ž",
|
| 141 |
+
"Ə",
|
| 142 |
+
"ơ",
|
| 143 |
+
"ș",
|
| 144 |
+
"ț",
|
| 145 |
+
"ə",
|
| 146 |
+
"ʻ",
|
| 147 |
+
"ʾ",
|
| 148 |
+
"ʿ",
|
| 149 |
+
"́",
|
| 150 |
+
"μ",
|
| 151 |
+
"ḫ",
|
| 152 |
+
"ṣ",
|
| 153 |
+
"‐",
|
| 154 |
+
"′",
|
| 155 |
+
"‹",
|
| 156 |
+
"›"
|
| 157 |
+
],
|
| 158 |
+
"units": [
|
| 159 |
+
"1",
|
| 160 |
+
"??",
|
| 161 |
+
"??ˈ",
|
| 162 |
+
"??ˌ",
|
| 163 |
+
"a",
|
| 164 |
+
"aɪ",
|
| 165 |
+
"aɪə",
|
| 166 |
+
"aɪəˈ",
|
| 167 |
+
"aɪəˌ",
|
| 168 |
+
"aɪˈ",
|
| 169 |
+
"aɪˌ",
|
| 170 |
+
"aʊ",
|
| 171 |
+
"aʊˈ",
|
| 172 |
+
"aʊˌ",
|
| 173 |
+
"aˈ",
|
| 174 |
+
"aˌ",
|
| 175 |
+
"b",
|
| 176 |
+
"bʲ",
|
| 177 |
+
"d",
|
| 178 |
+
"dʑ",
|
| 179 |
+
"dʒ",
|
| 180 |
+
"dʲ",
|
| 181 |
+
"e",
|
| 182 |
+
"eə",
|
| 183 |
+
"eəˈ",
|
| 184 |
+
"eəˌ",
|
| 185 |
+
"eɪ",
|
| 186 |
+
"eɪˈ",
|
| 187 |
+
"eɪˌ",
|
| 188 |
+
"eˈ",
|
| 189 |
+
"eː",
|
| 190 |
+
"eːˈ",
|
| 191 |
+
"eːˌ",
|
| 192 |
+
"f",
|
| 193 |
+
"fʲ",
|
| 194 |
+
"h",
|
| 195 |
+
"i",
|
| 196 |
+
"iə",
|
| 197 |
+
"iəˈ",
|
| 198 |
+
"iəˌ",
|
| 199 |
+
"iʊ",
|
| 200 |
+
"iˈ",
|
| 201 |
+
"iˌ",
|
| 202 |
+
"iː",
|
| 203 |
+
"iːˈ",
|
| 204 |
+
"iːˌ",
|
| 205 |
+
"j",
|
| 206 |
+
"k",
|
| 207 |
+
"kʲ",
|
| 208 |
+
"l",
|
| 209 |
+
"m",
|
| 210 |
+
"mʲ",
|
| 211 |
+
"n",
|
| 212 |
+
"o",
|
| 213 |
+
"oɪˈ",
|
| 214 |
+
"oˈ",
|
| 215 |
+
"oˌ",
|
| 216 |
+
"oː",
|
| 217 |
+
"oːˈ",
|
| 218 |
+
"oːˌ",
|
| 219 |
+
"p",
|
| 220 |
+
"pf",
|
| 221 |
+
"q",
|
| 222 |
+
"r",
|
| 223 |
+
"s",
|
| 224 |
+
"t",
|
| 225 |
+
"ts",
|
| 226 |
+
"tɕ",
|
| 227 |
+
"tʃ",
|
| 228 |
+
"tʲ",
|
| 229 |
+
"u",
|
| 230 |
+
"uˈ",
|
| 231 |
+
"uˌ",
|
| 232 |
+
"uː",
|
| 233 |
+
"uːˈ",
|
| 234 |
+
"uːˌ",
|
| 235 |
+
"v",
|
| 236 |
+
"vʲ",
|
| 237 |
+
"w",
|
| 238 |
+
"w-ˈ",
|
| 239 |
+
"x",
|
| 240 |
+
"y",
|
| 241 |
+
"yˈ",
|
| 242 |
+
"yˌ",
|
| 243 |
+
"yː",
|
| 244 |
+
"yːˈ",
|
| 245 |
+
"yːˌ",
|
| 246 |
+
"z",
|
| 247 |
+
"ç",
|
| 248 |
+
"ð",
|
| 249 |
+
"øː",
|
| 250 |
+
"øːˈ",
|
| 251 |
+
"øːˌ",
|
| 252 |
+
"ŋ",
|
| 253 |
+
"œ",
|
| 254 |
+
"œˈ",
|
| 255 |
+
"œˌ",
|
| 256 |
+
"œ̃ˈ",
|
| 257 |
+
"ɐ",
|
| 258 |
+
"ɐˈ",
|
| 259 |
+
"ɑ",
|
| 260 |
+
"ɑˈ",
|
| 261 |
+
"ɑˌ",
|
| 262 |
+
"ɑː",
|
| 263 |
+
"ɑːˈ",
|
| 264 |
+
"ɑːˌ",
|
| 265 |
+
"ɑ̃",
|
| 266 |
+
"ɑ̃ˈ",
|
| 267 |
+
"ɑ̃ˌ",
|
| 268 |
+
"ɒ",
|
| 269 |
+
"ɒˈ",
|
| 270 |
+
"ɒˌ",
|
| 271 |
+
"ɔ",
|
| 272 |
+
"ɔø",
|
| 273 |
+
"ɔøˈ",
|
| 274 |
+
"ɔøˌ",
|
| 275 |
+
"ɔɪ",
|
| 276 |
+
"ɔɪˈ",
|
| 277 |
+
"ɔɪˌ",
|
| 278 |
+
"ɔˈ",
|
| 279 |
+
"ɔˌ",
|
| 280 |
+
"ɔː",
|
| 281 |
+
"ɔːˈ",
|
| 282 |
+
"ɔːˌ",
|
| 283 |
+
"ɔ̃ˈ",
|
| 284 |
+
"ɔ̃ˌ",
|
| 285 |
+
"ɕ",
|
| 286 |
+
"ə",
|
| 287 |
+
"əl",
|
| 288 |
+
"əʊ",
|
| 289 |
+
"əʊˈ",
|
| 290 |
+
"əʊˌ",
|
| 291 |
+
"əˈ",
|
| 292 |
+
"əˌ",
|
| 293 |
+
"ɛ",
|
| 294 |
+
"ɛɪ",
|
| 295 |
+
"ɛɪˈ",
|
| 296 |
+
"ɛɪˌ",
|
| 297 |
+
"ɛˈ",
|
| 298 |
+
"ɛˌ",
|
| 299 |
+
"ɛː",
|
| 300 |
+
"ɛːˈ",
|
| 301 |
+
"ɛːˌ",
|
| 302 |
+
"ɛ̃ˌ",
|
| 303 |
+
"ɜ",
|
| 304 |
+
"ɜˈ",
|
| 305 |
+
"ɜˌ",
|
| 306 |
+
"ɜː",
|
| 307 |
+
"ɜːˈ",
|
| 308 |
+
"ɜːˌ",
|
| 309 |
+
"ɡ",
|
| 310 |
+
"ɡʲ",
|
| 311 |
+
"ɨ",
|
| 312 |
+
"ɨˈ",
|
| 313 |
+
"ɪ",
|
| 314 |
+
"ɪˈ",
|
| 315 |
+
"ɪˌ",
|
| 316 |
+
"ɫ",
|
| 317 |
+
"ɯ",
|
| 318 |
+
"ɯˈ",
|
| 319 |
+
"ɯˌ",
|
| 320 |
+
"ɲ",
|
| 321 |
+
"ɹ",
|
| 322 |
+
"ɾ",
|
| 323 |
+
"ʃ",
|
| 324 |
+
"ʊ",
|
| 325 |
+
"ʊə",
|
| 326 |
+
"ʊəˈ",
|
| 327 |
+
"ʊəˌ",
|
| 328 |
+
"ʊˈ",
|
| 329 |
+
"ʊˌ",
|
| 330 |
+
"ʌ",
|
| 331 |
+
"ʌˈ",
|
| 332 |
+
"ʌˌ",
|
| 333 |
+
"ʑ",
|
| 334 |
+
"ʒ",
|
| 335 |
+
"ʔ",
|
| 336 |
+
"θ"
|
| 337 |
+
],
|
| 338 |
+
"up": 3,
|
| 339 |
+
"max_len": 40,
|
| 340 |
+
"blank": 178,
|
| 341 |
+
"inputs": [
|
| 342 |
+
"chars"
|
| 343 |
+
],
|
| 344 |
+
"outputs": [
|
| 345 |
+
"logp"
|
| 346 |
+
]
|
| 347 |
+
}
|
apptor-g2p-de.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d981694e7a03030b2169be46b2094775dde4ec5a3e9406c92a3fc8f1ed8bbec3
|
| 3 |
+
size 12364141
|
apptor-tiny-tts-at.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"sample_rate": 24000,
|
| 3 |
+
"hop": 256,
|
| 4 |
+
"voices": [
|
| 5 |
+
"F2",
|
| 6 |
+
"M2",
|
| 7 |
+
"AT"
|
| 8 |
+
],
|
| 9 |
+
"symbols": [
|
| 10 |
+
"<pad>",
|
| 11 |
+
"<bos>",
|
| 12 |
+
"<eos>",
|
| 13 |
+
"<sp>",
|
| 14 |
+
"<unk>",
|
| 15 |
+
",",
|
| 16 |
+
".",
|
| 17 |
+
"?",
|
| 18 |
+
"!",
|
| 19 |
+
";",
|
| 20 |
+
":",
|
| 21 |
+
"\"",
|
| 22 |
+
"'",
|
| 23 |
+
"(",
|
| 24 |
+
")",
|
| 25 |
+
"—",
|
| 26 |
+
"…",
|
| 27 |
+
"p",
|
| 28 |
+
"b",
|
| 29 |
+
"t",
|
| 30 |
+
"d",
|
| 31 |
+
"k",
|
| 32 |
+
"ɡ",
|
| 33 |
+
"f",
|
| 34 |
+
"v",
|
| 35 |
+
"s",
|
| 36 |
+
"z",
|
| 37 |
+
"ʃ",
|
| 38 |
+
"ʒ",
|
| 39 |
+
"ç",
|
| 40 |
+
"x",
|
| 41 |
+
"h",
|
| 42 |
+
"m",
|
| 43 |
+
"n",
|
| 44 |
+
"ŋ",
|
| 45 |
+
"l",
|
| 46 |
+
"ɾ",
|
| 47 |
+
"r",
|
| 48 |
+
"j",
|
| 49 |
+
"ts",
|
| 50 |
+
"pf",
|
| 51 |
+
"tʃ",
|
| 52 |
+
"dʒ",
|
| 53 |
+
"ə",
|
| 54 |
+
"ɐ",
|
| 55 |
+
"ɜ",
|
| 56 |
+
"ɪ",
|
| 57 |
+
"i",
|
| 58 |
+
"iː",
|
| 59 |
+
"ɛ",
|
| 60 |
+
"ɛː",
|
| 61 |
+
"eː",
|
| 62 |
+
"a",
|
| 63 |
+
"ɑ",
|
| 64 |
+
"ɑː",
|
| 65 |
+
"ɔ",
|
| 66 |
+
"oː",
|
| 67 |
+
"ʊ",
|
| 68 |
+
"uː",
|
| 69 |
+
"y",
|
| 70 |
+
"yː",
|
| 71 |
+
"œ",
|
| 72 |
+
"øː",
|
| 73 |
+
"aɪ",
|
| 74 |
+
"aʊ",
|
| 75 |
+
"ɔø",
|
| 76 |
+
"ʊɐ"
|
| 77 |
+
],
|
| 78 |
+
"max_tokens": 512,
|
| 79 |
+
"max_frames": 3000,
|
| 80 |
+
"step": 126000,
|
| 81 |
+
"frontend": "espeak",
|
| 82 |
+
"frontend_fingerprint": "ddefc3ebfe4beeca2af195dc920c207110b07bd5067f225c575a3cdeef02d73f",
|
| 83 |
+
"inputs": [
|
| 84 |
+
"tokens",
|
| 85 |
+
"stress",
|
| 86 |
+
"voice",
|
| 87 |
+
"speed",
|
| 88 |
+
"pitch_shift",
|
| 89 |
+
"pitch_range",
|
| 90 |
+
"accent"
|
| 91 |
+
],
|
| 92 |
+
"outputs": [
|
| 93 |
+
"audio",
|
| 94 |
+
"durations"
|
| 95 |
+
],
|
| 96 |
+
"accent_style": "AT"
|
| 97 |
+
}
|
apptor-tiny-tts-at.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1db856e5aac4f6b21f6b7f6e026a63fa8fb29469fa2301b8b166ffc5ebaae05d
|
| 3 |
+
size 21382102
|
apptor-vocos-de.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:417f2413163d666b23a89dd73b1829a34ac316fb524a02cc6a4120660a40e6eb
|
| 3 |
+
size 16655451
|
samples/hobellied-F2-accent-1.0.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d54ec87d6875cf6f3b3dd03094e80bec67287accc53cc9cceb0f0d9e72b1a77c
|
| 3 |
+
size 316364
|
samples/hobellied-M2-accent-0.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98c98257cd67ae05d31b43273b53314b29fcded721f0670dae6819556d84b8ac
|
| 3 |
+
size 264748
|
samples/hobellied-M2-accent-1.0.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a277047db0b7cbb905262ab713f2c36eff71f765b1523ba2d9fed9ac2b0d4175
|
| 3 |
+
size 316364
|
samples/hobellied-M2-accent-1.6.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:759ff362f28d4652b5d928c15c654c7ee621f9d45fb9f9031797b102b1858bdb
|
| 3 |
+
size 344684
|
speak.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""apptor-tiny-tts: German text -> WAV on the CPU. No eSpeak NG, no torch, no GPU.
|
| 2 |
+
|
| 3 |
+
pip install onnxruntime numpy num2words
|
| 4 |
+
python speak.py "Servus, wie geht's dir?" --voice M2 --out servus.wav
|
| 5 |
+
python speak.py "Servus, wie geht's dir?" --accent 0 # Austrian model: Hochdeutsch
|
| 6 |
+
python speak.py "Servus, wie geht's dir?" --accent 1.6 # Austrian model: strongest usable accent
|
| 7 |
+
|
| 8 |
+
Uses the files next to this script: the speech model (apptor-tiny-tts-at.onnx, else apptor-tiny-tts-de.onnx), the
|
| 9 |
+
letter-to-sound model apptor-g2p-de.onnx and, unless --no-vocos, the sound filter apptor-vocos-de.int8.onnx.
|
| 10 |
+
"""
|
| 11 |
+
import argparse
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import re
|
| 15 |
+
import wave
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import numpy as np
|
| 19 |
+
import onnxruntime as ort
|
| 20 |
+
|
| 21 |
+
HERE = Path(__file__).resolve().parent
|
| 22 |
+
os.environ.setdefault("APPTOR_G2P_MODEL", str(HERE / "apptor-g2p-de.onnx"))
|
| 23 |
+
from tinyvoca.g2p_de import phonemize # noqa: E402
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def session(path, threads):
|
| 27 |
+
options = ort.SessionOptions()
|
| 28 |
+
options.intra_op_num_threads = threads
|
| 29 |
+
return ort.InferenceSession(str(path), options, providers=["CPUExecutionProvider"])
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def vocos_kernels(n_fft=1024):
|
| 33 |
+
"""Fixed STFT / inverse STFT kernels of the Vocos ONNX model (periodic Hann window)."""
|
| 34 |
+
n = np.arange(n_fft)
|
| 35 |
+
k = np.arange(n_fft // 2 + 1)[:, None]
|
| 36 |
+
w = 0.5 - 0.5 * np.cos(2 * np.pi * n / n_fft)
|
| 37 |
+
ang = 2 * np.pi * k * n / n_fft
|
| 38 |
+
c = np.where((k == 0) | (k == n_fft // 2), 1.0, 2.0) / n_fft
|
| 39 |
+
return {"a_real": (w * np.cos(ang))[:, None].astype(np.float32),
|
| 40 |
+
"a_imag": (-w * np.sin(ang))[:, None].astype(np.float32),
|
| 41 |
+
"synth": np.concatenate((c * np.cos(ang) * w, -c * np.sin(ang) * w))[:, None].astype(np.float32)}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def trim_tail(audio, sr, floor_db=-30.0, fade_ms=40.0):
|
| 45 |
+
"""Cut the breathy noise after the last sound: keep up to the last 10 ms frame within 30 dB of the loudest one,
|
| 46 |
+
then fade out over 40 ms."""
|
| 47 |
+
hop = sr // 100
|
| 48 |
+
n = len(audio) // hop
|
| 49 |
+
if n == 0:
|
| 50 |
+
return audio
|
| 51 |
+
e = (audio[:n * hop].reshape(n, hop) ** 2).sum(1)
|
| 52 |
+
if e.max() <= 0:
|
| 53 |
+
return audio
|
| 54 |
+
last = int(np.nonzero(e >= e.max() * 10 ** (floor_db / 10))[0][-1])
|
| 55 |
+
fade = int(fade_ms * sr / 1000)
|
| 56 |
+
end = (last + 1) * hop + fade
|
| 57 |
+
if end >= len(audio):
|
| 58 |
+
return audio
|
| 59 |
+
out = audio[:end].copy()
|
| 60 |
+
out[-fade:] *= 0.5 + 0.5 * np.cos(np.pi * np.arange(1, fade + 1) / fade)
|
| 61 |
+
return out
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class Speaker:
|
| 65 |
+
def __init__(self, model=None, vocos=True, threads=4):
|
| 66 |
+
model = Path(model) if model else next(p for p in (HERE / "apptor-tiny-tts-at.onnx", HERE / "apptor-tiny-tts-de.onnx")
|
| 67 |
+
if p.is_file())
|
| 68 |
+
self.meta = json.loads(model.with_suffix(".json").read_text(encoding="utf-8"))
|
| 69 |
+
self.tts = session(model, threads)
|
| 70 |
+
self.inputs = {i.name for i in self.tts.get_inputs()}
|
| 71 |
+
self.max_tokens = self.meta.get("max_tokens", 512)
|
| 72 |
+
self.vocos = session(HERE / "apptor-vocos-de.int8.onnx", threads) if vocos else None
|
| 73 |
+
self.kernels = vocos_kernels() if vocos else None
|
| 74 |
+
|
| 75 |
+
@property
|
| 76 |
+
def voices(self):
|
| 77 |
+
return [v for v in self.meta["voices"] if v != "AT"]
|
| 78 |
+
|
| 79 |
+
def _pieces(self, text, austrian):
|
| 80 |
+
"""Sentences, then clauses or halves, so that no piece exceeds the model's token limit."""
|
| 81 |
+
for sentence in re.split(r"(?<=[.!?…])\s+", text.strip()):
|
| 82 |
+
if not sentence:
|
| 83 |
+
continue
|
| 84 |
+
p = phonemize(sentence, austrian=austrian)
|
| 85 |
+
if len(p.ids) <= self.max_tokens:
|
| 86 |
+
yield p
|
| 87 |
+
continue
|
| 88 |
+
parts = re.split(r"(?<=[,;:—])\s+", sentence)
|
| 89 |
+
if len(parts) == 1:
|
| 90 |
+
words = sentence.split()
|
| 91 |
+
parts = [" ".join(words[:len(words) // 2]), " ".join(words[len(words) // 2:])]
|
| 92 |
+
for part in parts:
|
| 93 |
+
yield from self._pieces(part, austrian)
|
| 94 |
+
|
| 95 |
+
def speak(self, text, voice="M2", accent=1.0, speed=1.0, gap=0.12):
|
| 96 |
+
"""-> float32 audio at meta["sample_rate"]. accent: 0 = Hochdeutsch, 1.0 = Austrian, up to 1.6 (AT model only)."""
|
| 97 |
+
sr = self.meta["sample_rate"]
|
| 98 |
+
has_accent = "accent" in self.inputs
|
| 99 |
+
out = []
|
| 100 |
+
for p in self._pieces(text, austrian=has_accent and accent >= 0.5):
|
| 101 |
+
feeds = {"tokens": np.array([p.ids], np.int64), "stress": np.array([p.stress], np.int64),
|
| 102 |
+
"voice": np.array([self.meta["voices"].index(voice)], np.int64),
|
| 103 |
+
"speed": np.array([speed], np.float32), "pitch_shift": np.array([0.0], np.float32),
|
| 104 |
+
"pitch_range": np.array([1.0], np.float32)}
|
| 105 |
+
if has_accent:
|
| 106 |
+
feeds["accent"] = np.array([accent], np.float32)
|
| 107 |
+
audio = self.tts.run(["audio"], feeds)[0][0].astype(np.float32)
|
| 108 |
+
if self.vocos is not None:
|
| 109 |
+
y = self.vocos.run(None, {"audio": audio[None], **self.kernels})[0][0]
|
| 110 |
+
audio = y[:len(audio)]
|
| 111 |
+
audio = trim_tail(audio, sr)
|
| 112 |
+
peak = float(np.abs(audio).max()) if len(audio) else 0.0
|
| 113 |
+
if peak > 0.95:
|
| 114 |
+
audio = audio * (0.95 / peak)
|
| 115 |
+
if out:
|
| 116 |
+
out.append(np.zeros(int(gap * sr), np.float32))
|
| 117 |
+
out.append(audio)
|
| 118 |
+
return np.concatenate(out) if out else np.zeros(0, np.float32)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def write_wav(path, audio, sr):
|
| 122 |
+
"""float audio -> 16-bit mono WAV."""
|
| 123 |
+
with wave.open(str(path), "wb") as w:
|
| 124 |
+
w.setnchannels(1)
|
| 125 |
+
w.setsampwidth(2)
|
| 126 |
+
w.setframerate(sr)
|
| 127 |
+
w.writeframes((np.clip(audio, -1, 1) * 32767).astype("<i2").tobytes())
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def main():
|
| 131 |
+
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
| 132 |
+
ap.add_argument("text")
|
| 133 |
+
ap.add_argument("--voice", default="M2", choices=["M2", "F2"])
|
| 134 |
+
ap.add_argument("--accent", type=float, default=1.0, help="Austrian model: 0 Hochdeutsch, 1.0 Austrian, up to 1.6")
|
| 135 |
+
ap.add_argument("--speed", type=float, default=1.0)
|
| 136 |
+
ap.add_argument("--out", default="out.wav")
|
| 137 |
+
ap.add_argument("--model", help="speech model .onnx (default: the one next to this script)")
|
| 138 |
+
ap.add_argument("--no-vocos", action="store_true", help="skip the sound filter (faster, more buzzy)")
|
| 139 |
+
ap.add_argument("--threads", type=int, default=4)
|
| 140 |
+
a = ap.parse_args()
|
| 141 |
+
s = Speaker(a.model, vocos=not a.no_vocos, threads=a.threads)
|
| 142 |
+
audio = s.speak(a.text, voice=a.voice, accent=a.accent, speed=a.speed)
|
| 143 |
+
write_wav(a.out, audio, s.meta["sample_rate"])
|
| 144 |
+
print(f"wrote {a.out} ({len(audio) / s.meta['sample_rate']:.1f} s)")
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
if __name__ == "__main__":
|
| 148 |
+
main()
|
tinyvoca/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""German text front end of apptor-tiny-tts, based on tiny-voca (https://github.com/n4ze3m/tiny-voca, Apache 2.0):
|
| 2 |
+
text.py (phone inventory, tokens), normalize_de.py (numbers, dates, times; needs num2words) and g2p_de.py (letters
|
| 3 |
+
to phones with the small apptor-g2p-de model, so no eSpeak NG is needed)."""
|
tinyvoca/g2p_de.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""apptor-tiny-tts German letter-to-sound front end without eSpeak NG (Apache 2.0).
|
| 2 |
+
|
| 3 |
+
A small model (convolutions + bidirectional GRU, CTC, ~3 MB ONNX) turns each written word into phones with stress,
|
| 4 |
+
in the same inventory and conventions as eSpeak NG "de", which the speech models were trained on. It was trained
|
| 5 |
+
on the eSpeak readings of ~480,000 words from the Common Voice German sentences, so it reproduces those readings
|
| 6 |
+
without needing the eSpeak program (GPL-3.0) at run time. A small hand-written list (EXCEPTIONS) wins over the model.
|
| 7 |
+
|
| 8 |
+
words(piece) -> [[(phone, stress), ...], ...] # drop-in for tiny_voca.text.espeak_words
|
| 9 |
+
"""
|
| 10 |
+
import json
|
| 11 |
+
import os
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
+
HERE = Path(__file__).resolve().parent
|
| 17 |
+
MODEL = Path(os.environ.get("APPTOR_G2P_MODEL", HERE / "apptor-g2p-de.onnx"))
|
| 18 |
+
MARKS = {"ˈ": 1, "ˌ": 2}
|
| 19 |
+
|
| 20 |
+
# Hand-written readings (word -> phones with stress marks, space separated), used before the model: mostly first
|
| 21 |
+
# names, where the eSpeak readings (and so the model) put the stress on the wrong syllable.
|
| 22 |
+
EXCEPTIONS = {
|
| 23 |
+
"Helene": "h eː l eːˈ n ə",
|
| 24 |
+
"Diana": "d i aˈ n ɑː",
|
| 25 |
+
"Dianna": "d i aˈ n ɑː",
|
| 26 |
+
"Daniela": "d a n i eːˈ l ɑː",
|
| 27 |
+
"Melanie": "m eːˈ l a n iː",
|
| 28 |
+
"Valentina": "v a l ɛ n t iːˈ n ɑː",
|
| 29 |
+
"Theresa": "t eː r eːˈ z ɑː",
|
| 30 |
+
"Elisabeth": "eː l iːˈ z a b ɛ t",
|
| 31 |
+
"Alexander": "a l ɛ k s aˈ n d ɜ",
|
| 32 |
+
"Andreas": "a n d r eːˈ a s",
|
| 33 |
+
"Matthias": "m a t iːˈ a s",
|
| 34 |
+
"Tobias": "t oː b iːˈ a s",
|
| 35 |
+
"Florian": "f l oːˈ r i a n",
|
| 36 |
+
"Sebastian": "z eː b aˈ s t i a n",
|
| 37 |
+
"Stefanie": "ʃ t eːˈ f a n iː",
|
| 38 |
+
"Christina": "k r ɪ s t iːˈ n ɑː",
|
| 39 |
+
"Magdalena": "m a k d a l eːˈ n ɑː",
|
| 40 |
+
"Veronika": "v eː r oːˈ n i k ɑː",
|
| 41 |
+
"Monika": "m oːˈ n i k ɑː",
|
| 42 |
+
"Angelika": "a ŋ ɡ eːˈ l i k ɑː",
|
| 43 |
+
"Leonie": "l eː oːˈ n iː",
|
| 44 |
+
"Emilia": "eː m iːˈ l i ɑː",
|
| 45 |
+
"David": "d ɑːˈ v ɪ t",
|
| 46 |
+
"Raphael": "r ɑːˈ f a eː l",
|
| 47 |
+
"Michael": "m ɪˈ ç a eː l",
|
| 48 |
+
"Manuel": "m ɑːˈ n uː ɛ l",
|
| 49 |
+
"Maximilian": "m a k s i m iːˈ l i ɑː n",
|
| 50 |
+
"Julia": "j uːˈ l i ɑː",
|
| 51 |
+
"Sarah": "z ɑːˈ r ɑː",
|
| 52 |
+
"Barbara": "b aˈ ɾ b a r ɑː",
|
| 53 |
+
"Gabriele": "ɡ a b r i eːˈ l ə",
|
| 54 |
+
"Ursula": "ʊˈ ɾ z uː l ɑː",
|
| 55 |
+
"Irene": "iː r eːˈ n ə",
|
| 56 |
+
"Miriam": "m iːˈ r i a m",
|
| 57 |
+
"Marlene": "m a ɾ l eːˈ n ə",
|
| 58 |
+
"Helena": "h eːˈ l eː n ɑː",
|
| 59 |
+
"Elena": "eːˈ l eː n ɑː",
|
| 60 |
+
"Selina": "z eː l iːˈ n ɑː",
|
| 61 |
+
"Martina": "m a ɾ t iːˈ n ɑː",
|
| 62 |
+
"Claudia": "k l aʊˈ d i ɑː",
|
| 63 |
+
"Ingrid": "ɪˈ ŋ ɡ r ɪ t",
|
| 64 |
+
"Leopold": "l eːˈ oː p ɔ l t",
|
| 65 |
+
"Ferdinand": "f ɛˈ ɾ d i n a n t",
|
| 66 |
+
"Dominik": "d oːˈ m i n ɪ k",
|
| 67 |
+
"Fabian": "f ɑːˈ b i a n",
|
| 68 |
+
"Kilian": "k iːˈ l i a n",
|
| 69 |
+
"Elias": "eː l iːˈ a s",
|
| 70 |
+
"Noah": "n oːˈ a",
|
| 71 |
+
"Anton": "aˈ n t oː n",
|
| 72 |
+
"Dorothea": "d oː r oː t eːˈ ɑː",
|
| 73 |
+
"Cornelia": "k ɔ ɾ n eːˈ l i ɑː",
|
| 74 |
+
"Philomena": "f i l oː m eːˈ n ɑː",
|
| 75 |
+
"Aurelia": "aʊ r eːˈ l i ɑː",
|
| 76 |
+
"Antonia": "a n t oːˈ n i ɑː",
|
| 77 |
+
"Paulina": "p aʊ l iːˈ n ɑː",
|
| 78 |
+
"Juliana": "j uː l i ɑːˈ n ɑː",
|
| 79 |
+
"Liliana": "l i l i ɑːˈ n ɑː",
|
| 80 |
+
"Adriana": "a d r i ɑːˈ n ɑː",
|
| 81 |
+
"Tatjana": "t a t j ɑːˈ n ɑː",
|
| 82 |
+
"Svetlana": "s v ɛ t l ɑːˈ n ɑː",
|
| 83 |
+
"Milena": "m i l eːˈ n ɑː",
|
| 84 |
+
"Daria": "d ɑːˈ r i ɑː",
|
| 85 |
+
"Mariana": "m a r i ɑːˈ n ɑː",
|
| 86 |
+
"Ariana": "a r i ɑːˈ n ɑː",
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
# Austrian standard pronunciation (Österreichisches Wörterbuch) where the German German reading differs: used only
|
| 90 |
+
# when the Austrian accent is on (austrian=True), so the Hochdeutsch voices keep the German reading.
|
| 91 |
+
AUSTRIAN = {
|
| 92 |
+
"Kaffee": "k a f eːˈ", "Kaffees": "k a f eːˈ s", "Kaffeehaus": "k a f eːˈ h aʊˌ s",
|
| 93 |
+
"Kaffeehäuser": "k a f eːˈ h ɔøˌ z ɜ", "Tabak": "t a b aˈ k", "Mathematik": "m a t eːˈ m a t ɪ k",
|
| 94 |
+
"Chemie": "k eː m iːˈ", "Chemiker": "k eːˈ m ɪ k ɜ", "Chemikalien": "k eːˌ m iː k ɑˈ l ɪ ə n",
|
| 95 |
+
"chemisch": "k eːˈ m ɪ ʃ", "chemische": "k eːˈ m ɪ ʃ ə", "chemischen": "k eːˈ m ɪ ʃ ə n",
|
| 96 |
+
"China": "k iːˈ n ɑː", "Chinese": "k iː n eːˈ z ə", "Chinesen": "k iː n eːˈ z ə n",
|
| 97 |
+
"chinesisch": "k iː n eːˈ z ɪ ʃ", "chinesische": "k iː n eːˈ z ɪ ʃ ə", "Chirurg": "k iː r ??ˈ k",
|
| 98 |
+
"Motor": "m oː t oːˈ ɾ", "Platin": "p l a t iːˈ n", "Billard": "b ɪ j ɑːˈ ɾ", "Garage": "ɡ a r ɑːˈ ʃ",
|
| 99 |
+
# western-Austrian "scht" crept into the accent here; lenis d (as said in Vienna) keeps a clean s
|
| 100 |
+
"Donnerstag": "d ɔˈ n ɐ s d ɑː k", "Donnerstags": "d ɔˈ n ɐ s d ɑː k s",
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
_state = {}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def _load():
|
| 107 |
+
if "session" not in _state:
|
| 108 |
+
import onnxruntime as ort
|
| 109 |
+
meta = json.loads(MODEL.with_suffix(".json").read_text(encoding="utf-8"))
|
| 110 |
+
options = ort.SessionOptions()
|
| 111 |
+
options.intra_op_num_threads = 1
|
| 112 |
+
options.inter_op_num_threads = 1
|
| 113 |
+
_state["session"] = ort.InferenceSession(str(MODEL), options, providers=["CPUExecutionProvider"])
|
| 114 |
+
_state["chars"] = {c: i for i, c in enumerate(meta["chars"])}
|
| 115 |
+
_state["units"] = meta["units"]
|
| 116 |
+
_state["up"] = meta["up"]
|
| 117 |
+
_state["max_len"] = meta["max_len"]
|
| 118 |
+
_state["cache"] = {}
|
| 119 |
+
return _state
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def _units(text):
|
| 123 |
+
out = []
|
| 124 |
+
for unit in text.split():
|
| 125 |
+
stress = 0
|
| 126 |
+
for mark, level in MARKS.items():
|
| 127 |
+
if mark in unit:
|
| 128 |
+
stress = stress or level
|
| 129 |
+
unit = unit.replace(mark, "")
|
| 130 |
+
if unit:
|
| 131 |
+
out.append((unit, stress))
|
| 132 |
+
return out
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def word(w, austrian=False):
|
| 136 |
+
"""One written word -> [(phone, stress), ...]."""
|
| 137 |
+
if austrian and w in AUSTRIAN:
|
| 138 |
+
return _units(AUSTRIAN[w])
|
| 139 |
+
if w in EXCEPTIONS:
|
| 140 |
+
return _units(EXCEPTIONS[w])
|
| 141 |
+
s = _load()
|
| 142 |
+
cache = s["cache"]
|
| 143 |
+
if w in cache:
|
| 144 |
+
return cache[w]
|
| 145 |
+
if len(w) > s["max_len"]: # very long compound: read it in parts
|
| 146 |
+
half = len(w) // 2
|
| 147 |
+
result = word(w[:half]) + word(w[half:])
|
| 148 |
+
else:
|
| 149 |
+
ids = np.array([[s["chars"].get(c, 1) for c in w]], dtype=np.int64)
|
| 150 |
+
logp = s["session"].run(None, {"chars": ids})[0][0]
|
| 151 |
+
blank = len(s["units"])
|
| 152 |
+
best = logp.argmax(-1)
|
| 153 |
+
units, prev = [], None
|
| 154 |
+
for b in best:
|
| 155 |
+
if b != prev and b != blank:
|
| 156 |
+
units.append(s["units"][b])
|
| 157 |
+
prev = b
|
| 158 |
+
result = _units(" ".join(units))
|
| 159 |
+
if len(cache) < 100000:
|
| 160 |
+
cache[w] = result
|
| 161 |
+
return result
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def words(piece, austrian=False):
|
| 165 |
+
"""A text piece (normalized, no punctuation) -> words as lists of (phone, stress), like espeak_words."""
|
| 166 |
+
return [u for u in (word(w, austrian) for w in piece.split()) if u]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def phonemize(text, austrian=False):
|
| 170 |
+
"""Text -> tokens like tiny_voca.text.phonemize, with this model instead of eSpeak NG. ``austrian``: use the
|
| 171 |
+
Austrian readings (AUSTRIAN) - for the accent switch of apptor-tiny-tts-at."""
|
| 172 |
+
try:
|
| 173 |
+
from tiny_voca.normalize_de import normalize as normalize_german
|
| 174 |
+
from tiny_voca.text import chunks, normalize_text, tokenize
|
| 175 |
+
except ImportError: # flash-voice vendors the front end as "tinyvoca"
|
| 176 |
+
from tinyvoca.normalize_de import normalize as normalize_german
|
| 177 |
+
from tinyvoca.text import chunks, normalize_text, tokenize
|
| 178 |
+
if not isinstance(text, str) or not text.strip():
|
| 179 |
+
raise ValueError("text must not be empty")
|
| 180 |
+
pieces = [(True, p) if punct else (False, words(p, austrian))
|
| 181 |
+
for punct, p in chunks(normalize_text(normalize_german(normalize_text(text))))]
|
| 182 |
+
return tokenize(pieces)
|
tinyvoca/normalize_de.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""German text normalization before eSpeak: spell out what a speaker reads aloud
|
| 2 |
+
differently from eSpeak's defaults (abbreviations, clock times, money, ordinals
|
| 3 |
+
before months, percent, years). Used for annotation, training and inference alike.
|
| 4 |
+
"""
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
from num2words import num2words as _n2w
|
| 9 |
+
except ImportError: # eSpeak still reads plain numbers; only the special forms need num2words
|
| 10 |
+
_n2w = None
|
| 11 |
+
|
| 12 |
+
MONTHS = ("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")
|
| 13 |
+
ABBREVIATIONS = {
|
| 14 |
+
"z.B.": "zum Beispiel", "z. B.": "zum Beispiel", "d.h.": "das heißt", "d. h.": "das heißt", "u.a.": "unter anderem",
|
| 15 |
+
"usw.": "und so weiter", "bzw.": "beziehungsweise", "ca.": "circa", "vgl.": "vergleiche", "evtl.": "eventuell",
|
| 16 |
+
"ggf.": "gegebenenfalls", "inkl.": "inklusive", "Nr.": "Nummer", "Dr.": "Doktor", "Prof.": "Professor",
|
| 17 |
+
"Str.": "Straße", "Hr.": "Herr", "Fr.": "Frau", "St.": "Sankt", "etc.": "et cetera", "Mio.": "Millionen",
|
| 18 |
+
"Mrd.": "Milliarden", "km/h": "Kilometer pro Stunde", "€": " Euro", "%": " Prozent",
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _num(value, to="cardinal"):
|
| 23 |
+
if _n2w is None:
|
| 24 |
+
return str(value)
|
| 25 |
+
return _n2w(int(value), lang="de", to=to)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _ordinal(match):
|
| 29 |
+
word = _num(match[2], "ordinal") # "dritte"
|
| 30 |
+
prefix = match[1] or ""
|
| 31 |
+
# After a preposition/article in the dative ("am", "vom", "zum", "bis zum") the ending is -n.
|
| 32 |
+
if prefix.strip().lower() in ("am", "vom", "zum", "im", "ab dem", "bis zum", "seit dem", "dem", "den"):
|
| 33 |
+
word += "n"
|
| 34 |
+
return f"{prefix}{word} {match[3]}"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def _time(match):
|
| 38 |
+
hours, minutes = int(match[1]), int(match[2])
|
| 39 |
+
text = f"{_num(hours)} Uhr"
|
| 40 |
+
if hours == 1:
|
| 41 |
+
text = "ein Uhr"
|
| 42 |
+
return text + (f" {_num(minutes)}" if minutes else "")
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def _money(match):
|
| 46 |
+
euros, cents = int(match[1]), int(match[2])
|
| 47 |
+
text = f"{_num(euros)} Euro"
|
| 48 |
+
return text + (f" {_num(cents)}" if cents else "")
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def normalize(text):
|
| 52 |
+
for short, long in ABBREVIATIONS.items():
|
| 53 |
+
text = text.replace(short, long)
|
| 54 |
+
text = re.sub(r"\b(\d{1,2}):(\d{2})\s*Uhr\b", _time, text)
|
| 55 |
+
text = re.sub(r"\b(\d{1,2}):(\d{2})\b", _time, text)
|
| 56 |
+
text = re.sub(r"\b(\d+),(\d{2})\s*Euro\b", _money, text)
|
| 57 |
+
text = re.sub(r"\b((?:[Aa]m|[Vv]om|[Zz]um|[Bb]is zum|[Ss]eit dem|[Aa]b dem) )?(\d{1,2})\. (" + "|".join(MONTHS) + r")\b", _ordinal, text)
|
| 58 |
+
# Years after "im Jahr", or bare four-digit numbers 1100-1999 in running text, are read as years.
|
| 59 |
+
text = re.sub(r"\b(1[1-9]\d\d)\b", lambda m: _num(m[1], "year"), text)
|
| 60 |
+
text = re.sub(r"(\d+),(\d+)", lambda m: f"{_num(m[1])} Komma {' '.join(_num(d) for d in m[2])}", text)
|
| 61 |
+
text = re.sub(r"(?<![\w-])-(\d+)", lambda m: "minus " + m[1], text)
|
| 62 |
+
if _n2w is not None:
|
| 63 |
+
text = re.sub(r"\d+", lambda m: _num(m[0]), text)
|
| 64 |
+
text = text.replace("einstausend", "eintausend") # num2words: 101000 -> einhunderteinstausend
|
| 65 |
+
text = re.sub(r"\bein(hundert|tausend)", r"\1", text)
|
| 66 |
+
return re.sub(r"\s+", " ", text).strip()
|
tinyvoca/text.py
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""German front end (fork of the English tiny-voca front end): text -> phoneme tokens with a stress feature.
|
| 2 |
+
|
| 3 |
+
The same code runs during annotation, training-set preparation and inference,
|
| 4 |
+
so tokens can never drift between them. Two programs can produce the phonemes:
|
| 5 |
+
|
| 6 |
+
* ``espeak`` (front-end version 3, the default): eSpeak NG, as described below.
|
| 7 |
+
The current checkpoints and annotations were made with it.
|
| 8 |
+
* ``own`` (front-end version 4): the separate ``dizione`` package, a dictionary
|
| 9 |
+
built from CMUdict, a small model for unknown words and rules. No eSpeak, so
|
| 10 |
+
the whole system can be shipped under a permissive licence. Same 76 symbols.
|
| 11 |
+
|
| 12 |
+
Choose with ``set_frontend("own")`` or ``TINY_VOCA_FRONTEND=own``. Everything
|
| 13 |
+
below about tokens holds for both; the rest of this note is the eSpeak path.
|
| 14 |
+
|
| 15 |
+
* eSpeak NG (``en-us``) is the only pronunciation source. It is an external
|
| 16 |
+
rule-based program: no neural G2P and no downloaded weights.
|
| 17 |
+
* A token is one eSpeak phoneme exactly as eSpeak segments it (``--sep``), for
|
| 18 |
+
example ``t``, ``aɪ``, ``ɑːɹ`` or ``n̩``. This is also the label inventory of
|
| 19 |
+
the phoneme recogniser used for offline forced alignment, so one aligned
|
| 20 |
+
label corresponds to exactly one token.
|
| 21 |
+
* Lexical stress is a parallel feature (0 none, 1 primary, 2 secondary), not a
|
| 22 |
+
token, so it never has to be given audio frames.
|
| 23 |
+
* Punctuation, word boundaries and the utterance edges are explicit tokens that
|
| 24 |
+
may last zero frames. They carry pauses when the recording has them.
|
| 25 |
+
|
| 26 |
+
Versions 1 and 2 encoded IPA as UTF-8 bytes and piped text to eSpeak without a
|
| 27 |
+
final newline; eSpeak NG 1.51 then drops the last character of the input, so
|
| 28 |
+
the final phonemes of every clause were wrong. Version 3 terminates the input
|
| 29 |
+
and has a regression test for it.
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
from dataclasses import dataclass
|
| 33 |
+
import hashlib
|
| 34 |
+
import json
|
| 35 |
+
import os
|
| 36 |
+
import re
|
| 37 |
+
import shutil
|
| 38 |
+
import subprocess
|
| 39 |
+
import unicodedata
|
| 40 |
+
|
| 41 |
+
FRONTEND_VERSION = 103 # German fork: eSpeak NG "de", German phone inventory
|
| 42 |
+
ESPEAK_VOICE = "de"
|
| 43 |
+
SEPARATOR = "_"
|
| 44 |
+
FRONTENDS = ("espeak", "own")
|
| 45 |
+
FRONTEND_VARIABLE = "TINY_VOCA_FRONTEND"
|
| 46 |
+
_frontend = os.environ.get(FRONTEND_VARIABLE, "espeak")
|
| 47 |
+
if _frontend not in FRONTENDS:
|
| 48 |
+
raise ValueError(f"{FRONTEND_VARIABLE} must be one of {FRONTENDS}, not {_frontend!r}")
|
| 49 |
+
|
| 50 |
+
PAD, BOS, EOS, SP, UNK = "<pad>", "<bos>", "<eos>", "<sp>", "<unk>"
|
| 51 |
+
SPECIALS = (PAD, BOS, EOS, SP, UNK)
|
| 52 |
+
PUNCTUATION = (",", ".", "?", "!", ";", ":", '"', "'", "(", ")", "—", "…")
|
| 53 |
+
# German inventory: every phone is a label of the forced-alignment recogniser, except
|
| 54 |
+
# "ʊɐ", which eSpeak NG prints (and the recogniser was trained on) as "??".
|
| 55 |
+
CONSONANTS = ("p", "b", "t", "d", "k", "ɡ", "f", "v", "s", "z", "ʃ", "ʒ", "ç", "x", "h",
|
| 56 |
+
"m", "n", "ŋ", "l", "ɾ", "r", "j", "ts", "pf", "tʃ", "dʒ")
|
| 57 |
+
VOWELS = ("ə", "ɐ", "ɜ", "ɪ", "i", "iː", "ɛ", "ɛː", "eː", "a", "ɑ", "ɑː", "ɔ", "oː", "ʊ", "uː",
|
| 58 |
+
"y", "yː", "œ", "øː", "aɪ", "aʊ", "ɔø", "ʊɐ")
|
| 59 |
+
PHONES = CONSONANTS + VOWELS
|
| 60 |
+
SYMBOLS = SPECIALS + PUNCTUATION + PHONES
|
| 61 |
+
SYMBOL_TO_ID = {symbol: index for index, symbol in enumerate(SYMBOLS)}
|
| 62 |
+
PHONE_SET = frozenset(PHONES)
|
| 63 |
+
PHONE_IDS = frozenset(SYMBOL_TO_ID[p] for p in PHONES) | {SYMBOL_TO_ID[UNK]}
|
| 64 |
+
VOICELESS = frozenset(("p", "t", "k", "f", "s", "ʃ", "ç", "x", "h", "ts", "pf", "tʃ"))
|
| 65 |
+
VOWEL_SET = frozenset(VOWELS)
|
| 66 |
+
STRESS_MARKS = {"ˈ": 1, "ˌ": 2}
|
| 67 |
+
|
| 68 |
+
# eSpeak phonemes outside the inventory (English/French loan words, rare allophones).
|
| 69 |
+
FALLBACK = {
|
| 70 |
+
"??": ("ʊɐ",), "ɹ": ("ɾ",), "ʁ": ("ɾ",), "w": ("v",), "ð": ("d",), "θ": ("s",), "ʔ": (),
|
| 71 |
+
"e": ("eː",), "o": ("oː",), "u": ("uː",), "ø": ("øː",), "ɒ": ("ɔ",), "ʌ": ("a",), "æ": ("ɛ",),
|
| 72 |
+
"ɜː": ("øː",), "ɔː": ("oː",), "ɪː": ("iː",), "aː": ("ɑː",), "eɪ": ("eː",), "ɛɪ": ("eː",),
|
| 73 |
+
"əʊ": ("oː",), "oʊ": ("oː",), "eə": ("ɛː",), "ɪə": ("iː", "ɐ"), "ʊə": ("uː", "ɐ"), "aɪə": ("aɪ", "ɐ"),
|
| 74 |
+
"ɔɪ": ("ɔø",), "ɔʏ": ("ɔø",), "əl": ("ə", "l"), "l̩": ("ə", "l"), "n̩": ("ə", "n"), "m̩": ("ə", "m"),
|
| 75 |
+
"ɑ̃": ("ɑ", "ŋ"), "ɔ̃": ("ɔ", "ŋ"), "ɛ̃": ("ɛ", "ŋ"), "œ̃": ("œ", "ŋ"), "ʏ": ("y",), "ɚ": ("ɐ",),
|
| 76 |
+
"ɲ": ("n", "j"), "ɬ": ("l",), "ɫ": ("l",), "dz": ("d", "z"), "β": ("v",), "ɣ": ("ɡ",), "ʎ": ("l", "j"),
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
_QUOTES = str.maketrans({"‘": "'", "’": "'", "‚": "'", "‛": "'", "`": "'", "´": "'",
|
| 80 |
+
"“": '"', "”": '"', "„": '"', "‟": '"', "«": '"', "»": '"',
|
| 81 |
+
"–": "—", "―": "—", "[": "(", "{": "(", "]": ")", "}": ")"})
|
| 82 |
+
_PUNCTUATION_CHARS = frozenset(PUNCTUATION)
|
| 83 |
+
ABBREVIATIONS = {"dr", "prof", "nr", "str", "bzw", "ca", "usw", "vgl", "evtl", "ggf", "inkl", "hr", "fr", "st", "z", "b", "d", "h", "u", "a", "s", "o"}
|
| 84 |
+
_LANGUAGE_TAG = re.compile(r"\((?:_?[a-z0-9]_?){2,3}(?:-(?:_?[a-z0-9]_?)+)*\)")
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
@dataclass(frozen=True)
|
| 88 |
+
class Phonemized:
|
| 89 |
+
symbols: tuple
|
| 90 |
+
ids: tuple
|
| 91 |
+
stress: tuple
|
| 92 |
+
unknown: tuple # eSpeak phonemes that had no inventory mapping
|
| 93 |
+
|
| 94 |
+
def __len__(self):
|
| 95 |
+
return len(self.ids)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def frontend():
|
| 99 |
+
"""Name of the program that produces the phonemes: ``"espeak"`` or ``"own"``."""
|
| 100 |
+
return _frontend
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def set_frontend(name):
|
| 104 |
+
"""Select the phonemizer for this process. Tokens of the two front ends
|
| 105 |
+
must not be mixed: annotations and checkpoints record which one made them."""
|
| 106 |
+
global _frontend
|
| 107 |
+
if name not in FRONTENDS:
|
| 108 |
+
raise ValueError(f"front end must be one of {FRONTENDS}, not {name!r}")
|
| 109 |
+
_frontend = name
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def _dizione():
|
| 113 |
+
try:
|
| 114 |
+
import dizione
|
| 115 |
+
except ImportError as error:
|
| 116 |
+
raise RuntimeError('the "own" front end needs the dizione package: pip install dizione') from error
|
| 117 |
+
if tuple(dizione.symbols.SYMBOLS) != SYMBOLS:
|
| 118 |
+
raise RuntimeError("dizione's symbol inventory differs from this model's")
|
| 119 |
+
return dizione
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def frontend_identity():
|
| 123 |
+
if _frontend == "own":
|
| 124 |
+
phonemizer = _dizione()
|
| 125 |
+
return {"frontend_version": phonemizer.VERSION, "phonemizer": "dizione", "symbols": list(SYMBOLS)}
|
| 126 |
+
return {"frontend_version": FRONTEND_VERSION, "voice": ESPEAK_VOICE, "separator": SEPARATOR,
|
| 127 |
+
"symbols": list(SYMBOLS), "fallback": {key: list(value) for key, value in sorted(FALLBACK.items())}}
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def frontend_runtime():
|
| 131 |
+
"""What an annotation run records about the exact program behind its
|
| 132 |
+
tokens: the eSpeak version, or the fingerprint of the phonemizer build."""
|
| 133 |
+
if _frontend == "own":
|
| 134 |
+
return {"phonemizer": _dizione().identity()["fingerprint"]}
|
| 135 |
+
return {"espeak_version": espeak_version()}
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def frontend_fingerprint():
|
| 139 |
+
return hashlib.sha256(json.dumps(frontend_identity(), sort_keys=True, ensure_ascii=False).encode()).hexdigest()
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def normalize_text(text):
|
| 143 |
+
text = unicodedata.normalize("NFKC", text).translate(_QUOTES)
|
| 144 |
+
text = re.sub(r"\.{3,}", "…", text)
|
| 145 |
+
text = re.sub(r"-{2,}|\s-\s", "—", text)
|
| 146 |
+
return re.sub(r"\s+", " ", text).strip()
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def chunks(text):
|
| 150 |
+
"""Yield ``(is_punctuation, piece)``. Decimals, clock times, digit groups,
|
| 151 |
+
contractions, title abbreviations and initialisms stay inside the text piece
|
| 152 |
+
for eSpeak; every other punctuation mark becomes its own token."""
|
| 153 |
+
start = 0
|
| 154 |
+
for i, char in enumerate(text):
|
| 155 |
+
if char not in _PUNCTUATION_CHARS:
|
| 156 |
+
continue
|
| 157 |
+
previous = text[i-1] if i else ""
|
| 158 |
+
following = text[i+1] if i+1 < len(text) else ""
|
| 159 |
+
if char == "'" and previous.isalnum() and following.isalnum():
|
| 160 |
+
continue
|
| 161 |
+
if char in ".,:" and previous.isdigit() and following.isdigit():
|
| 162 |
+
continue
|
| 163 |
+
if char == "." and previous.isdigit() and following == " " and i+2 < len(text) and text[i+2].isalnum():
|
| 164 |
+
continue
|
| 165 |
+
if char == ".":
|
| 166 |
+
word = re.search(r"([A-Za-z]+)$", text[:i])
|
| 167 |
+
if word and word[1].lower() in ABBREVIATIONS:
|
| 168 |
+
continue
|
| 169 |
+
if previous.isalpha() and following.isalpha():
|
| 170 |
+
continue
|
| 171 |
+
if text[start:i].strip():
|
| 172 |
+
yield False, text[start:i].strip()
|
| 173 |
+
yield True, char
|
| 174 |
+
start = i+1
|
| 175 |
+
if text[start:].strip():
|
| 176 |
+
yield False, text[start:].strip()
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def espeak_executable():
|
| 180 |
+
executable = shutil.which("espeak-ng")
|
| 181 |
+
if executable is None:
|
| 182 |
+
raise RuntimeError("Install espeak-ng on the cloud machine before preprocessing/inference")
|
| 183 |
+
return executable
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def espeak_version():
|
| 187 |
+
return subprocess.run([espeak_executable(), "--version"], capture_output=True, text=True, check=True, timeout=10).stdout.strip()
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def espeak_words(piece):
|
| 191 |
+
"""Phonemize one text piece. Returns words as lists of ``(phone, stress)``.
|
| 192 |
+
|
| 193 |
+
The input must end with a newline: eSpeak NG 1.51 silently drops the last
|
| 194 |
+
character of unterminated standard input.
|
| 195 |
+
"""
|
| 196 |
+
result = subprocess.run(
|
| 197 |
+
[espeak_executable(), "-q", "--ipa", "--sep=" + SEPARATOR, "-v", ESPEAK_VOICE, "--stdin"],
|
| 198 |
+
input=piece.rstrip("\n") + "\n", text=True, capture_output=True, check=True, timeout=30)
|
| 199 |
+
return parse_espeak(result.stdout)
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def parse_espeak(output):
|
| 203 |
+
words = []
|
| 204 |
+
for word in _LANGUAGE_TAG.sub("", output).split():
|
| 205 |
+
units = []
|
| 206 |
+
for unit in word.split(SEPARATOR):
|
| 207 |
+
stress = 0
|
| 208 |
+
for mark, level in STRESS_MARKS.items():
|
| 209 |
+
if mark in unit:
|
| 210 |
+
stress = stress or level
|
| 211 |
+
unit = unit.replace(mark, "")
|
| 212 |
+
unit = "".join(c for c in unit if unicodedata.category(c) != "Cf" and c not in "()")
|
| 213 |
+
if unit:
|
| 214 |
+
units.append((unit, stress))
|
| 215 |
+
if units:
|
| 216 |
+
words.append(units)
|
| 217 |
+
return words
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def canonical(phone):
|
| 221 |
+
"""Map an eSpeak phoneme to inventory phones; ``None`` when unknown."""
|
| 222 |
+
if phone in PHONE_SET:
|
| 223 |
+
return (phone,)
|
| 224 |
+
if phone in FALLBACK:
|
| 225 |
+
return FALLBACK[phone]
|
| 226 |
+
stripped = "".join(c for c in unicodedata.normalize("NFD", phone) if not unicodedata.combining(c))
|
| 227 |
+
for candidate in (stripped, stripped.replace("ː", ""), stripped + "ː"):
|
| 228 |
+
if candidate != phone and candidate in PHONE_SET:
|
| 229 |
+
return (candidate,)
|
| 230 |
+
if candidate != phone and candidate in FALLBACK:
|
| 231 |
+
return FALLBACK[candidate]
|
| 232 |
+
return None
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def tokenize(pieces):
|
| 236 |
+
"""Build the token sequence from ``(is_punctuation, value)`` pieces where a
|
| 237 |
+
text piece's value is the parsed eSpeak word list. Pure function (testable
|
| 238 |
+
without eSpeak)."""
|
| 239 |
+
symbols, stress, unknown = [BOS], [0], []
|
| 240 |
+
for punctuation, value in pieces:
|
| 241 |
+
if punctuation:
|
| 242 |
+
if symbols[-1] != value: # collapse repeats such as "!!"
|
| 243 |
+
symbols.append(value)
|
| 244 |
+
stress.append(0)
|
| 245 |
+
continue
|
| 246 |
+
for word in value:
|
| 247 |
+
if symbols[-1] in PHONE_SET or symbols[-1] == UNK:
|
| 248 |
+
symbols.append(SP)
|
| 249 |
+
stress.append(0)
|
| 250 |
+
for phone, level in word:
|
| 251 |
+
mapped = canonical(phone)
|
| 252 |
+
if mapped is None:
|
| 253 |
+
unknown.append(phone)
|
| 254 |
+
mapped = (UNK,)
|
| 255 |
+
# A fallback may expand to several phones: stress goes to its first vowel.
|
| 256 |
+
carrier = next((i for i, item in enumerate(mapped) if item in VOWEL_SET), 0)
|
| 257 |
+
for index, item in enumerate(mapped):
|
| 258 |
+
symbols.append(item)
|
| 259 |
+
stress.append(level if index == carrier else 0)
|
| 260 |
+
symbols.append(EOS)
|
| 261 |
+
stress.append(0)
|
| 262 |
+
if not any(s in PHONE_SET or s == UNK for s in symbols):
|
| 263 |
+
raise ValueError("the text has nothing to pronounce")
|
| 264 |
+
return Phonemized(tuple(symbols), tuple(SYMBOL_TO_ID[s] for s in symbols), tuple(stress), tuple(unknown))
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def phonemize(text):
|
| 268 |
+
if not isinstance(text, str) or not text.strip():
|
| 269 |
+
raise ValueError("text must not be empty")
|
| 270 |
+
if _frontend == "own":
|
| 271 |
+
return tokenize(_dizione().pieces(text))
|
| 272 |
+
pieces = []
|
| 273 |
+
from .normalize_de import normalize as normalize_german
|
| 274 |
+
for punctuation, piece in chunks(normalize_text(normalize_german(normalize_text(text)))):
|
| 275 |
+
pieces.append((True, piece) if punctuation else (False, espeak_words(piece)))
|
| 276 |
+
return tokenize(pieces)
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def is_phone(token_ids):
|
| 280 |
+
"""Boolean list/tensor helper: tokens that must be realised as audio."""
|
| 281 |
+
return [int(i) in PHONE_IDS for i in token_ids]
|
web/.htaccess
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# apptor-tiny-tts demo (static). Multithreaded WebAssembly needs cross-origin isolation; large model files are cached.
|
| 2 |
+
<IfModule mod_headers.c>
|
| 3 |
+
Header always set Cross-Origin-Opener-Policy "same-origin"
|
| 4 |
+
Header always set Cross-Origin-Embedder-Policy "require-corp"
|
| 5 |
+
Header always set Cross-Origin-Resource-Policy "same-origin"
|
| 6 |
+
<FilesMatch "\.(onnx|wasm)$">
|
| 7 |
+
Header set Cache-Control "public, max-age=2592000, immutable"
|
| 8 |
+
</FilesMatch>
|
| 9 |
+
</IfModule>
|
| 10 |
+
AddType application/wasm .wasm
|
| 11 |
+
AddType application/octet-stream .onnx
|
| 12 |
+
AddType text/javascript .mjs
|
| 13 |
+
<IfModule mod_deflate.c>
|
| 14 |
+
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json application/wasm
|
| 15 |
+
</IfModule>
|
web/apptor-tts.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// apptor-tiny-tts in the browser (Apache 2.0): German / Austrian text -> speech, everything on the visitor's device.
|
| 2 |
+
// A port of the Python front end (tiny_voca normalize_de + text, with the own letter-to-sound model instead of
|
| 3 |
+
// eSpeak NG) plus the ONNX models: letter-to-sound (g2p), speech model (accent input), optional Vocos second stage.
|
| 4 |
+
// `ort` is onnxruntime-web (browser) or onnxruntime-node (tests), passed in by the caller.
|
| 5 |
+
|
| 6 |
+
// ------------------------------------------------------------------ German numbers (like num2words "de")
|
| 7 |
+
const ONES = ["null", "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf",
|
| 8 |
+
"dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"];
|
| 9 |
+
const TENS = ["", "", "zwanzig", "dreißig", "vierzig", "fünfzig", "sechzig", "siebzig", "achtzig", "neunzig"];
|
| 10 |
+
|
| 11 |
+
function below100(n, final) {
|
| 12 |
+
if (n < 20) return n === 1 ? (final ? "eins" : "ein") : ONES[n];
|
| 13 |
+
const u = n % 10, t = Math.floor(n / 10);
|
| 14 |
+
return (u ? (u === 1 ? "ein" : ONES[u]) + "und" : "") + TENS[t];
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function below1000(n, final) {
|
| 18 |
+
const h = Math.floor(n / 100), r = n % 100;
|
| 19 |
+
return (h ? (h === 1 ? "ein" : ONES[h]) + "hundert" : "") + (r ? below100(r, final) : "");
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function below1e6(n) {
|
| 23 |
+
const t = Math.floor(n / 1000), r = n % 1000;
|
| 24 |
+
return (t ? below1000(t, false) + "tausend" : "") + (r ? below1000(r, true) : "");
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
export function cardinal(value) {
|
| 28 |
+
let n = BigInt(value);
|
| 29 |
+
if (n === 0n) return "null";
|
| 30 |
+
const parts = [];
|
| 31 |
+
const big = [[10n ** 12n, "Billion", "Billionen"], [10n ** 9n, "Milliarde", "Milliarden"], [10n ** 6n, "Million", "Millionen"]];
|
| 32 |
+
for (const [unit, one, many] of big) {
|
| 33 |
+
if (n >= unit) {
|
| 34 |
+
const k = n / unit;
|
| 35 |
+
n %= unit;
|
| 36 |
+
parts.push(k === 1n ? `eine ${one}` : `${cardinal(k)} ${many}`);
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
if (n > 0n) parts.push(below1e6(Number(n)));
|
| 40 |
+
return parts.join(" ");
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
export function ordinal(value) {
|
| 44 |
+
// used for days of the month (1-31); larger numbers follow the same rule
|
| 45 |
+
const n = Number(value);
|
| 46 |
+
const word = cardinal(n), last = n % 100;
|
| 47 |
+
if (last === 0 || last >= 20) return word + "ste";
|
| 48 |
+
for (const [end, repl] of [["eins", "erste"], ["drei", "dritte"], ["sieben", "siebte"], ["acht", "achte"]])
|
| 49 |
+
if (word.endsWith(end) && !word.endsWith("zehn")) return word.slice(0, -end.length) + repl;
|
| 50 |
+
return word + "te";
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export function year(value) {
|
| 54 |
+
const n = Number(value);
|
| 55 |
+
const h = Math.floor(n / 100), r = n % 100;
|
| 56 |
+
return below100(h, true) + "hundert" + (r ? below100(r, true) : "");
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
// ------------------------------------------------------------------ text normalisation (tiny_voca normalize_de/text)
|
| 60 |
+
const W = "[\\p{L}\\p{N}_]"; // Python's \w (Unicode)
|
| 61 |
+
const B0 = `(?<!${W})`, B1 = `(?!${W})`; // Python's \b at the start / end of a word
|
| 62 |
+
|
| 63 |
+
const QUOTES = {"‘": "'", "’": "'", "‚": "'", "‛": "'", "`": "'", "´": "'", "“": '"', "”": '"', "„": '"', "‟": '"',
|
| 64 |
+
"«": '"', "»": '"', "–": "—", "―": "—", "[": "(", "{": "(", "]": ")", "}": ")"};
|
| 65 |
+
|
| 66 |
+
export function normalizeText(text) {
|
| 67 |
+
text = text.normalize("NFKC").replace(/./gsu, c => QUOTES[c] ?? c);
|
| 68 |
+
text = text.replace(/\.{3,}/g, "…");
|
| 69 |
+
text = text.replace(/-{2,}|\s-\s/g, "—");
|
| 70 |
+
return text.replace(/\s+/g, " ").trim();
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
export function makeNormalizeGerman(F) {
|
| 74 |
+
const months = F.months.join("|");
|
| 75 |
+
const time = (h, m) => (Number(h) === 1 ? "ein Uhr" : `${cardinal(h)} Uhr`) + (Number(m) ? ` ${cardinal(m)}` : "");
|
| 76 |
+
const dative = new Set(["am", "vom", "zum", "im", "ab dem", "bis zum", "seit dem", "dem", "den"]);
|
| 77 |
+
return function normalizeGerman(text) {
|
| 78 |
+
for (const [short, long] of F.abbreviations) text = text.split(short).join(long);
|
| 79 |
+
text = text.replace(new RegExp(`${B0}(\\d{1,2}):(\\d{2})\\s*Uhr${B1}`, "gu"), (_, h, m) => time(h, m));
|
| 80 |
+
text = text.replace(new RegExp(`${B0}(\\d{1,2}):(\\d{2})${B1}`, "gu"), (_, h, m) => time(h, m));
|
| 81 |
+
text = text.replace(new RegExp(`${B0}(\\d+),(\\d{2})\\s*Euro${B1}`, "gu"),
|
| 82 |
+
(_, e, c) => `${cardinal(e)} Euro` + (Number(c) ? ` ${cardinal(c)}` : ""));
|
| 83 |
+
text = text.replace(new RegExp(`${B0}((?:[Aa]m|[Vv]om|[Zz]um|[Bb]is zum|[Ss]eit dem|[Aa]b dem) )?(\\d{1,2})\\. (${months})${B1}`, "gu"),
|
| 84 |
+
(_, prefix, d, month) => {
|
| 85 |
+
prefix = prefix || "";
|
| 86 |
+
let word = ordinal(d);
|
| 87 |
+
if (dative.has(prefix.trim().toLowerCase())) word += "n";
|
| 88 |
+
return `${prefix}${word} ${month}`;
|
| 89 |
+
});
|
| 90 |
+
text = text.replace(new RegExp(`${B0}(1[1-9]\\d\\d)${B1}`, "gu"), (_, y) => year(y));
|
| 91 |
+
text = text.replace(/(\d+),(\d+)/g, (_, a, b) => `${cardinal(a)} Komma ${[...b].map(cardinal).join(" ")}`);
|
| 92 |
+
text = text.replace(new RegExp(`(?<![\\p{L}\\p{N}_-])-(\\d+)`, "gu"), (_, d) => "minus " + d);
|
| 93 |
+
text = text.replace(/\d+/g, d => cardinal(d));
|
| 94 |
+
text = text.replace(new RegExp(`${B0}ein(hundert|tausend)`, "gu"), "$1");
|
| 95 |
+
return text.replace(/\s+/g, " ").trim();
|
| 96 |
+
};
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
const isDigit = c => /\p{N}/u.test(c);
|
| 100 |
+
const isAlpha = c => /\p{L}/u.test(c);
|
| 101 |
+
const isAlnum = c => /[\p{L}\p{N}]/u.test(c);
|
| 102 |
+
|
| 103 |
+
export function makeChunks(F) {
|
| 104 |
+
const punct = new Set(F.punctuation);
|
| 105 |
+
const abbrev = new Set(F.chunk_abbreviations);
|
| 106 |
+
return function chunks(text) {
|
| 107 |
+
const out = [];
|
| 108 |
+
const chars = [...text];
|
| 109 |
+
let start = 0;
|
| 110 |
+
for (let i = 0; i < chars.length; i++) {
|
| 111 |
+
const c = chars[i];
|
| 112 |
+
if (!punct.has(c)) continue;
|
| 113 |
+
const prev = i ? chars[i - 1] : "", next = i + 1 < chars.length ? chars[i + 1] : "";
|
| 114 |
+
if (c === "'" && prev && next && isAlnum(prev) && isAlnum(next)) continue;
|
| 115 |
+
if (".,:".includes(c) && prev && next && isDigit(prev) && isDigit(next)) continue;
|
| 116 |
+
if (c === "." && prev && isDigit(prev) && next === " " && i + 2 < chars.length && isAlnum(chars[i + 2])) continue;
|
| 117 |
+
if (c === ".") {
|
| 118 |
+
const m = chars.slice(0, i).join("").match(/([A-Za-z]+)$/);
|
| 119 |
+
if (m && abbrev.has(m[1].toLowerCase())) continue;
|
| 120 |
+
if (prev && next && isAlpha(prev) && isAlpha(next)) continue;
|
| 121 |
+
}
|
| 122 |
+
const piece = chars.slice(start, i).join("").trim();
|
| 123 |
+
if (piece) out.push([false, piece]);
|
| 124 |
+
out.push([true, c]);
|
| 125 |
+
start = i + 1;
|
| 126 |
+
}
|
| 127 |
+
const rest = chars.slice(start).join("").trim();
|
| 128 |
+
if (rest) out.push([false, rest]);
|
| 129 |
+
return out;
|
| 130 |
+
};
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// ------------------------------------------------------------------ letter-to-sound model
|
| 134 |
+
export class G2P {
|
| 135 |
+
// austrian: {word: "phones with stress marks"} used when the Austrian accent is on (see g2p_de.py AUSTRIAN)
|
| 136 |
+
constructor(ort, session, meta, exceptions = {}, austrian = {}) {
|
| 137 |
+
this.ort = ort; this.session = session; this.meta = meta; this.exceptions = exceptions; this.austrian = austrian;
|
| 138 |
+
this.chars = new Map(meta.chars.map((c, i) => [c, i]));
|
| 139 |
+
this.cache = new Map();
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
static async load(ort, url, metaUrl, {exceptions = {}, austrian = {}, options} = {}) {
|
| 143 |
+
const meta = await (await fetch(metaUrl)).json();
|
| 144 |
+
const session = await ort.InferenceSession.create(url, options);
|
| 145 |
+
return new G2P(ort, session, meta, exceptions, austrian);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
static units(text) {
|
| 149 |
+
return text.split(/\s+/).filter(Boolean).map(u => {
|
| 150 |
+
let stress = 0;
|
| 151 |
+
if (u.includes("ˈ")) stress = 1; else if (u.includes("ˌ")) stress = 2;
|
| 152 |
+
return [u.replace(/[ˈˌ]/g, ""), stress];
|
| 153 |
+
}).filter(([u]) => u);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
async word(w, austrian = false) {
|
| 157 |
+
if (austrian && this.austrian[w]) return G2P.units(this.austrian[w]);
|
| 158 |
+
if (this.exceptions[w]) return G2P.units(this.exceptions[w]);
|
| 159 |
+
if (this.cache.has(w)) return this.cache.get(w);
|
| 160 |
+
const letters = [...w];
|
| 161 |
+
let result;
|
| 162 |
+
if (letters.length > this.meta.max_len) {
|
| 163 |
+
const half = Math.floor(letters.length / 2);
|
| 164 |
+
result = [...await this.word(letters.slice(0, half).join("")), ...await this.word(letters.slice(half).join(""))];
|
| 165 |
+
} else {
|
| 166 |
+
const ids = BigInt64Array.from(letters.map(c => BigInt(this.chars.get(c) ?? 1)));
|
| 167 |
+
const out = await this.session.run({chars: new this.ort.Tensor("int64", ids, [1, ids.length])});
|
| 168 |
+
const logp = out.logp, [, T, C] = logp.dims, data = logp.data;
|
| 169 |
+
const blank = this.meta.units.length, units = [];
|
| 170 |
+
let prev = -1;
|
| 171 |
+
for (let t = 0; t < T; t++) {
|
| 172 |
+
let best = 0, bv = -Infinity;
|
| 173 |
+
for (let c = 0; c < C; c++) { const v = data[t * C + c]; if (v > bv) { bv = v; best = c; } }
|
| 174 |
+
if (best !== prev && best !== blank) units.push(this.meta.units[best]);
|
| 175 |
+
prev = best;
|
| 176 |
+
}
|
| 177 |
+
result = G2P.units(units.join(" "));
|
| 178 |
+
}
|
| 179 |
+
if (this.cache.size < 50000) this.cache.set(w, result);
|
| 180 |
+
return result;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
async words(piece, austrian = false) {
|
| 184 |
+
const out = [];
|
| 185 |
+
for (const w of piece.split(" ").filter(Boolean)) { const u = await this.word(w, austrian); if (u.length) out.push(u); }
|
| 186 |
+
return out;
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
// ------------------------------------------------------------------ phonemes -> tokens (tiny_voca text.tokenize)
|
| 191 |
+
export function makeTokenize(F) {
|
| 192 |
+
const ids = new Map(F.symbols.map((s, i) => [s, i]));
|
| 193 |
+
const phones = new Set(F.phones), vowels = new Set(F.vowels);
|
| 194 |
+
const {bos, eos, sp, unk} = F.specials;
|
| 195 |
+
function canonical(phone) {
|
| 196 |
+
if (phones.has(phone)) return [phone];
|
| 197 |
+
if (F.fallback[phone]) return F.fallback[phone];
|
| 198 |
+
const stripped = phone.normalize("NFD").replace(/\p{M}/gu, "");
|
| 199 |
+
for (const cand of [stripped, stripped.replaceAll("ː", ""), stripped + "ː"]) {
|
| 200 |
+
if (cand !== phone && phones.has(cand)) return [cand];
|
| 201 |
+
if (cand !== phone && F.fallback[cand]) return F.fallback[cand];
|
| 202 |
+
}
|
| 203 |
+
return null;
|
| 204 |
+
}
|
| 205 |
+
return function tokenize(pieces) {
|
| 206 |
+
const symbols = [bos], stress = [0];
|
| 207 |
+
for (const [isPunct, value] of pieces) {
|
| 208 |
+
if (isPunct) {
|
| 209 |
+
if (symbols[symbols.length - 1] !== value) { symbols.push(value); stress.push(0); }
|
| 210 |
+
continue;
|
| 211 |
+
}
|
| 212 |
+
for (const word of value) {
|
| 213 |
+
const last = symbols[symbols.length - 1];
|
| 214 |
+
if (phones.has(last) || last === unk) { symbols.push(sp); stress.push(0); }
|
| 215 |
+
for (const [phone, level] of word) {
|
| 216 |
+
const mapped = canonical(phone) ?? [unk];
|
| 217 |
+
let carrier = mapped.findIndex(p => vowels.has(p));
|
| 218 |
+
if (carrier < 0) carrier = 0;
|
| 219 |
+
mapped.forEach((p, i) => { symbols.push(p); stress.push(i === carrier ? level : 0); });
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
symbols.push(eos); stress.push(0);
|
| 224 |
+
if (!symbols.some(s => phones.has(s) || s === unk)) throw new Error("nothing to pronounce");
|
| 225 |
+
return {symbols, ids: symbols.map(s => ids.get(s)), stress};
|
| 226 |
+
};
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
export function makeFrontEnd(F, g2p) {
|
| 230 |
+
const normalizeGerman = makeNormalizeGerman(F), chunks = makeChunks(F), tokenize = makeTokenize(F);
|
| 231 |
+
return async function phonemize(text, {austrian = false} = {}) {
|
| 232 |
+
const pieces = [];
|
| 233 |
+
for (const [isPunct, piece] of chunks(normalizeText(normalizeGerman(normalizeText(text)))))
|
| 234 |
+
pieces.push(isPunct ? [true, piece] : [false, await g2p.words(piece, austrian)]);
|
| 235 |
+
return tokenize(pieces);
|
| 236 |
+
};
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
// ------------------------------------------------------------------ Vocos kernels (vocos_export.py kernels())
|
| 240 |
+
export function vocosKernels(ort, nFft = 1024) {
|
| 241 |
+
const bins = nFft / 2 + 1;
|
| 242 |
+
const real = new Float32Array(bins * nFft), imag = new Float32Array(bins * nFft), synth = new Float32Array(2 * bins * nFft);
|
| 243 |
+
const w = Float64Array.from({length: nFft}, (_, n) => 0.5 - 0.5 * Math.cos(2 * Math.PI * n / nFft));
|
| 244 |
+
for (let k = 0; k < bins; k++) {
|
| 245 |
+
const c = (k === 0 || k === nFft / 2 ? 1 : 2) / nFft;
|
| 246 |
+
for (let n = 0; n < nFft; n++) {
|
| 247 |
+
const a = 2 * Math.PI * ((k * n) % nFft) / nFft, cs = Math.cos(a), sn = Math.sin(a);
|
| 248 |
+
real[k * nFft + n] = w[n] * cs;
|
| 249 |
+
imag[k * nFft + n] = -w[n] * sn;
|
| 250 |
+
synth[k * nFft + n] = c * cs * w[n];
|
| 251 |
+
synth[(bins + k) * nFft + n] = -c * sn * w[n];
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
return {a_real: new ort.Tensor("float32", real, [bins, 1, nFft]), a_imag: new ort.Tensor("float32", imag, [bins, 1, nFft]),
|
| 255 |
+
synth: new ort.Tensor("float32", synth, [2 * bins, 1, nFft])};
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// ------------------------------------------------------------------ the voice
|
| 259 |
+
// Cut the breathy noise after the last sound (the Austrian style learned it from Common Voice recordings; after a
|
| 260 |
+
// final "p" it sounds like an "f"): keep up to the last 10 ms frame within 30 dB of the loudest one, then fade 40 ms.
|
| 261 |
+
export function trimTail(audio, sr, floorDb = -30, fadeMs = 40) {
|
| 262 |
+
const hop = Math.round(sr / 100), e = [];
|
| 263 |
+
for (let s = 0; s + hop <= audio.length; s += hop) { let x = 0; for (let n = 0; n < hop; n++) x += audio[s + n] ** 2; e.push(x); }
|
| 264 |
+
const peak = Math.max(0, ...e), floor = peak * 10 ** (floorDb / 10);
|
| 265 |
+
let last = e.length - 1; while (last > 0 && e[last] < floor) last--;
|
| 266 |
+
const fade = Math.round(fadeMs * sr / 1000), end = Math.min(audio.length, (last + 1) * hop + fade);
|
| 267 |
+
if (!peak || end >= audio.length) return audio;
|
| 268 |
+
const out = audio.slice(0, end);
|
| 269 |
+
for (let i = 0; i < fade; i++) out[end - fade + i] *= 0.5 + 0.5 * Math.cos(Math.PI * (i + 1) / fade);
|
| 270 |
+
return out;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
export class Voice {
|
| 274 |
+
constructor(ort, tts, meta, phonemize, vocos = null) {
|
| 275 |
+
Object.assign(this, {ort, tts, meta, phonemize, vocos});
|
| 276 |
+
this.kernels = vocos ? vocosKernels(ort) : null;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
setVocos(vocos) { this.vocos = vocos; this.kernels = this.kernels || vocosKernels(this.ort); }
|
| 280 |
+
|
| 281 |
+
// Sentences, then clauses, so that no piece exceeds the model's token limit.
|
| 282 |
+
// quickStart: also cut a long first sentence at its commas, so that playback can start sooner.
|
| 283 |
+
async parts(text, austrian = false, quickStart = false) {
|
| 284 |
+
const out = [];
|
| 285 |
+
const sentences = text.trim().split(/(?<=[.!?…])\s+/).filter(Boolean);
|
| 286 |
+
if (quickStart && sentences.length && sentences[0].length > 60) sentences.splice(0, 1, ...sentences[0].split(/(?<=[,;:—])\s+/));
|
| 287 |
+
for (const sentence of sentences) {
|
| 288 |
+
let p;
|
| 289 |
+
try { p = await this.phonemize(sentence, {austrian}); } catch (e) { console.warn("skipped:", sentence, e); continue; }
|
| 290 |
+
if (p.ids.length <= this.meta.max_tokens) { out.push(p); continue; }
|
| 291 |
+
let pieces = sentence.split(/(?<=[,;:—])\s+/);
|
| 292 |
+
if (pieces.length === 1) { const w = sentence.split(" "); const h = w.length >> 1; pieces = [w.slice(0, h).join(" "), w.slice(h).join(" ")]; }
|
| 293 |
+
for (const piece of pieces) out.push(...await this.parts(piece, austrian));
|
| 294 |
+
}
|
| 295 |
+
return out;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// -> Float32Array at meta.sample_rate. voice: "F2" | "M2"; accent: 0 (Hochdeutsch) .. 1.6.
|
| 299 |
+
// onChunk(audio, index): called with each sentence as soon as it is ready (play while the rest is computed);
|
| 300 |
+
// cancelled(): checked before each sentence, return true to stop early.
|
| 301 |
+
async speak(text, {voice = "F2", accent = 1.0, speed = 1.0, gap = 0.12, onChunk = null, cancelled = () => false} = {}) {
|
| 302 |
+
const T = this.ort.Tensor, f = v => new T("float32", Float32Array.of(v), [1]);
|
| 303 |
+
const chunks = [];
|
| 304 |
+
let index = 0;
|
| 305 |
+
for (const p of await this.parts(text, accent >= 0.5, !!onChunk)) {
|
| 306 |
+
if (cancelled()) break;
|
| 307 |
+
const n = p.ids.length;
|
| 308 |
+
const feeds = {
|
| 309 |
+
tokens: new T("int64", BigInt64Array.from(p.ids.map(BigInt)), [1, n]),
|
| 310 |
+
stress: new T("int64", BigInt64Array.from(p.stress.map(BigInt)), [1, n]),
|
| 311 |
+
voice: new T("int64", BigInt64Array.of(BigInt(this.meta.voices.indexOf(voice))), [1]),
|
| 312 |
+
speed: f(speed), pitch_shift: f(0), pitch_range: f(1),
|
| 313 |
+
};
|
| 314 |
+
if (this.meta.inputs.includes("accent")) feeds.accent = f(accent);
|
| 315 |
+
let audio = (await this.tts.run(feeds)).audio.data;
|
| 316 |
+
if (this.vocos) {
|
| 317 |
+
// copies: with ort.env.wasm.proxy the input buffers are handed to the worker and are gone afterwards
|
| 318 |
+
const n = audio.length, k = this.kernels, copy = t => new T("float32", t.data.slice(), t.dims);
|
| 319 |
+
const out = (await this.vocos.run({audio: new T("float32", audio.slice(), [1, n]),
|
| 320 |
+
a_real: copy(k.a_real), a_imag: copy(k.a_imag), synth: copy(k.synth)})).output.data;
|
| 321 |
+
audio = out.slice(0, Math.min(out.length, n));
|
| 322 |
+
}
|
| 323 |
+
audio = trimTail(audio, this.meta.sample_rate);
|
| 324 |
+
let peak = 0; for (const v of audio) peak = Math.max(peak, Math.abs(v));
|
| 325 |
+
const g = peak > 0.95 ? 0.95 / peak : 1;
|
| 326 |
+
if (chunks.length) chunks.push(new Float32Array(Math.round(gap * this.meta.sample_rate)));
|
| 327 |
+
const piece = g === 1 ? audio : audio.map(v => v * g);
|
| 328 |
+
chunks.push(piece);
|
| 329 |
+
if (onChunk) onChunk(piece, index);
|
| 330 |
+
index++;
|
| 331 |
+
}
|
| 332 |
+
const total = chunks.reduce((s, c) => s + c.length, 0), out = new Float32Array(total);
|
| 333 |
+
let o = 0; for (const c of chunks) { out.set(c, o); o += c.length; }
|
| 334 |
+
return out;
|
| 335 |
+
}
|
| 336 |
+
}
|
web/austrian-de.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Kaffee": "k a f eːˈ",
|
| 3 |
+
"Kaffees": "k a f eːˈ s",
|
| 4 |
+
"Kaffeehaus": "k a f eːˈ h aʊˌ s",
|
| 5 |
+
"Kaffeehäuser": "k a f eːˈ h ɔøˌ z ɜ",
|
| 6 |
+
"Tabak": "t a b aˈ k",
|
| 7 |
+
"Mathematik": "m a t eːˈ m a t ɪ k",
|
| 8 |
+
"Chemie": "k eː m iːˈ",
|
| 9 |
+
"Chemiker": "k eːˈ m ɪ k ɜ",
|
| 10 |
+
"Chemikalien": "k eːˌ m iː k ɑˈ l ɪ ə n",
|
| 11 |
+
"chemisch": "k eːˈ m ɪ ʃ",
|
| 12 |
+
"chemische": "k eːˈ m ɪ ʃ ə",
|
| 13 |
+
"chemischen": "k eːˈ m ɪ ʃ ə n",
|
| 14 |
+
"China": "k iːˈ n ɑː",
|
| 15 |
+
"Chinese": "k iː n eːˈ z ə",
|
| 16 |
+
"Chinesen": "k iː n eːˈ z ə n",
|
| 17 |
+
"chinesisch": "k iː n eːˈ z ɪ ʃ",
|
| 18 |
+
"chinesische": "k iː n eːˈ z ɪ ʃ ə",
|
| 19 |
+
"Chirurg": "k iː r ??ˈ k",
|
| 20 |
+
"Motor": "m oː t oːˈ ɾ",
|
| 21 |
+
"Platin": "p l a t iːˈ n",
|
| 22 |
+
"Billard": "b ɪ j ɑːˈ ɾ",
|
| 23 |
+
"Garage": "ɡ a r ɑːˈ ʃ",
|
| 24 |
+
"Donnerstag": "d ɔˈ n ɐ s d ɑː k",
|
| 25 |
+
"Donnerstags": "d ɔˈ n ɐ s d ɑː k s"
|
| 26 |
+
}
|
web/exceptions-de.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Helene": "h eː l eːˈ n ə",
|
| 3 |
+
"Diana": "d i aˈ n ɑː",
|
| 4 |
+
"Dianna": "d i aˈ n ɑː",
|
| 5 |
+
"Daniela": "d a n i eːˈ l ɑː",
|
| 6 |
+
"Melanie": "m eːˈ l a n iː",
|
| 7 |
+
"Valentina": "v a l ɛ n t iːˈ n ɑː",
|
| 8 |
+
"Theresa": "t eː r eːˈ z ɑː",
|
| 9 |
+
"Elisabeth": "eː l iːˈ z a b ɛ t",
|
| 10 |
+
"Alexander": "a l ɛ k s aˈ n d ɜ",
|
| 11 |
+
"Andreas": "a n d r eːˈ a s",
|
| 12 |
+
"Matthias": "m a t iːˈ a s",
|
| 13 |
+
"Tobias": "t oː b iːˈ a s",
|
| 14 |
+
"Florian": "f l oːˈ r i a n",
|
| 15 |
+
"Sebastian": "z eː b aˈ s t i a n",
|
| 16 |
+
"Stefanie": "ʃ t eːˈ f a n iː",
|
| 17 |
+
"Christina": "k r ɪ s t iːˈ n ɑː",
|
| 18 |
+
"Magdalena": "m a k d a l eːˈ n ɑː",
|
| 19 |
+
"Veronika": "v eː r oːˈ n i k ɑː",
|
| 20 |
+
"Monika": "m oːˈ n i k ɑː",
|
| 21 |
+
"Angelika": "a ŋ ɡ eːˈ l i k ɑː",
|
| 22 |
+
"Leonie": "l eː oːˈ n iː",
|
| 23 |
+
"Emilia": "eː m iːˈ l i ɑː",
|
| 24 |
+
"David": "d ɑːˈ v ɪ t",
|
| 25 |
+
"Raphael": "r ɑːˈ f a eː l",
|
| 26 |
+
"Michael": "m ɪˈ ç a eː l",
|
| 27 |
+
"Manuel": "m ɑːˈ n uː ɛ l",
|
| 28 |
+
"Maximilian": "m a k s i m iːˈ l i ɑː n",
|
| 29 |
+
"Julia": "j uːˈ l i ɑː",
|
| 30 |
+
"Sarah": "z ɑːˈ r ɑː",
|
| 31 |
+
"Barbara": "b aˈ ɾ b a r ɑː",
|
| 32 |
+
"Gabriele": "ɡ a b r i eːˈ l ə",
|
| 33 |
+
"Ursula": "ʊˈ ɾ z uː l ɑː",
|
| 34 |
+
"Irene": "iː r eːˈ n ə",
|
| 35 |
+
"Miriam": "m iːˈ r i a m",
|
| 36 |
+
"Marlene": "m a ɾ l eːˈ n ə",
|
| 37 |
+
"Helena": "h eːˈ l eː n ɑː",
|
| 38 |
+
"Elena": "eːˈ l eː n ɑː",
|
| 39 |
+
"Selina": "z eː l iːˈ n ɑː",
|
| 40 |
+
"Martina": "m a ɾ t iːˈ n ɑː",
|
| 41 |
+
"Claudia": "k l aʊˈ d i ɑː",
|
| 42 |
+
"Ingrid": "ɪˈ ŋ ɡ r ɪ t",
|
| 43 |
+
"Leopold": "l eːˈ oː p ɔ l t",
|
| 44 |
+
"Ferdinand": "f ɛˈ ɾ d i n a n t",
|
| 45 |
+
"Dominik": "d oːˈ m i n ɪ k",
|
| 46 |
+
"Fabian": "f ɑːˈ b i a n",
|
| 47 |
+
"Kilian": "k iːˈ l i a n",
|
| 48 |
+
"Elias": "eː l iːˈ a s",
|
| 49 |
+
"Noah": "n oːˈ a",
|
| 50 |
+
"Anton": "aˈ n t oː n",
|
| 51 |
+
"Dorothea": "d oː r oː t eːˈ ɑː",
|
| 52 |
+
"Cornelia": "k ɔ ɾ n eːˈ l i ɑː",
|
| 53 |
+
"Philomena": "f i l oː m eːˈ n ɑː",
|
| 54 |
+
"Aurelia": "aʊ r eːˈ l i ɑː",
|
| 55 |
+
"Antonia": "a n t oːˈ n i ɑː",
|
| 56 |
+
"Paulina": "p aʊ l iːˈ n ɑː",
|
| 57 |
+
"Juliana": "j uː l i ɑːˈ n ɑː",
|
| 58 |
+
"Liliana": "l i l i ɑːˈ n ɑː",
|
| 59 |
+
"Adriana": "a d r i ɑːˈ n ɑː",
|
| 60 |
+
"Tatjana": "t a t j ɑːˈ n ɑː",
|
| 61 |
+
"Svetlana": "s v ɛ t l ɑːˈ n ɑː",
|
| 62 |
+
"Milena": "m i l eːˈ n ɑː",
|
| 63 |
+
"Daria": "d ɑːˈ r i ɑː",
|
| 64 |
+
"Mariana": "m a r i ɑːˈ n ɑː",
|
| 65 |
+
"Ariana": "a r i ɑːˈ n ɑː"
|
| 66 |
+
}
|
web/frontend-de.json
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"symbols": [
|
| 3 |
+
"<pad>",
|
| 4 |
+
"<bos>",
|
| 5 |
+
"<eos>",
|
| 6 |
+
"<sp>",
|
| 7 |
+
"<unk>",
|
| 8 |
+
",",
|
| 9 |
+
".",
|
| 10 |
+
"?",
|
| 11 |
+
"!",
|
| 12 |
+
";",
|
| 13 |
+
":",
|
| 14 |
+
"\"",
|
| 15 |
+
"'",
|
| 16 |
+
"(",
|
| 17 |
+
")",
|
| 18 |
+
"—",
|
| 19 |
+
"…",
|
| 20 |
+
"p",
|
| 21 |
+
"b",
|
| 22 |
+
"t",
|
| 23 |
+
"d",
|
| 24 |
+
"k",
|
| 25 |
+
"ɡ",
|
| 26 |
+
"f",
|
| 27 |
+
"v",
|
| 28 |
+
"s",
|
| 29 |
+
"z",
|
| 30 |
+
"ʃ",
|
| 31 |
+
"ʒ",
|
| 32 |
+
"ç",
|
| 33 |
+
"x",
|
| 34 |
+
"h",
|
| 35 |
+
"m",
|
| 36 |
+
"n",
|
| 37 |
+
"ŋ",
|
| 38 |
+
"l",
|
| 39 |
+
"ɾ",
|
| 40 |
+
"r",
|
| 41 |
+
"j",
|
| 42 |
+
"ts",
|
| 43 |
+
"pf",
|
| 44 |
+
"tʃ",
|
| 45 |
+
"dʒ",
|
| 46 |
+
"ə",
|
| 47 |
+
"ɐ",
|
| 48 |
+
"ɜ",
|
| 49 |
+
"ɪ",
|
| 50 |
+
"i",
|
| 51 |
+
"iː",
|
| 52 |
+
"ɛ",
|
| 53 |
+
"ɛː",
|
| 54 |
+
"eː",
|
| 55 |
+
"a",
|
| 56 |
+
"ɑ",
|
| 57 |
+
"ɑː",
|
| 58 |
+
"ɔ",
|
| 59 |
+
"oː",
|
| 60 |
+
"ʊ",
|
| 61 |
+
"uː",
|
| 62 |
+
"y",
|
| 63 |
+
"yː",
|
| 64 |
+
"œ",
|
| 65 |
+
"øː",
|
| 66 |
+
"aɪ",
|
| 67 |
+
"aʊ",
|
| 68 |
+
"ɔø",
|
| 69 |
+
"ʊɐ"
|
| 70 |
+
],
|
| 71 |
+
"phones": [
|
| 72 |
+
"p",
|
| 73 |
+
"b",
|
| 74 |
+
"t",
|
| 75 |
+
"d",
|
| 76 |
+
"k",
|
| 77 |
+
"ɡ",
|
| 78 |
+
"f",
|
| 79 |
+
"v",
|
| 80 |
+
"s",
|
| 81 |
+
"z",
|
| 82 |
+
"ʃ",
|
| 83 |
+
"ʒ",
|
| 84 |
+
"ç",
|
| 85 |
+
"x",
|
| 86 |
+
"h",
|
| 87 |
+
"m",
|
| 88 |
+
"n",
|
| 89 |
+
"ŋ",
|
| 90 |
+
"l",
|
| 91 |
+
"ɾ",
|
| 92 |
+
"r",
|
| 93 |
+
"j",
|
| 94 |
+
"ts",
|
| 95 |
+
"pf",
|
| 96 |
+
"tʃ",
|
| 97 |
+
"dʒ",
|
| 98 |
+
"ə",
|
| 99 |
+
"ɐ",
|
| 100 |
+
"ɜ",
|
| 101 |
+
"ɪ",
|
| 102 |
+
"i",
|
| 103 |
+
"iː",
|
| 104 |
+
"ɛ",
|
| 105 |
+
"ɛː",
|
| 106 |
+
"eː",
|
| 107 |
+
"a",
|
| 108 |
+
"ɑ",
|
| 109 |
+
"ɑː",
|
| 110 |
+
"ɔ",
|
| 111 |
+
"oː",
|
| 112 |
+
"ʊ",
|
| 113 |
+
"uː",
|
| 114 |
+
"y",
|
| 115 |
+
"yː",
|
| 116 |
+
"œ",
|
| 117 |
+
"øː",
|
| 118 |
+
"aɪ",
|
| 119 |
+
"aʊ",
|
| 120 |
+
"ɔø",
|
| 121 |
+
"ʊɐ"
|
| 122 |
+
],
|
| 123 |
+
"vowels": [
|
| 124 |
+
"ə",
|
| 125 |
+
"ɐ",
|
| 126 |
+
"ɜ",
|
| 127 |
+
"ɪ",
|
| 128 |
+
"i",
|
| 129 |
+
"iː",
|
| 130 |
+
"ɛ",
|
| 131 |
+
"ɛː",
|
| 132 |
+
"eː",
|
| 133 |
+
"a",
|
| 134 |
+
"ɑ",
|
| 135 |
+
"ɑː",
|
| 136 |
+
"ɔ",
|
| 137 |
+
"oː",
|
| 138 |
+
"ʊ",
|
| 139 |
+
"uː",
|
| 140 |
+
"y",
|
| 141 |
+
"yː",
|
| 142 |
+
"œ",
|
| 143 |
+
"øː",
|
| 144 |
+
"aɪ",
|
| 145 |
+
"aʊ",
|
| 146 |
+
"ɔø",
|
| 147 |
+
"ʊɐ"
|
| 148 |
+
],
|
| 149 |
+
"punctuation": [
|
| 150 |
+
",",
|
| 151 |
+
".",
|
| 152 |
+
"?",
|
| 153 |
+
"!",
|
| 154 |
+
";",
|
| 155 |
+
":",
|
| 156 |
+
"\"",
|
| 157 |
+
"'",
|
| 158 |
+
"(",
|
| 159 |
+
")",
|
| 160 |
+
"—",
|
| 161 |
+
"…"
|
| 162 |
+
],
|
| 163 |
+
"specials": {
|
| 164 |
+
"pad": "<pad>",
|
| 165 |
+
"bos": "<bos>",
|
| 166 |
+
"eos": "<eos>",
|
| 167 |
+
"sp": "<sp>",
|
| 168 |
+
"unk": "<unk>"
|
| 169 |
+
},
|
| 170 |
+
"fallback": {
|
| 171 |
+
"??": [
|
| 172 |
+
"ʊɐ"
|
| 173 |
+
],
|
| 174 |
+
"ɹ": [
|
| 175 |
+
"ɾ"
|
| 176 |
+
],
|
| 177 |
+
"ʁ": [
|
| 178 |
+
"ɾ"
|
| 179 |
+
],
|
| 180 |
+
"w": [
|
| 181 |
+
"v"
|
| 182 |
+
],
|
| 183 |
+
"ð": [
|
| 184 |
+
"d"
|
| 185 |
+
],
|
| 186 |
+
"θ": [
|
| 187 |
+
"s"
|
| 188 |
+
],
|
| 189 |
+
"ʔ": [],
|
| 190 |
+
"e": [
|
| 191 |
+
"eː"
|
| 192 |
+
],
|
| 193 |
+
"o": [
|
| 194 |
+
"oː"
|
| 195 |
+
],
|
| 196 |
+
"u": [
|
| 197 |
+
"uː"
|
| 198 |
+
],
|
| 199 |
+
"ø": [
|
| 200 |
+
"øː"
|
| 201 |
+
],
|
| 202 |
+
"ɒ": [
|
| 203 |
+
"ɔ"
|
| 204 |
+
],
|
| 205 |
+
"ʌ": [
|
| 206 |
+
"a"
|
| 207 |
+
],
|
| 208 |
+
"æ": [
|
| 209 |
+
"ɛ"
|
| 210 |
+
],
|
| 211 |
+
"ɜː": [
|
| 212 |
+
"øː"
|
| 213 |
+
],
|
| 214 |
+
"ɔː": [
|
| 215 |
+
"oː"
|
| 216 |
+
],
|
| 217 |
+
"ɪː": [
|
| 218 |
+
"iː"
|
| 219 |
+
],
|
| 220 |
+
"aː": [
|
| 221 |
+
"ɑː"
|
| 222 |
+
],
|
| 223 |
+
"eɪ": [
|
| 224 |
+
"eː"
|
| 225 |
+
],
|
| 226 |
+
"ɛɪ": [
|
| 227 |
+
"eː"
|
| 228 |
+
],
|
| 229 |
+
"əʊ": [
|
| 230 |
+
"oː"
|
| 231 |
+
],
|
| 232 |
+
"oʊ": [
|
| 233 |
+
"oː"
|
| 234 |
+
],
|
| 235 |
+
"eə": [
|
| 236 |
+
"ɛː"
|
| 237 |
+
],
|
| 238 |
+
"ɪə": [
|
| 239 |
+
"iː",
|
| 240 |
+
"ɐ"
|
| 241 |
+
],
|
| 242 |
+
"ʊə": [
|
| 243 |
+
"uː",
|
| 244 |
+
"ɐ"
|
| 245 |
+
],
|
| 246 |
+
"aɪə": [
|
| 247 |
+
"aɪ",
|
| 248 |
+
"ɐ"
|
| 249 |
+
],
|
| 250 |
+
"ɔɪ": [
|
| 251 |
+
"ɔø"
|
| 252 |
+
],
|
| 253 |
+
"ɔʏ": [
|
| 254 |
+
"ɔø"
|
| 255 |
+
],
|
| 256 |
+
"əl": [
|
| 257 |
+
"ə",
|
| 258 |
+
"l"
|
| 259 |
+
],
|
| 260 |
+
"l̩": [
|
| 261 |
+
"ə",
|
| 262 |
+
"l"
|
| 263 |
+
],
|
| 264 |
+
"n̩": [
|
| 265 |
+
"ə",
|
| 266 |
+
"n"
|
| 267 |
+
],
|
| 268 |
+
"m̩": [
|
| 269 |
+
"ə",
|
| 270 |
+
"m"
|
| 271 |
+
],
|
| 272 |
+
"ɑ̃": [
|
| 273 |
+
"ɑ",
|
| 274 |
+
"ŋ"
|
| 275 |
+
],
|
| 276 |
+
"ɔ̃": [
|
| 277 |
+
"ɔ",
|
| 278 |
+
"ŋ"
|
| 279 |
+
],
|
| 280 |
+
"ɛ̃": [
|
| 281 |
+
"ɛ",
|
| 282 |
+
"ŋ"
|
| 283 |
+
],
|
| 284 |
+
"œ̃": [
|
| 285 |
+
"œ",
|
| 286 |
+
"ŋ"
|
| 287 |
+
],
|
| 288 |
+
"ʏ": [
|
| 289 |
+
"y"
|
| 290 |
+
],
|
| 291 |
+
"ɚ": [
|
| 292 |
+
"ɐ"
|
| 293 |
+
],
|
| 294 |
+
"ɲ": [
|
| 295 |
+
"n",
|
| 296 |
+
"j"
|
| 297 |
+
],
|
| 298 |
+
"ɬ": [
|
| 299 |
+
"l"
|
| 300 |
+
],
|
| 301 |
+
"ɫ": [
|
| 302 |
+
"l"
|
| 303 |
+
],
|
| 304 |
+
"dz": [
|
| 305 |
+
"d",
|
| 306 |
+
"z"
|
| 307 |
+
],
|
| 308 |
+
"β": [
|
| 309 |
+
"v"
|
| 310 |
+
],
|
| 311 |
+
"ɣ": [
|
| 312 |
+
"ɡ"
|
| 313 |
+
],
|
| 314 |
+
"ʎ": [
|
| 315 |
+
"l",
|
| 316 |
+
"j"
|
| 317 |
+
]
|
| 318 |
+
},
|
| 319 |
+
"chunk_abbreviations": [
|
| 320 |
+
"a",
|
| 321 |
+
"b",
|
| 322 |
+
"bzw",
|
| 323 |
+
"ca",
|
| 324 |
+
"d",
|
| 325 |
+
"dr",
|
| 326 |
+
"evtl",
|
| 327 |
+
"fr",
|
| 328 |
+
"ggf",
|
| 329 |
+
"h",
|
| 330 |
+
"hr",
|
| 331 |
+
"inkl",
|
| 332 |
+
"nr",
|
| 333 |
+
"o",
|
| 334 |
+
"prof",
|
| 335 |
+
"s",
|
| 336 |
+
"st",
|
| 337 |
+
"str",
|
| 338 |
+
"u",
|
| 339 |
+
"usw",
|
| 340 |
+
"vgl",
|
| 341 |
+
"z"
|
| 342 |
+
],
|
| 343 |
+
"months": [
|
| 344 |
+
"Januar",
|
| 345 |
+
"Februar",
|
| 346 |
+
"März",
|
| 347 |
+
"April",
|
| 348 |
+
"Mai",
|
| 349 |
+
"Juni",
|
| 350 |
+
"Juli",
|
| 351 |
+
"August",
|
| 352 |
+
"September",
|
| 353 |
+
"Oktober",
|
| 354 |
+
"November",
|
| 355 |
+
"Dezember"
|
| 356 |
+
],
|
| 357 |
+
"abbreviations": [
|
| 358 |
+
[
|
| 359 |
+
"z.B.",
|
| 360 |
+
"zum Beispiel"
|
| 361 |
+
],
|
| 362 |
+
[
|
| 363 |
+
"z. B.",
|
| 364 |
+
"zum Beispiel"
|
| 365 |
+
],
|
| 366 |
+
[
|
| 367 |
+
"d.h.",
|
| 368 |
+
"das heißt"
|
| 369 |
+
],
|
| 370 |
+
[
|
| 371 |
+
"d. h.",
|
| 372 |
+
"das heißt"
|
| 373 |
+
],
|
| 374 |
+
[
|
| 375 |
+
"u.a.",
|
| 376 |
+
"unter anderem"
|
| 377 |
+
],
|
| 378 |
+
[
|
| 379 |
+
"usw.",
|
| 380 |
+
"und so weiter"
|
| 381 |
+
],
|
| 382 |
+
[
|
| 383 |
+
"bzw.",
|
| 384 |
+
"beziehungsweise"
|
| 385 |
+
],
|
| 386 |
+
[
|
| 387 |
+
"ca.",
|
| 388 |
+
"circa"
|
| 389 |
+
],
|
| 390 |
+
[
|
| 391 |
+
"vgl.",
|
| 392 |
+
"vergleiche"
|
| 393 |
+
],
|
| 394 |
+
[
|
| 395 |
+
"evtl.",
|
| 396 |
+
"eventuell"
|
| 397 |
+
],
|
| 398 |
+
[
|
| 399 |
+
"ggf.",
|
| 400 |
+
"gegebenenfalls"
|
| 401 |
+
],
|
| 402 |
+
[
|
| 403 |
+
"inkl.",
|
| 404 |
+
"inklusive"
|
| 405 |
+
],
|
| 406 |
+
[
|
| 407 |
+
"Nr.",
|
| 408 |
+
"Nummer"
|
| 409 |
+
],
|
| 410 |
+
[
|
| 411 |
+
"Dr.",
|
| 412 |
+
"Doktor"
|
| 413 |
+
],
|
| 414 |
+
[
|
| 415 |
+
"Prof.",
|
| 416 |
+
"Professor"
|
| 417 |
+
],
|
| 418 |
+
[
|
| 419 |
+
"Str.",
|
| 420 |
+
"Straße"
|
| 421 |
+
],
|
| 422 |
+
[
|
| 423 |
+
"Hr.",
|
| 424 |
+
"Herr"
|
| 425 |
+
],
|
| 426 |
+
[
|
| 427 |
+
"Fr.",
|
| 428 |
+
"Frau"
|
| 429 |
+
],
|
| 430 |
+
[
|
| 431 |
+
"St.",
|
| 432 |
+
"Sankt"
|
| 433 |
+
],
|
| 434 |
+
[
|
| 435 |
+
"etc.",
|
| 436 |
+
"et cetera"
|
| 437 |
+
],
|
| 438 |
+
[
|
| 439 |
+
"Mio.",
|
| 440 |
+
"Millionen"
|
| 441 |
+
],
|
| 442 |
+
[
|
| 443 |
+
"Mrd.",
|
| 444 |
+
"Milliarden"
|
| 445 |
+
],
|
| 446 |
+
[
|
| 447 |
+
"km/h",
|
| 448 |
+
"Kilometer pro Stunde"
|
| 449 |
+
],
|
| 450 |
+
[
|
| 451 |
+
"€",
|
| 452 |
+
" Euro"
|
| 453 |
+
],
|
| 454 |
+
[
|
| 455 |
+
"%",
|
| 456 |
+
" Prozent"
|
| 457 |
+
]
|
| 458 |
+
]
|
| 459 |
+
}
|
web/index.html
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="de">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>apptor-tiny-tts</title>
|
| 7 |
+
<meta name="description" content="Eine kleine deutsche Stimme, die auch (etwas) österreichisch kann. Läuft komplett im Browser, Apache 2.0.">
|
| 8 |
+
<meta property="og:title" content="apptor-tiny-tts: vom Fischbrötchen zum Schnitzel">
|
| 9 |
+
<meta property="og:description" content="Kleine deutsche Stimme mit Akzent-Regler, hochdeutsch oder österreichisch. Läuft komplett im Browser, Apache 2.0.">
|
| 10 |
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%23c8102e'/%3E%3Crect y='11' width='32' height='10' fill='%23fff'/%3E%3C/svg%3E">
|
| 11 |
+
<style>
|
| 12 |
+
:root {
|
| 13 |
+
--ink: #1d232b; --muted: #5b6672; --card: #ffffffee; --line: #d9dee4; --accent: #c8102e; --accent-ink: #fff;
|
| 14 |
+
--bg-a: #2f7aa0; --bg-b: #d8eef6; --shadow: 0 10px 30px #0002; --track: #e7ebef;
|
| 15 |
+
font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
|
| 16 |
+
}
|
| 17 |
+
@media (prefers-color-scheme: dark) {
|
| 18 |
+
:root { --ink: #eef2f5; --muted: #a6b1bc; --card: #1b2229ee; --line: #34404b; --shadow: 0 10px 30px #0006; --track: #2b343d; }
|
| 19 |
+
}
|
| 20 |
+
* { box-sizing: border-box; }
|
| 21 |
+
html, body { margin: 0; }
|
| 22 |
+
body {
|
| 23 |
+
min-height: 100vh; color: var(--ink);
|
| 24 |
+
background: linear-gradient(160deg, var(--bg-a), var(--bg-b)); background-attachment: fixed;
|
| 25 |
+
transition: background 0.6s;
|
| 26 |
+
}
|
| 27 |
+
main { max-width: 760px; margin: 0 auto; padding: 28px 16px 40px; }
|
| 28 |
+
header { text-align: center; color: #fff; text-shadow: 0 2px 8px #0004; }
|
| 29 |
+
header h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); margin: 0; letter-spacing: -0.02em; transition: transform 0.25s; }
|
| 30 |
+
header p { margin: 6px 0 0; font-size: 1.05rem; opacity: 0.95; }
|
| 31 |
+
.ver { display: inline-block; margin-top: 10px; padding: 3px 12px; border-radius: 999px; background: #fff3; border: 1px solid #fff8;
|
| 32 |
+
font-size: 0.8rem; font-weight: 600; text-shadow: none; }
|
| 33 |
+
.card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; margin-top: 18px; backdrop-filter: blur(6px); }
|
| 34 |
+
.food { position: relative; height: 190px; display: flex; align-items: center; justify-content: center; }
|
| 35 |
+
.food svg { position: absolute; width: min(260px, 70vw); height: 180px; transition: opacity 0.35s, transform 0.35s; }
|
| 36 |
+
.dish { text-align: center; font-weight: 600; margin: 2px 0 10px; min-height: 1.4em; }
|
| 37 |
+
.slider-wrap { padding: 4px 4px 0; }
|
| 38 |
+
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
|
| 39 |
+
.stops { position: relative; height: 1.9em; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
|
| 40 |
+
.stops button { position: absolute; top: 0; white-space: nowrap; }
|
| 41 |
+
.stops button { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 4px 2px; }
|
| 42 |
+
.stops button:hover { color: var(--ink); text-decoration: underline; }
|
| 43 |
+
.value { text-align: center; color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
|
| 44 |
+
textarea { width: 100%; min-height: 200px; resize: vertical; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
|
| 45 |
+
font: inherit; font-size: 1.05rem; background: transparent; color: var(--ink); }
|
| 46 |
+
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
|
| 47 |
+
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
|
| 48 |
+
.seg button { border: 0; background: transparent; color: var(--ink); padding: 9px 16px; font: inherit; cursor: pointer; }
|
| 49 |
+
.seg button[aria-pressed=true] { background: var(--ink); color: var(--card); }
|
| 50 |
+
.speak { margin-left: auto; border: 0; border-radius: 999px; padding: 11px 26px; font: inherit; font-weight: 700; font-size: 1.05rem;
|
| 51 |
+
background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 0 4px 14px #c8102e55; }
|
| 52 |
+
.speak:disabled { opacity: 0.5; cursor: wait; box-shadow: none; }
|
| 53 |
+
.examples { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
|
| 54 |
+
.examples button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 12px;
|
| 55 |
+
font: inherit; font-size: 0.85rem; cursor: pointer; }
|
| 56 |
+
.examples button:hover { color: var(--ink); border-color: var(--ink); }
|
| 57 |
+
.source { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
|
| 58 |
+
.status { font-size: 0.88rem; color: var(--muted); margin-top: 12px; min-height: 1.2em; }
|
| 59 |
+
.bar { height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; margin-top: 6px; }
|
| 60 |
+
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
|
| 61 |
+
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 0.9rem; color: var(--muted); }
|
| 62 |
+
.info { font-size: 0.92rem; line-height: 1.55; color: var(--muted); }
|
| 63 |
+
.info h2 { color: var(--ink); font-size: 1.05rem; margin: 0 0 6px; }
|
| 64 |
+
.info p + h2 { margin-top: 16px; }
|
| 65 |
+
.info p { margin: 0 0 10px; }
|
| 66 |
+
.info a { color: var(--accent); }
|
| 67 |
+
.use { margin: 0 0 12px; padding-left: 18px; }
|
| 68 |
+
.use li { margin-bottom: 8px; }
|
| 69 |
+
.use b { color: var(--ink); }
|
| 70 |
+
.links { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
|
| 71 |
+
.btn { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; text-decoration: none;
|
| 72 |
+
font-weight: 600; color: var(--ink) !important; }
|
| 73 |
+
.btn:hover { border-color: var(--ink); }
|
| 74 |
+
.small { font-size: 0.82rem; }
|
| 75 |
+
footer { text-align: center; color: #1d232bcc; font-size: 0.9rem; margin-top: 22px; }
|
| 76 |
+
footer a { color: #1d232b; font-weight: 600; }
|
| 77 |
+
.wobble { animation: wob 0.5s; }
|
| 78 |
+
@keyframes wob { 30% { transform: rotate(-3deg) scale(1.04); } 60% { transform: rotate(2deg); } }
|
| 79 |
+
@media (max-width: 520px) { .speak { margin-left: 0; width: 100%; } }
|
| 80 |
+
</style>
|
| 81 |
+
</head>
|
| 82 |
+
<body>
|
| 83 |
+
<main>
|
| 84 |
+
<header>
|
| 85 |
+
<h1 id="greet">Servus!</h1>
|
| 86 |
+
<p>Eine kleine deutsche Stimme, die auch (etwas) österreichisch kann. Direkt in deinem Browser.</p>
|
| 87 |
+
<span class="ver">Version 0.1 · frühe Vorschau</span>
|
| 88 |
+
</header>
|
| 89 |
+
|
| 90 |
+
<section class="card" aria-label="Akzent">
|
| 91 |
+
<div class="food" id="food" aria-hidden="true">
|
| 92 |
+
<!-- Fischbrötchen -->
|
| 93 |
+
<svg viewBox="0 0 260 180" data-i="0">
|
| 94 |
+
<ellipse cx="130" cy="150" rx="110" ry="14" fill="#0002"/>
|
| 95 |
+
<path d="M30 112 Q130 150 230 112 L224 128 Q130 168 36 128Z" fill="#d79a4a"/>
|
| 96 |
+
<path d="M44 98 Q70 84 100 92 Q130 80 160 92 Q190 82 216 98 L214 110 Q130 124 46 110Z" fill="#7dbb4a"/>
|
| 97 |
+
<path d="M8 96 Q40 70 120 78 Q200 72 236 92 L252 78 L248 104 L252 126 L234 108 Q190 118 120 112 Q40 116 8 96Z" fill="#c9cfd6"/>
|
| 98 |
+
<path d="M30 92 Q120 84 230 96" stroke="#8d97a3" stroke-width="3" fill="none"/>
|
| 99 |
+
<circle cx="32" cy="92" r="4" fill="#24303a"/>
|
| 100 |
+
<circle cx="96" cy="104" r="9" fill="none" stroke="#b07ac0" stroke-width="4"/>
|
| 101 |
+
<circle cx="160" cy="104" r="9" fill="none" stroke="#b07ac0" stroke-width="4"/>
|
| 102 |
+
<path d="M34 92 Q130 30 226 92 Q130 70 34 92Z" fill="#e2ad5f"/>
|
| 103 |
+
<path d="M70 66 l6 -4 M110 52 l6 -3 M150 54 l6 3 M188 66 l6 4" stroke="#fff8" stroke-width="3" stroke-linecap="round"/>
|
| 104 |
+
</svg>
|
| 105 |
+
<!-- Wiener Schnitzel -->
|
| 106 |
+
<svg viewBox="0 0 260 180" data-i="1">
|
| 107 |
+
<ellipse cx="130" cy="98" rx="122" ry="72" fill="#f5f2ec" stroke="#d8d2c6" stroke-width="3"/>
|
| 108 |
+
<path d="M34 98 Q30 52 92 46 Q130 30 178 48 Q232 56 226 102 Q232 146 170 150 Q130 164 86 150 Q28 146 34 98Z" fill="#d9952f"/>
|
| 109 |
+
<path d="M50 96 Q48 62 96 58 Q130 46 172 60 Q214 66 210 100 Q214 134 166 138 Q130 150 92 138 Q50 134 50 96Z" fill="#e8ad46"/>
|
| 110 |
+
<g fill="#b97821"><circle cx="80" cy="80" r="3"/><circle cx="120" cy="66" r="3"/><circle cx="160" cy="84" r="3"/><circle cx="104" cy="112" r="3"/><circle cx="150" cy="120" r="3"/><circle cx="186" cy="104" r="3"/><circle cx="70" cy="118" r="3"/></g>
|
| 111 |
+
<path d="M168 40 a26 26 0 0 1 44 22 Z" fill="#f4e04d" stroke="#d9c22c" stroke-width="3"/>
|
| 112 |
+
<path d="M172 44 L200 58 M186 38 L198 58" stroke="#fff7" stroke-width="2"/>
|
| 113 |
+
<path d="M46 52 q10 -14 22 -4 q8 -12 18 0" stroke="#3f8f3a" stroke-width="5" fill="none" stroke-linecap="round"/>
|
| 114 |
+
</svg>
|
| 115 |
+
</div>
|
| 116 |
+
<p class="dish" id="dish">Wiener Schnitzel</p>
|
| 117 |
+
<div class="slider-wrap">
|
| 118 |
+
<label for="accent" class="value" style="display:block">Akzentstärke: <b id="accent-val">1,0</b></label>
|
| 119 |
+
<input id="accent" type="range" min="0" max="1.6" step="0.05" value="1" aria-describedby="dish">
|
| 120 |
+
<div class="stops">
|
| 121 |
+
<button data-v="0" style="left:0">Hochdeutsch</button><button data-v="1.6" style="right:0">Österreichisch</button>
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
</section>
|
| 125 |
+
|
| 126 |
+
<section class="card" aria-label="Sprechen">
|
| 127 |
+
<label for="text" class="value" style="display:block;text-align:left;margin:0 0 6px">Was soll ich sagen?</label>
|
| 128 |
+
<textarea id="text" rows="8">Da streiten sich die Leut herum
|
| 129 |
+
oft um den Wert des Glücks,
|
| 130 |
+
der eine heißt den andern dumm,
|
| 131 |
+
am End weiß keiner nix.
|
| 132 |
+
Da ist der allerärmste Mann
|
| 133 |
+
dem andern viel zu reich,
|
| 134 |
+
das Schicksal setzt den Hobel an
|
| 135 |
+
und hobelt alles gleich.</textarea>
|
| 136 |
+
<div class="source">Ferdinand Raimund, „Hobellied“ (1834). Oder schreib einfach etwas Eigenes.</div>
|
| 137 |
+
<div class="row">
|
| 138 |
+
<div class="seg" role="group" aria-label="Stimme">
|
| 139 |
+
<button data-voice="M2" aria-pressed="true">Mann</button><button data-voice="F2" aria-pressed="false">Frau</button>
|
| 140 |
+
</div>
|
| 141 |
+
<label class="check"><input type="checkbox" id="vocos" checked disabled> Klangfilter</label>
|
| 142 |
+
<button class="speak" id="speak" disabled>Lade …</button>
|
| 143 |
+
</div>
|
| 144 |
+
<div class="status" id="status">Lade die Modelle (einmalig, danach im Browser gespeichert) …</div>
|
| 145 |
+
<div class="bar"><i id="bar"></i></div>
|
| 146 |
+
</section>
|
| 147 |
+
|
| 148 |
+
<section class="card info">
|
| 149 |
+
<h2>Warum österreichisch?</h2>
|
| 150 |
+
<p>Sprachausgaben klingen fast immer bundesdeutsch. apptor-tiny-tts soll eine Alternative sein, und zwar dort, wo große
|
| 151 |
+
Modelle keinen Platz haben: im Browser, am Handy, in kleinen Apps. Der Akzent ist noch dezent und sitzt nicht in jedem
|
| 152 |
+
Wort: besser als nichts, aber noch nicht ganz österreichisch. Das hier ist Version 0.1, trainiert auf einer einzigen Grafikkarte mit freien Aufnahmen von Freiwilligen
|
| 153 |
+
aus <a href="https://commonvoice.mozilla.org/de" rel="noopener">Mozilla Common Voice</a>. Die beiden Stimmen sind
|
| 154 |
+
synthetisch; das Modell hat den Tonfall gelernt, nicht die Stimmen der Sprecherinnen und Sprecher.</p>
|
| 155 |
+
<p>Was hier passiert: Beim ersten Besuch lädt dein Browser einmalig rund 50 MB (Aussprache, Stimme, Klangfilter) und
|
| 156 |
+
rechnet danach alles selbst. Dein Text verlässt das Gerät nicht.</p>
|
| 157 |
+
</section>
|
| 158 |
+
|
| 159 |
+
<section class="card info">
|
| 160 |
+
<h2>Selbst verwenden</h2>
|
| 161 |
+
<ul class="use">
|
| 162 |
+
<li><b>Im Web.</b> Diese Seite ist das ganze Paket: ein paar Dateien, kein Build, keine Abhängigkeiten. Den Ordner von
|
| 163 |
+
Hugging Face auf den eigenen Webserver legen, und die Stimme läuft auch dort.</li>
|
| 164 |
+
<li><b>In Python.</b> Dieselben Modelle als ONNX, dazu ein kleines Skript. Es braucht nur onnxruntime, kein eSpeak, keine GPU.</li>
|
| 165 |
+
<li><b>Als ganzer Sprachassistent.</b> <a href="https://github.com/ViktorsGitUser/flash-voice" rel="noopener">flash-voice</a>
|
| 166 |
+
auf GitHub verbindet Hören, Entscheiden und Sprechen; apptor-tiny-tts ist dort die deutsche Stimme.</li>
|
| 167 |
+
</ul>
|
| 168 |
+
<div class="links">
|
| 169 |
+
<a class="btn" href="https://huggingface.co/apptor/apptor-tiny-tts-at" rel="noopener">Hugging Face</a>
|
| 170 |
+
<a class="btn" href="https://github.com/ViktorsGitUser/flash-voice" rel="noopener">GitHub</a>
|
| 171 |
+
</div>
|
| 172 |
+
<p class="small">Apache 2.0. Gebaut auf <a href="https://github.com/n4ze3m/tiny-voca" rel="noopener">tiny-voca</a> von Nazeem,
|
| 173 |
+
Klangfilter <a href="https://github.com/gemelo-ai/vocos" rel="noopener">Vocos</a> (MIT), Laufzeit
|
| 174 |
+
<a href="https://onnxruntime.ai" rel="noopener">ONNX Runtime Web</a> (MIT).</p>
|
| 175 |
+
</section>
|
| 176 |
+
<footer>
|
| 177 |
+
<a href="https://apptor.at" rel="noopener">apptor.at</a> ·
|
| 178 |
+
Feedback gern auf <a href="https://x.com/apptor_at" rel="noopener">X @apptor_at</a>
|
| 179 |
+
</footer>
|
| 180 |
+
</main>
|
| 181 |
+
|
| 182 |
+
<script type="module">
|
| 183 |
+
import * as ort from "./ort/ort.wasm.min.mjs";
|
| 184 |
+
import {G2P, makeFrontEnd, Voice} from "./apptor-tts.js?v=4";
|
| 185 |
+
|
| 186 |
+
ort.env.wasm.wasmPaths = new URL("./ort/", location.href).href;
|
| 187 |
+
ort.env.wasm.numThreads = self.crossOriginIsolated ? Math.min(4, navigator.hardwareConcurrency || 2) : 1;
|
| 188 |
+
ort.env.wasm.proxy = true; // run the models in a Web Worker, so the page stays responsive while it computes
|
| 189 |
+
|
| 190 |
+
const $ = id => document.getElementById(id);
|
| 191 |
+
const STOPS = [
|
| 192 |
+
{v: 0, hi: "Moin!", dish: "Fischbrötchen", bg: ["#2f7aa0", "#d8eef6"]},
|
| 193 |
+
{v: 1.0, hi: "Servus!", dish: "Wiener Schnitzel", bg: ["#c8102e", "#f6e9ea"]},
|
| 194 |
+
];
|
| 195 |
+
const svgs = [...document.querySelectorAll("#food svg")];
|
| 196 |
+
let voiceName = "M2", voice = null, playing = null, ctx = null, spoken = false;
|
| 197 |
+
|
| 198 |
+
function mix(a, b, t) {
|
| 199 |
+
const p = h => [1, 3, 5].map(i => parseInt(h.slice(i, i + 2), 16));
|
| 200 |
+
const x = p(a), y = p(b);
|
| 201 |
+
return "#" + x.map((v, i) => Math.round(v + (y[i] - v) * t).toString(16).padStart(2, "0")).join("");
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
function showAccent(v) {
|
| 205 |
+
$("accent-val").textContent = v.toFixed(2).replace(/0$/, "").replace(".", ",");
|
| 206 |
+
let i = 0;
|
| 207 |
+
while (i < STOPS.length - 2 && v > STOPS[i + 1].v) i++;
|
| 208 |
+
const a = STOPS[i], b = STOPS[i + 1], t = Math.max(0, Math.min(1, (v - a.v) / (b.v - a.v)));
|
| 209 |
+
svgs.forEach((s, k) => {
|
| 210 |
+
const o = k === i ? 1 - t : k === i + 1 ? t : 0;
|
| 211 |
+
s.style.opacity = o; s.style.transform = `scale(${0.8 + 0.2 * o}) rotate(${(1 - o) * (k > i ? 8 : -8)}deg)`;
|
| 212 |
+
});
|
| 213 |
+
const near = t < 0.5 ? a : b;
|
| 214 |
+
if ($("greet").textContent !== near.hi) { $("greet").textContent = near.hi; $("greet").classList.remove("wobble"); void $("greet").offsetWidth; $("greet").classList.add("wobble"); }
|
| 215 |
+
$("dish").textContent = near.dish;
|
| 216 |
+
document.body.style.setProperty("--bg-a", mix(a.bg[0], b.bg[0], t));
|
| 217 |
+
document.body.style.setProperty("--bg-b", mix(a.bg[1], b.bg[1], t));
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
$("accent").addEventListener("input", e => showAccent(Number(e.target.value)));
|
| 221 |
+
$("accent").addEventListener("change", () => { if (spoken) speak(); });
|
| 222 |
+
document.querySelectorAll(".stops button").forEach(b => b.addEventListener("click", () => {
|
| 223 |
+
$("accent").value = b.dataset.v; showAccent(Number(b.dataset.v)); if (spoken) speak();
|
| 224 |
+
}));
|
| 225 |
+
document.querySelectorAll(".seg button").forEach(b => b.addEventListener("click", () => {
|
| 226 |
+
voiceName = b.dataset.voice;
|
| 227 |
+
document.querySelectorAll(".seg button").forEach(x => x.setAttribute("aria-pressed", String(x === b)));
|
| 228 |
+
if (spoken) speak();
|
| 229 |
+
}));
|
| 230 |
+
showAccent(1.0);
|
| 231 |
+
|
| 232 |
+
// ---- loading with progress, kept in the Cache Storage for the next visit
|
| 233 |
+
const CACHE = "apptor-tiny-tts-v1";
|
| 234 |
+
async function fetchBytes(url, onProgress) {
|
| 235 |
+
let cache = null;
|
| 236 |
+
try { cache = await caches.open(CACHE); const hit = await cache.match(url); if (hit) { const b = await hit.arrayBuffer(); onProgress(b.byteLength, b.byteLength); return new Uint8Array(b); } } catch {}
|
| 237 |
+
const r = await fetch(url);
|
| 238 |
+
if (!r.ok) throw new Error(`${url}: ${r.status}`);
|
| 239 |
+
const total = Number(r.headers.get("content-length")) || 0, reader = r.body.getReader(), parts = [];
|
| 240 |
+
let got = 0;
|
| 241 |
+
for (;;) { const {done, value} = await reader.read(); if (done) break; parts.push(value); got += value.length; onProgress(got, total); }
|
| 242 |
+
const out = new Uint8Array(got); let o = 0; for (const p of parts) { out.set(p, o); o += p.length; }
|
| 243 |
+
try { await cache?.put(url, new Response(out.slice(), {headers: {"content-type": "application/octet-stream"}})); } catch {}
|
| 244 |
+
return out;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
const SIZES = {"models/apptor-g2p-de.onnx": 12.4, "models/apptor-tiny-tts-at.onnx": 21.4, "models/apptor-vocos-de.int8.onnx": 16.7};
|
| 248 |
+
const done = {};
|
| 249 |
+
function progress(url, got, total) {
|
| 250 |
+
done[url] = got / 1e6;
|
| 251 |
+
const all = Object.values(SIZES).reduce((a, b) => a + b, 0), have = Object.values(done).reduce((a, b) => a + b, 0);
|
| 252 |
+
$("bar").style.width = `${Math.min(100, 100 * have / all)}%`;
|
| 253 |
+
$("status").textContent = `Lade die Modelle: ${have.toFixed(0)} von ${all.toFixed(0)} MB (einmalig, danach im Browser gespeichert)`;
|
| 254 |
+
}
|
| 255 |
+
const json = async u => (await fetch(u)).json();
|
| 256 |
+
const opts = {executionProviders: ["wasm"], graphOptimizationLevel: "all"};
|
| 257 |
+
|
| 258 |
+
async function load() {
|
| 259 |
+
const [F, exceptions, austrian, g2pMeta, ttsMeta] = await Promise.all(["frontend-de.json", "exceptions-de.json", "austrian-de.json", "models/apptor-g2p-de.json", "models/apptor-tiny-tts-at.json"].map(json));
|
| 260 |
+
const [g2pBytes, ttsBytes] = await Promise.all(["models/apptor-g2p-de.onnx", "models/apptor-tiny-tts-at.onnx"].map(u => fetchBytes(u, (g, t) => progress(u, g, t))));
|
| 261 |
+
const g2p = new G2P(ort, await ort.InferenceSession.create(g2pBytes, opts), g2pMeta, exceptions, austrian);
|
| 262 |
+
voice = new Voice(ort, await ort.InferenceSession.create(ttsBytes, opts), ttsMeta, makeFrontEnd(F, g2p));
|
| 263 |
+
$("speak").disabled = false; $("speak").textContent = "Sprechen";
|
| 264 |
+
$("status").textContent = "Bereit. Der Klangfilter lädt noch im Hintergrund.";
|
| 265 |
+
const u = "models/apptor-vocos-de.int8.onnx";
|
| 266 |
+
const vb = await fetchBytes(u, (g, t) => progress(u, g, t));
|
| 267 |
+
voice.setVocos(await ort.InferenceSession.create(vb, opts));
|
| 268 |
+
$("vocos").disabled = false;
|
| 269 |
+
$("status").textContent = "Bereit. Alles ist geladen und bleibt im Browser gespeichert.";
|
| 270 |
+
}
|
| 271 |
+
load().catch(e => { $("status").textContent = "Das Laden hat nicht geklappt: " + e.message; console.error(e); });
|
| 272 |
+
|
| 273 |
+
let busy = false, again = false, sources = [];
|
| 274 |
+
function stopAudio() { for (const x of sources) { try { x.stop(); } catch {} } sources = []; }
|
| 275 |
+
async function speak() {
|
| 276 |
+
if (!voice) return;
|
| 277 |
+
if (busy) { again = true; return; } // the running job stops after its current sentence, then this starts
|
| 278 |
+
busy = true; spoken = true;
|
| 279 |
+
$("speak").disabled = true; $("speak").textContent = "Rechne …";
|
| 280 |
+
const keep = voice.vocos;
|
| 281 |
+
try {
|
| 282 |
+
ctx ??= new (window.AudioContext || window.webkitAudioContext)();
|
| 283 |
+
await ctx.resume();
|
| 284 |
+
stopAudio();
|
| 285 |
+
if (!$("vocos").checked) voice.vocos = null;
|
| 286 |
+
const sr = voice.meta.sample_rate, t = performance.now();
|
| 287 |
+
let at = 0, first = 0;
|
| 288 |
+
const audio = await voice.speak($("text").value, {voice: voiceName, accent: Number($("accent").value), cancelled: () => again,
|
| 289 |
+
onChunk: (a, i) => { // play each sentence as soon as it is ready
|
| 290 |
+
const buf = ctx.createBuffer(1, a.length, sr);
|
| 291 |
+
buf.copyToChannel(a, 0);
|
| 292 |
+
const src = ctx.createBufferSource(); src.buffer = buf; src.connect(ctx.destination);
|
| 293 |
+
if (i === 0) { first = performance.now() - t; at = ctx.currentTime + 0.05; } else at += 0.12;
|
| 294 |
+
at = Math.max(at, ctx.currentTime + 0.02);
|
| 295 |
+
src.start(at); at += buf.duration; sources.push(src);
|
| 296 |
+
}});
|
| 297 |
+
if (again) return;
|
| 298 |
+
if (!audio.length) throw new Error("kein Text zum Sprechen");
|
| 299 |
+
const ms = performance.now() - t;
|
| 300 |
+
$("status").textContent = `${(audio.length / sr).toFixed(1)} s Sprache, auf deinem Gerät gerechnet: erster Satz nach ${(first / 1000).toFixed(2)} s, alles nach ${(ms / 1000).toFixed(2)} s.`;
|
| 301 |
+
} catch (e) {
|
| 302 |
+
$("status").textContent = "Fehler: " + e.message; console.error(e);
|
| 303 |
+
} finally {
|
| 304 |
+
voice.vocos = keep;
|
| 305 |
+
busy = false; $("speak").disabled = false; $("speak").textContent = "Sprechen";
|
| 306 |
+
if (again) { again = false; speak(); }
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
$("speak").addEventListener("click", speak);
|
| 310 |
+
</script>
|
| 311 |
+
</body>
|
| 312 |
+
</html>
|
web/models/apptor-g2p-de.json
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"chars": [
|
| 3 |
+
"<pad>",
|
| 4 |
+
"<unk>",
|
| 5 |
+
"'",
|
| 6 |
+
"-",
|
| 7 |
+
".",
|
| 8 |
+
"A",
|
| 9 |
+
"B",
|
| 10 |
+
"C",
|
| 11 |
+
"D",
|
| 12 |
+
"E",
|
| 13 |
+
"F",
|
| 14 |
+
"G",
|
| 15 |
+
"H",
|
| 16 |
+
"I",
|
| 17 |
+
"J",
|
| 18 |
+
"K",
|
| 19 |
+
"L",
|
| 20 |
+
"M",
|
| 21 |
+
"N",
|
| 22 |
+
"O",
|
| 23 |
+
"P",
|
| 24 |
+
"Q",
|
| 25 |
+
"R",
|
| 26 |
+
"S",
|
| 27 |
+
"T",
|
| 28 |
+
"U",
|
| 29 |
+
"V",
|
| 30 |
+
"W",
|
| 31 |
+
"X",
|
| 32 |
+
"Y",
|
| 33 |
+
"Z",
|
| 34 |
+
"a",
|
| 35 |
+
"b",
|
| 36 |
+
"c",
|
| 37 |
+
"d",
|
| 38 |
+
"e",
|
| 39 |
+
"f",
|
| 40 |
+
"g",
|
| 41 |
+
"h",
|
| 42 |
+
"i",
|
| 43 |
+
"j",
|
| 44 |
+
"k",
|
| 45 |
+
"l",
|
| 46 |
+
"m",
|
| 47 |
+
"n",
|
| 48 |
+
"o",
|
| 49 |
+
"p",
|
| 50 |
+
"q",
|
| 51 |
+
"r",
|
| 52 |
+
"s",
|
| 53 |
+
"t",
|
| 54 |
+
"u",
|
| 55 |
+
"v",
|
| 56 |
+
"w",
|
| 57 |
+
"x",
|
| 58 |
+
"y",
|
| 59 |
+
"z",
|
| 60 |
+
"¡",
|
| 61 |
+
"",
|
| 62 |
+
"®",
|
| 63 |
+
"Á",
|
| 64 |
+
"Ä",
|
| 65 |
+
"Æ",
|
| 66 |
+
"Ç",
|
| 67 |
+
"É",
|
| 68 |
+
"Í",
|
| 69 |
+
"Î",
|
| 70 |
+
"Ó",
|
| 71 |
+
"Ö",
|
| 72 |
+
"Ú",
|
| 73 |
+
"Ü",
|
| 74 |
+
"Þ",
|
| 75 |
+
"ß",
|
| 76 |
+
"à",
|
| 77 |
+
"á",
|
| 78 |
+
"â",
|
| 79 |
+
"ã",
|
| 80 |
+
"ä",
|
| 81 |
+
"å",
|
| 82 |
+
"æ",
|
| 83 |
+
"è",
|
| 84 |
+
"é",
|
| 85 |
+
"ê",
|
| 86 |
+
"ë",
|
| 87 |
+
"í",
|
| 88 |
+
"î",
|
| 89 |
+
"ï",
|
| 90 |
+
"ð",
|
| 91 |
+
"ñ",
|
| 92 |
+
"ò",
|
| 93 |
+
"ó",
|
| 94 |
+
"ô",
|
| 95 |
+
"õ",
|
| 96 |
+
"ö",
|
| 97 |
+
"ø",
|
| 98 |
+
"ú",
|
| 99 |
+
"ü",
|
| 100 |
+
"ý",
|
| 101 |
+
"ā",
|
| 102 |
+
"ă",
|
| 103 |
+
"ą",
|
| 104 |
+
"ć",
|
| 105 |
+
"Č",
|
| 106 |
+
"č",
|
| 107 |
+
"Đ",
|
| 108 |
+
"đ",
|
| 109 |
+
"ė",
|
| 110 |
+
"ę",
|
| 111 |
+
"ě",
|
| 112 |
+
"ğ",
|
| 113 |
+
"ġ",
|
| 114 |
+
"ī",
|
| 115 |
+
"İ",
|
| 116 |
+
"ı",
|
| 117 |
+
"Ł",
|
| 118 |
+
"ł",
|
| 119 |
+
"ń",
|
| 120 |
+
"ň",
|
| 121 |
+
"Ō",
|
| 122 |
+
"ō",
|
| 123 |
+
"ő",
|
| 124 |
+
"Œ",
|
| 125 |
+
"œ",
|
| 126 |
+
"Ř",
|
| 127 |
+
"ř",
|
| 128 |
+
"Ś",
|
| 129 |
+
"ś",
|
| 130 |
+
"Ş",
|
| 131 |
+
"ş",
|
| 132 |
+
"Š",
|
| 133 |
+
"š",
|
| 134 |
+
"ţ",
|
| 135 |
+
"ū",
|
| 136 |
+
"ŭ",
|
| 137 |
+
"ů",
|
| 138 |
+
"Ż",
|
| 139 |
+
"Ž",
|
| 140 |
+
"ž",
|
| 141 |
+
"Ə",
|
| 142 |
+
"ơ",
|
| 143 |
+
"ș",
|
| 144 |
+
"ț",
|
| 145 |
+
"ə",
|
| 146 |
+
"ʻ",
|
| 147 |
+
"ʾ",
|
| 148 |
+
"ʿ",
|
| 149 |
+
"́",
|
| 150 |
+
"μ",
|
| 151 |
+
"ḫ",
|
| 152 |
+
"ṣ",
|
| 153 |
+
"‐",
|
| 154 |
+
"′",
|
| 155 |
+
"‹",
|
| 156 |
+
"›"
|
| 157 |
+
],
|
| 158 |
+
"units": [
|
| 159 |
+
"1",
|
| 160 |
+
"??",
|
| 161 |
+
"??ˈ",
|
| 162 |
+
"??ˌ",
|
| 163 |
+
"a",
|
| 164 |
+
"aɪ",
|
| 165 |
+
"aɪə",
|
| 166 |
+
"aɪəˈ",
|
| 167 |
+
"aɪəˌ",
|
| 168 |
+
"aɪˈ",
|
| 169 |
+
"aɪˌ",
|
| 170 |
+
"aʊ",
|
| 171 |
+
"aʊˈ",
|
| 172 |
+
"aʊˌ",
|
| 173 |
+
"aˈ",
|
| 174 |
+
"aˌ",
|
| 175 |
+
"b",
|
| 176 |
+
"bʲ",
|
| 177 |
+
"d",
|
| 178 |
+
"dʑ",
|
| 179 |
+
"dʒ",
|
| 180 |
+
"dʲ",
|
| 181 |
+
"e",
|
| 182 |
+
"eə",
|
| 183 |
+
"eəˈ",
|
| 184 |
+
"eəˌ",
|
| 185 |
+
"eɪ",
|
| 186 |
+
"eɪˈ",
|
| 187 |
+
"eɪˌ",
|
| 188 |
+
"eˈ",
|
| 189 |
+
"eː",
|
| 190 |
+
"eːˈ",
|
| 191 |
+
"eːˌ",
|
| 192 |
+
"f",
|
| 193 |
+
"fʲ",
|
| 194 |
+
"h",
|
| 195 |
+
"i",
|
| 196 |
+
"iə",
|
| 197 |
+
"iəˈ",
|
| 198 |
+
"iəˌ",
|
| 199 |
+
"iʊ",
|
| 200 |
+
"iˈ",
|
| 201 |
+
"iˌ",
|
| 202 |
+
"iː",
|
| 203 |
+
"iːˈ",
|
| 204 |
+
"iːˌ",
|
| 205 |
+
"j",
|
| 206 |
+
"k",
|
| 207 |
+
"kʲ",
|
| 208 |
+
"l",
|
| 209 |
+
"m",
|
| 210 |
+
"mʲ",
|
| 211 |
+
"n",
|
| 212 |
+
"o",
|
| 213 |
+
"oɪˈ",
|
| 214 |
+
"oˈ",
|
| 215 |
+
"oˌ",
|
| 216 |
+
"oː",
|
| 217 |
+
"oːˈ",
|
| 218 |
+
"oːˌ",
|
| 219 |
+
"p",
|
| 220 |
+
"pf",
|
| 221 |
+
"q",
|
| 222 |
+
"r",
|
| 223 |
+
"s",
|
| 224 |
+
"t",
|
| 225 |
+
"ts",
|
| 226 |
+
"tɕ",
|
| 227 |
+
"tʃ",
|
| 228 |
+
"tʲ",
|
| 229 |
+
"u",
|
| 230 |
+
"uˈ",
|
| 231 |
+
"uˌ",
|
| 232 |
+
"uː",
|
| 233 |
+
"uːˈ",
|
| 234 |
+
"uːˌ",
|
| 235 |
+
"v",
|
| 236 |
+
"vʲ",
|
| 237 |
+
"w",
|
| 238 |
+
"w-ˈ",
|
| 239 |
+
"x",
|
| 240 |
+
"y",
|
| 241 |
+
"yˈ",
|
| 242 |
+
"yˌ",
|
| 243 |
+
"yː",
|
| 244 |
+
"yːˈ",
|
| 245 |
+
"yːˌ",
|
| 246 |
+
"z",
|
| 247 |
+
"ç",
|
| 248 |
+
"ð",
|
| 249 |
+
"øː",
|
| 250 |
+
"øːˈ",
|
| 251 |
+
"øːˌ",
|
| 252 |
+
"ŋ",
|
| 253 |
+
"œ",
|
| 254 |
+
"œˈ",
|
| 255 |
+
"œˌ",
|
| 256 |
+
"œ̃ˈ",
|
| 257 |
+
"ɐ",
|
| 258 |
+
"ɐˈ",
|
| 259 |
+
"ɑ",
|
| 260 |
+
"ɑˈ",
|
| 261 |
+
"ɑˌ",
|
| 262 |
+
"ɑː",
|
| 263 |
+
"ɑːˈ",
|
| 264 |
+
"ɑːˌ",
|
| 265 |
+
"ɑ̃",
|
| 266 |
+
"ɑ̃ˈ",
|
| 267 |
+
"ɑ̃ˌ",
|
| 268 |
+
"ɒ",
|
| 269 |
+
"ɒˈ",
|
| 270 |
+
"ɒˌ",
|
| 271 |
+
"ɔ",
|
| 272 |
+
"ɔø",
|
| 273 |
+
"ɔøˈ",
|
| 274 |
+
"ɔøˌ",
|
| 275 |
+
"ɔɪ",
|
| 276 |
+
"ɔɪˈ",
|
| 277 |
+
"ɔɪˌ",
|
| 278 |
+
"ɔˈ",
|
| 279 |
+
"ɔˌ",
|
| 280 |
+
"ɔː",
|
| 281 |
+
"ɔːˈ",
|
| 282 |
+
"ɔːˌ",
|
| 283 |
+
"ɔ̃ˈ",
|
| 284 |
+
"ɔ̃ˌ",
|
| 285 |
+
"ɕ",
|
| 286 |
+
"ə",
|
| 287 |
+
"əl",
|
| 288 |
+
"əʊ",
|
| 289 |
+
"əʊˈ",
|
| 290 |
+
"əʊˌ",
|
| 291 |
+
"əˈ",
|
| 292 |
+
"əˌ",
|
| 293 |
+
"ɛ",
|
| 294 |
+
"ɛɪ",
|
| 295 |
+
"ɛɪˈ",
|
| 296 |
+
"ɛɪˌ",
|
| 297 |
+
"ɛˈ",
|
| 298 |
+
"ɛˌ",
|
| 299 |
+
"ɛː",
|
| 300 |
+
"ɛːˈ",
|
| 301 |
+
"ɛːˌ",
|
| 302 |
+
"ɛ̃ˌ",
|
| 303 |
+
"ɜ",
|
| 304 |
+
"ɜˈ",
|
| 305 |
+
"ɜˌ",
|
| 306 |
+
"ɜː",
|
| 307 |
+
"ɜːˈ",
|
| 308 |
+
"ɜːˌ",
|
| 309 |
+
"ɡ",
|
| 310 |
+
"ɡʲ",
|
| 311 |
+
"ɨ",
|
| 312 |
+
"ɨˈ",
|
| 313 |
+
"ɪ",
|
| 314 |
+
"ɪˈ",
|
| 315 |
+
"ɪˌ",
|
| 316 |
+
"ɫ",
|
| 317 |
+
"ɯ",
|
| 318 |
+
"ɯˈ",
|
| 319 |
+
"ɯˌ",
|
| 320 |
+
"ɲ",
|
| 321 |
+
"ɹ",
|
| 322 |
+
"ɾ",
|
| 323 |
+
"ʃ",
|
| 324 |
+
"ʊ",
|
| 325 |
+
"ʊə",
|
| 326 |
+
"ʊəˈ",
|
| 327 |
+
"ʊəˌ",
|
| 328 |
+
"ʊˈ",
|
| 329 |
+
"ʊˌ",
|
| 330 |
+
"ʌ",
|
| 331 |
+
"ʌˈ",
|
| 332 |
+
"ʌˌ",
|
| 333 |
+
"ʑ",
|
| 334 |
+
"ʒ",
|
| 335 |
+
"ʔ",
|
| 336 |
+
"θ"
|
| 337 |
+
],
|
| 338 |
+
"up": 3,
|
| 339 |
+
"max_len": 40,
|
| 340 |
+
"blank": 178,
|
| 341 |
+
"inputs": [
|
| 342 |
+
"chars"
|
| 343 |
+
],
|
| 344 |
+
"outputs": [
|
| 345 |
+
"logp"
|
| 346 |
+
]
|
| 347 |
+
}
|
web/models/apptor-g2p-de.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d981694e7a03030b2169be46b2094775dde4ec5a3e9406c92a3fc8f1ed8bbec3
|
| 3 |
+
size 12364141
|
web/models/apptor-tiny-tts-at.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"sample_rate": 24000,
|
| 3 |
+
"hop": 256,
|
| 4 |
+
"voices": [
|
| 5 |
+
"F2",
|
| 6 |
+
"M2",
|
| 7 |
+
"AT"
|
| 8 |
+
],
|
| 9 |
+
"symbols": [
|
| 10 |
+
"<pad>",
|
| 11 |
+
"<bos>",
|
| 12 |
+
"<eos>",
|
| 13 |
+
"<sp>",
|
| 14 |
+
"<unk>",
|
| 15 |
+
",",
|
| 16 |
+
".",
|
| 17 |
+
"?",
|
| 18 |
+
"!",
|
| 19 |
+
";",
|
| 20 |
+
":",
|
| 21 |
+
"\"",
|
| 22 |
+
"'",
|
| 23 |
+
"(",
|
| 24 |
+
")",
|
| 25 |
+
"—",
|
| 26 |
+
"…",
|
| 27 |
+
"p",
|
| 28 |
+
"b",
|
| 29 |
+
"t",
|
| 30 |
+
"d",
|
| 31 |
+
"k",
|
| 32 |
+
"ɡ",
|
| 33 |
+
"f",
|
| 34 |
+
"v",
|
| 35 |
+
"s",
|
| 36 |
+
"z",
|
| 37 |
+
"ʃ",
|
| 38 |
+
"ʒ",
|
| 39 |
+
"ç",
|
| 40 |
+
"x",
|
| 41 |
+
"h",
|
| 42 |
+
"m",
|
| 43 |
+
"n",
|
| 44 |
+
"ŋ",
|
| 45 |
+
"l",
|
| 46 |
+
"ɾ",
|
| 47 |
+
"r",
|
| 48 |
+
"j",
|
| 49 |
+
"ts",
|
| 50 |
+
"pf",
|
| 51 |
+
"tʃ",
|
| 52 |
+
"dʒ",
|
| 53 |
+
"ə",
|
| 54 |
+
"ɐ",
|
| 55 |
+
"ɜ",
|
| 56 |
+
"ɪ",
|
| 57 |
+
"i",
|
| 58 |
+
"iː",
|
| 59 |
+
"ɛ",
|
| 60 |
+
"ɛː",
|
| 61 |
+
"eː",
|
| 62 |
+
"a",
|
| 63 |
+
"ɑ",
|
| 64 |
+
"ɑː",
|
| 65 |
+
"ɔ",
|
| 66 |
+
"oː",
|
| 67 |
+
"ʊ",
|
| 68 |
+
"uː",
|
| 69 |
+
"y",
|
| 70 |
+
"yː",
|
| 71 |
+
"œ",
|
| 72 |
+
"øː",
|
| 73 |
+
"aɪ",
|
| 74 |
+
"aʊ",
|
| 75 |
+
"ɔø",
|
| 76 |
+
"ʊɐ"
|
| 77 |
+
],
|
| 78 |
+
"max_tokens": 512,
|
| 79 |
+
"max_frames": 3000,
|
| 80 |
+
"step": 126000,
|
| 81 |
+
"frontend": "espeak",
|
| 82 |
+
"frontend_fingerprint": "ddefc3ebfe4beeca2af195dc920c207110b07bd5067f225c575a3cdeef02d73f",
|
| 83 |
+
"inputs": [
|
| 84 |
+
"tokens",
|
| 85 |
+
"stress",
|
| 86 |
+
"voice",
|
| 87 |
+
"speed",
|
| 88 |
+
"pitch_shift",
|
| 89 |
+
"pitch_range",
|
| 90 |
+
"accent"
|
| 91 |
+
],
|
| 92 |
+
"outputs": [
|
| 93 |
+
"audio",
|
| 94 |
+
"durations"
|
| 95 |
+
],
|
| 96 |
+
"accent_style": "AT"
|
| 97 |
+
}
|
web/models/apptor-tiny-tts-at.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1db856e5aac4f6b21f6b7f6e026a63fa8fb29469fa2301b8b166ffc5ebaae05d
|
| 3 |
+
size 21382102
|
web/models/apptor-vocos-de.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:417f2413163d666b23a89dd73b1829a34ac316fb524a02cc6a4120660a40e6eb
|
| 3 |
+
size 16655451
|
web/ort/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ONNX Runtime Web 1.20.1 (https://github.com/microsoft/onnxruntime)
|
| 2 |
+
|
| 3 |
+
MIT License
|
| 4 |
+
|
| 5 |
+
Copyright (c) Microsoft Corporation
|
| 6 |
+
|
| 7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 8 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 9 |
+
in the Software without restriction, including without limitation the rights
|
| 10 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 12 |
+
furnished to do so, subject to the following conditions:
|
| 13 |
+
|
| 14 |
+
The above copyright notice and this permission notice shall be included in all
|
| 15 |
+
copies or substantial portions of the Software.
|
| 16 |
+
|
| 17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 19 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 20 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 21 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 22 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 23 |
+
SOFTWARE.
|
web/ort/ort-wasm-simd-threaded.mjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
var ortWasmThreaded = (() => {
|
| 3 |
+
var _scriptName = import.meta.url;
|
| 4 |
+
|
| 5 |
+
return (
|
| 6 |
+
async function(moduleArg = {}) {
|
| 7 |
+
var moduleRtn;
|
| 8 |
+
|
| 9 |
+
function aa(){g.buffer!=l.buffer&&m();return l}function n(){g.buffer!=l.buffer&&m();return ba}function r(){g.buffer!=l.buffer&&m();return ca}function u(){g.buffer!=l.buffer&&m();return da}function ea(){g.buffer!=l.buffer&&m();return fa}var w=Object.assign({},moduleArg),ha,x,ia=new Promise((a,b)=>{ha=a;x=b}),ja="object"==typeof window,A="function"==typeof importScripts,B="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,C=A&&"em-pthread"==self.name;
|
| 10 |
+
if(B){const {createRequire:a}=await import("module");var require=a(import.meta.url),D=require("worker_threads");global.Worker=D.Worker;C=(A=!D.lb)&&"em-pthread"==D.workerData}"use strict";w.mountExternalData=(a,b)=>{a.startsWith("./")&&(a=a.substring(2));(w.Ua||(w.Ua=new Map)).set(a,b)};w.unmountExternalData=()=>{delete w.Ua};
|
| 11 |
+
var SharedArrayBuffer=globalThis.SharedArrayBuffer??(new WebAssembly.Memory({initial:0,maximum:0,shared:!0})).buffer.constructor,ka=Object.assign({},w),la="./this.program",E=(a,b)=>{throw b;},F="",ma,G,H;
|
| 12 |
+
if(B){var fs=require("fs"),na=require("path");F=require("url").fileURLToPath(new URL("./",import.meta.url));ma=(a,b)=>{a=oa(a)?new URL(a):na.normalize(a);return fs.readFileSync(a,b?void 0:"utf8")};H=a=>{a=ma(a,!0);a.buffer||(a=new Uint8Array(a));return a};G=(a,b,c,d=!0)=>{a=oa(a)?new URL(a):na.normalize(a);fs.readFile(a,d?void 0:"utf8",(f,h)=>{f?c(f):b(d?h.buffer:h)})};!w.thisProgram&&1<process.argv.length&&(la=process.argv[1].replace(/\\/g,"/"));process.argv.slice(2);E=(a,b)=>{process.exitCode=
|
| 13 |
+
a;throw b;}}else if(ja||A)A?F=self.location.href:"undefined"!=typeof document&&document.currentScript&&(F=document.currentScript.src),_scriptName&&(F=_scriptName),F.startsWith("blob:")?F="":F=F.substr(0,F.replace(/[?#].*/,"").lastIndexOf("/")+1),B||(ma=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},A&&(H=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),G=(a,b,c)=>{var d=new XMLHttpRequest;
|
| 14 |
+
d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=()=>{200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)});B&&"undefined"==typeof performance&&(global.performance=require("perf_hooks").performance);var pa=console.log.bind(console),qa=console.error.bind(console);B&&(pa=(...a)=>fs.writeSync(1,a.join(" ")+"\n"),qa=(...a)=>fs.writeSync(2,a.join(" ")+"\n"));var ra=pa,I=qa;Object.assign(w,ka);ka=null;
|
| 15 |
+
if(C){var sa;if(B){var ta=D.parentPort;ta.on("message",b=>onmessage({data:b}));Object.assign(globalThis,{self:global,importScripts:()=>{},postMessage:b=>ta.postMessage(b),performance:global.performance||{now:Date.now}})}var ua=!1;I=function(...b){b=b.join(" ");B?fs.writeSync(2,b+"\n"):console.error(b)};self.alert=function(...b){postMessage({Za:"alert",text:b.join(" "),nb:K()})};w.instantiateWasm=(b,c)=>new Promise(d=>{sa=f=>{f=new WebAssembly.Instance(f,va());c(f);d()}});self.onunhandledrejection=
|
| 16 |
+
b=>{throw b.reason||b;};function a(b){try{var c=b.data,d=c.cmd;if("load"===d){let f=[];self.onmessage=h=>f.push(h);self.startWorker=()=>{postMessage({cmd:"loaded"});for(let h of f)a(h);self.onmessage=a};for(const h of c.handlers)if(!w[h]||w[h].proxy)w[h]=(...k)=>{postMessage({Za:"callHandler",kb:h,args:k})},"print"==h&&(ra=w[h]),"printErr"==h&&(I=w[h]);g=c.wasmMemory;m();sa(c.wasmModule)}else if("run"===d){wa(c.pthread_ptr,0,0,1,0,0);xa(c.pthread_ptr);ya();za();ua||=!0;try{Aa(c.start_routine,c.arg)}catch(f){if("unwind"!=
|
| 17 |
+
f)throw f;}}else"cancel"===d?K()&&Ba(-1):"setimmediate"!==c.target&&("checkMailbox"===d?ua&&Ca():d&&(I(`worker: received unknown command ${d}`),I(c)))}catch(f){throw Da(),f;}}self.onmessage=a}var L;w.wasmBinary&&(L=w.wasmBinary);var g,Ea,Fa=!1,M,l,ba,ca,da,N,fa;
|
| 18 |
+
function m(){var a=g.buffer;w.HEAP8=l=new Int8Array(a);w.HEAP16=new Int16Array(a);w.HEAPU8=ba=new Uint8Array(a);w.HEAPU16=new Uint16Array(a);w.HEAP32=ca=new Int32Array(a);w.HEAPU32=da=new Uint32Array(a);w.HEAPF32=new Float32Array(a);w.HEAPF64=fa=new Float64Array(a);w.HEAP64=N=new BigInt64Array(a);w.HEAPU64=new BigUint64Array(a)}
|
| 19 |
+
if(!C){g=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0});if(!(g.buffer instanceof SharedArrayBuffer))throw I("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),B&&I("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");m()}
|
| 20 |
+
var Ga=[],Ha=[],Ia=[],O=0,Ja=null,P=null;function Ka(){O--;if(0==O&&(null!==Ja&&(clearInterval(Ja),Ja=null),P)){var a=P;P=null;a()}}function La(a){a="Aborted("+a+")";I(a);Fa=!0;M=1;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");x(a);throw a;}var Ma=a=>a.startsWith("data:application/octet-stream;base64,"),oa=a=>a.startsWith("file://"),Na;function Oa(a){if(a==Na&&L)return new Uint8Array(L);if(H)return H(a);throw"both async and sync fetching of the wasm failed";}
|
| 21 |
+
function Pa(a){if(!L&&(ja||A)){if("function"==typeof fetch&&!oa(a))return fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw`failed to load wasm binary file at '${a}'`;return b.arrayBuffer()}).catch(()=>Oa(a));if(G)return new Promise((b,c)=>{G(a,d=>b(new Uint8Array(d)),c)})}return Promise.resolve().then(()=>Oa(a))}function Qa(a,b,c){return Pa(a).then(d=>WebAssembly.instantiate(d,b)).then(c,d=>{I(`failed to asynchronously prepare wasm: ${d}`);La(d)})}
|
| 22 |
+
function Ra(a,b){var c=Na;return L||"function"!=typeof WebAssembly.instantiateStreaming||Ma(c)||oa(c)||B||"function"!=typeof fetch?Qa(c,a,b):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,a).then(b,function(f){I(`wasm streaming compile failed: ${f}`);I("falling back to ArrayBuffer instantiation");return Qa(c,a,b)}))}
|
| 23 |
+
function va(){Sa={j:Ta,b:Ua,E:Va,g:Wa,V:Xa,A:Ya,C:Za,W:$a,T:ab,L:bb,S:cb,o:db,B:eb,y:fb,U:gb,z:hb,_:ib,Z:jb,P:kb,w:lb,F:mb,k:nb,O:xa,Y:ob,I:pb,J:qb,K:rb,G:sb,H:tb,v:ub,q:vb,l:wb,p:xb,e:yb,X:zb,x:Ab,d:Bb,f:Cb,i:Db,u:Eb,t:Fb,s:Gb,Q:Hb,R:Ib,D:Jb,h:Kb,n:Lb,M:Mb,m:Nb,a:g,r:Ob,N:Pb,c:Qb};return{a:Sa}}
|
| 24 |
+
var Rb={837620:(a,b,c,d,f)=>{if("undefined"==typeof w||!w.Ua)return 1;a=Q(a>>>0);a.startsWith("./")&&(a=a.substring(2));a=w.Ua.get(a);if(!a)return 2;b>>>=0;c>>>=0;d>>>=0;if(b+c>a.byteLength)return 3;try{const h=a.subarray(b,b+c);switch(f){case 0:n().set(h,d>>>0);break;case 1:w.mb(d,h);break;default:return 4}return 0}catch{return 4}},838303:()=>"undefined"!==typeof wasmOffsetConverter};function Ta(){return"undefined"!==typeof wasmOffsetConverter}
|
| 25 |
+
function Sb(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}
|
| 26 |
+
var Tb=a=>{a.terminate();a.onmessage=()=>{}},Wb=a=>{0==R.length&&(Ub(),Vb(R[0]));var b=R.pop();if(!b)return 6;S.push(b);T[a.Ra]=b;b.Ra=a.Ra;var c={cmd:"run",start_routine:a.cb,arg:a.ab,pthread_ptr:a.Ra};B&&b.unref();b.postMessage(c,a.ib);return 0},U=0,V=(a,b,...c)=>{for(var d=2*c.length,f=$b(),h=ac(8*d),k=h>>>3,q=0;q<c.length;q++){var y=c[q];"bigint"==typeof y?(N[k+2*q]=1n,N[k+2*q+1]=y):(N[k+2*q]=0n,ea()[k+2*q+1>>>0]=y)}a=bc(a,0,d,h,b);cc(f);return a};
|
| 27 |
+
function Ob(a){if(C)return V(0,1,a);M=a;if(!(0<U)){for(var b of S)Tb(b);for(b of R)Tb(b);R=[];S=[];T=[];Fa=!0}E(a,new Sb(a))}function dc(a){if(C)return V(1,0,a);Jb(a)}var Jb=a=>{M=a;if(C)throw dc(a),"unwind";Ob(a)},R=[],S=[],ec=[],T={};function fc(){for(var a=w.numThreads-1;a--;)Ub();Ga.unshift(()=>{O++;gc(()=>Ka())})}var ic=a=>{var b=a.Ra;delete T[b];R.push(a);S.splice(S.indexOf(a),1);a.Ra=0;hc(b)};function za(){ec.forEach(a=>a())}
|
| 28 |
+
var Vb=a=>new Promise(b=>{a.onmessage=h=>{h=h.data;var k=h.cmd;if(h.targetThread&&h.targetThread!=K()){var q=T[h.targetThread];q?q.postMessage(h,h.transferList):I(`Internal error! Worker sent a message "${k}" to target pthread ${h.targetThread}, but that thread no longer exists!`)}else if("checkMailbox"===k)Ca();else if("spawnThread"===k)Wb(h);else if("cleanupThread"===k)ic(T[h.thread]);else if("killThread"===k)h=h.thread,k=T[h],delete T[h],Tb(k),hc(h),S.splice(S.indexOf(k),1),k.Ra=0;else if("cancelThread"===
|
| 29 |
+
k)T[h.thread].postMessage({cmd:"cancel"});else if("loaded"===k)a.loaded=!0,B&&!a.Ra&&a.unref(),b(a);else if("alert"===k)alert(`Thread ${h.threadId}: ${h.text}`);else if("setimmediate"===h.target)a.postMessage(h);else if("callHandler"===k)w[h.handler](...h.args);else k&&I(`worker sent an unknown command ${k}`)};a.onerror=h=>{I(`${"worker sent an error!"} ${h.filename}:${h.lineno}: ${h.message}`);throw h;};B&&(a.on("message",h=>a.onmessage({data:h})),a.on("error",h=>a.onerror(h)));var c=[],d=[],f;for(f of d)w.hasOwnProperty(f)&&
|
| 30 |
+
c.push(f);a.postMessage({cmd:"load",handlers:c,wasmMemory:g,wasmModule:Ea})});function gc(a){C?a():Promise.all(R.map(Vb)).then(a)}function Ub(){var a=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});R.push(a)}var jc=a=>{for(;0<a.length;)a.shift()(w)},ya=()=>{var a=K(),b=u()[a+52>>>2>>>0];a=u()[a+56>>>2>>>0];kc(b,b-a);cc(b)},lc=[],mc,Aa=(a,b)=>{U=0;var c=lc[a];c||(a>=lc.length&&(lc.length=a+1),lc[a]=c=mc.get(a));a=c(b);0<U?M=a:Ba(a)};
|
| 31 |
+
class nc{constructor(a){this.Xa=a-24}}var oc=0,pc=0;function Ua(a,b,c){a>>>=0;var d=new nc(a);b>>>=0;c>>>=0;u()[d.Xa+16>>>2>>>0]=0;u()[d.Xa+4>>>2>>>0]=b;u()[d.Xa+8>>>2>>>0]=c;oc=a;pc++;throw oc;}function qc(a,b,c,d){return C?V(2,1,a,b,c,d):Va(a,b,c,d)}
|
| 32 |
+
function Va(a,b,c,d){a>>>=0;b>>>=0;c>>>=0;d>>>=0;if("undefined"==typeof SharedArrayBuffer)return I("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var f=[];if(C&&0===f.length)return qc(a,b,c,d);a={cb:c,Ra:a,ab:d,ib:f};return C?(a.Za="spawnThread",postMessage(a,f),0):Wb(a)}
|
| 33 |
+
var rc="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,sc=(a,b,c)=>{b>>>=0;var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.buffer&&rc)return rc.decode(a.buffer instanceof SharedArrayBuffer?a.slice(b,c):a.subarray(b,c));for(d="";b<c;){var f=a[b++];if(f&128){var h=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|h);else{var k=a[b++]&63;f=224==(f&240)?(f&15)<<12|h<<6|k:(f&7)<<18|h<<12|k<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>
|
| 34 |
+
10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d},Q=(a,b)=>(a>>>=0)?sc(n(),a,b):"";function Wa(a,b,c){return C?V(3,1,a,b,c):0}function Xa(a,b){if(C)return V(4,1,a,b)}
|
| 35 |
+
var tc=a=>{for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b},uc=(a,b,c,d)=>{c>>>=0;if(!(0<d))return 0;var f=c;d=c+d-1;for(var h=0;h<a.length;++h){var k=a.charCodeAt(h);if(55296<=k&&57343>=k){var q=a.charCodeAt(++h);k=65536+((k&1023)<<10)|q&1023}if(127>=k){if(c>=d)break;b[c++>>>0]=k}else{if(2047>=k){if(c+1>=d)break;b[c++>>>0]=192|k>>6}else{if(65535>=k){if(c+2>=d)break;b[c++>>>0]=224|k>>12}else{if(c+3>=d)break;b[c++>>>0]=240|k>>
|
| 36 |
+
18;b[c++>>>0]=128|k>>12&63}b[c++>>>0]=128|k>>6&63}b[c++>>>0]=128|k&63}}b[c>>>0]=0;return c-f},W=(a,b,c)=>uc(a,n(),b,c);function Ya(a,b){if(C)return V(5,1,a,b)}function Za(a,b,c){if(C)return V(6,1,a,b,c)}function $a(a,b,c){return C?V(7,1,a,b,c):0}function ab(a,b){if(C)return V(8,1,a,b)}function bb(a,b,c){if(C)return V(9,1,a,b,c)}function cb(a,b,c,d){if(C)return V(10,1,a,b,c,d)}function db(a,b,c,d){if(C)return V(11,1,a,b,c,d)}function eb(a,b,c,d){if(C)return V(12,1,a,b,c,d)}
|
| 37 |
+
function fb(a){if(C)return V(13,1,a)}function gb(a,b){if(C)return V(14,1,a,b)}function hb(a,b,c){if(C)return V(15,1,a,b,c)}var ib=()=>{La("")},jb=()=>1;function kb(a){wa(a>>>0,!A,1,!ja,131072,!1);za()}function xa(a){a>>>=0;"function"===typeof Atomics.jb&&(Atomics.jb(r(),a>>>2,a).value.then(Ca),a+=128,Atomics.store(r(),a>>>2,1))}
|
| 38 |
+
var Ca=()=>{var a=K();if(a&&(xa(a),a=vc,!Fa))try{if(a(),!(0<U))try{C?Ba(M):Jb(M)}catch(b){b instanceof Sb||"unwind"==b||E(1,b)}}catch(b){b instanceof Sb||"unwind"==b||E(1,b)}};function lb(a,b){a>>>=0;a==b>>>0?setTimeout(Ca):C?postMessage({targetThread:a,cmd:"checkMailbox"}):(a=T[a])&&a.postMessage({cmd:"checkMailbox"})}var wc=[];function mb(a,b,c,d,f){b>>>=0;d/=2;wc.length=d;c=f>>>0>>>3;for(f=0;f<d;f++)wc[f]=N[c+2*f]?N[c+2*f+1]:ea()[c+2*f+1>>>0];return(b?Rb[b]:xc[a])(...wc)}
|
| 39 |
+
function nb(a){a>>>=0;C?postMessage({cmd:"cleanupThread",thread:a}):ic(T[a])}function ob(a){B&&T[a>>>0].ref()}
|
| 40 |
+
function pb(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);r()[b>>>2>>>0]=a.getUTCSeconds();r()[b+4>>>2>>>0]=a.getUTCMinutes();r()[b+8>>>2>>>0]=a.getUTCHours();r()[b+12>>>2>>>0]=a.getUTCDate();r()[b+16>>>2>>>0]=a.getUTCMonth();r()[b+20>>>2>>>0]=a.getUTCFullYear()-1900;r()[b+24>>>2>>>0]=a.getUTCDay();a=(a.getTime()-Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0))/864E5|0;r()[b+28>>>2>>>0]=a}
|
| 41 |
+
var X=a=>0===a%4&&(0!==a%100||0===a%400),yc=[0,31,60,91,121,152,182,213,244,274,305,335],zc=[0,31,59,90,120,151,181,212,243,273,304,334];
|
| 42 |
+
function qb(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);r()[b>>>2>>>0]=a.getSeconds();r()[b+4>>>2>>>0]=a.getMinutes();r()[b+8>>>2>>>0]=a.getHours();r()[b+12>>>2>>>0]=a.getDate();r()[b+16>>>2>>>0]=a.getMonth();r()[b+20>>>2>>>0]=a.getFullYear()-1900;r()[b+24>>>2>>>0]=a.getDay();var c=(X(a.getFullYear())?yc:zc)[a.getMonth()]+a.getDate()-1|0;r()[b+28>>>2>>>0]=c;r()[b+36>>>2>>>0]=-(60*a.getTimezoneOffset());c=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();
|
| 43 |
+
var d=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();a=(c!=d&&a.getTimezoneOffset()==Math.min(d,c))|0;r()[b+32>>>2>>>0]=a}
|
| 44 |
+
function rb(a){a>>>=0;var b=new Date(r()[a+20>>>2>>>0]+1900,r()[a+16>>>2>>>0],r()[a+12>>>2>>>0],r()[a+8>>>2>>>0],r()[a+4>>>2>>>0],r()[a>>>2>>>0],0),c=r()[a+32>>>2>>>0],d=b.getTimezoneOffset(),f=(new Date(b.getFullYear(),6,1)).getTimezoneOffset(),h=(new Date(b.getFullYear(),0,1)).getTimezoneOffset(),k=Math.min(h,f);0>c?r()[a+32>>>2>>>0]=Number(f!=h&&k==d):0<c!=(k==d)&&(f=Math.max(h,f),b.setTime(b.getTime()+6E4*((0<c?k:f)-d)));r()[a+24>>>2>>>0]=b.getDay();c=(X(b.getFullYear())?yc:zc)[b.getMonth()]+
|
| 45 |
+
b.getDate()-1|0;r()[a+28>>>2>>>0]=c;r()[a>>>2>>>0]=b.getSeconds();r()[a+4>>>2>>>0]=b.getMinutes();r()[a+8>>>2>>>0]=b.getHours();r()[a+12>>>2>>>0]=b.getDate();r()[a+16>>>2>>>0]=b.getMonth();r()[a+20>>>2>>>0]=b.getYear();a=b.getTime();return BigInt(isNaN(a)?-1:a/1E3)}function sb(a,b,c,d,f,h,k){return C?V(16,1,a,b,c,d,f,h,k):-52}function tb(a,b,c,d,f,h){if(C)return V(17,1,a,b,c,d,f,h)}
|
| 46 |
+
function ub(a,b,c,d){a>>>=0;b>>>=0;c>>>=0;d>>>=0;var f=(new Date).getFullYear(),h=new Date(f,0,1),k=new Date(f,6,1);f=h.getTimezoneOffset();var q=k.getTimezoneOffset(),y=Math.max(f,q);u()[a>>>2>>>0]=60*y;r()[b>>>2>>>0]=Number(f!=q);a=v=>v.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1];h=a(h);k=a(k);q<f?(W(h,c,17),W(k,d,17)):(W(h,d,17),W(k,c,17))}var Ac=[];
|
| 47 |
+
function vb(a,b,c){a>>>=0;b>>>=0;c>>>=0;Ac.length=0;for(var d;d=n()[b++>>>0];){var f=105!=d;f&=112!=d;c+=f&&c%8?4:0;Ac.push(112==d?u()[c>>>2>>>0]:106==d?N[c>>>3]:105==d?r()[c>>>2>>>0]:ea()[c>>>3>>>0]);c+=f?8:4}return Rb[a](...Ac)}var wb=()=>{},xb=()=>Date.now();function yb(a,b){return I(Q(a>>>0,b>>>0))}var zb=()=>{U+=1;throw"unwind";};function Ab(){return 4294901760}var Bb;Bb=()=>performance.timeOrigin+performance.now();var Cb=()=>B?require("os").cpus().length:navigator.hardwareConcurrency;
|
| 48 |
+
function Db(){La("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER");return 0}function Eb(a){a>>>=0;var b=n().length;if(a<=b||4294901760<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);var f=Math;d=Math.max(a,d);a:{f=(f.min.call(f,4294901760,d+(65536-d%65536)%65536)-g.buffer.byteLength+65535)/65536;try{g.grow(f);m();var h=1;break a}catch(k){}h=void 0}if(h)return!0}return!1}
|
| 49 |
+
var Bc=()=>{La("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER");return 0},Y={},Cc=a=>{a.forEach(b=>{var c=Bc();c&&(Y[c]=b)})};function Fb(){var a=Error().stack.toString().split("\n");"Error"==a[0]&&a.shift();Cc(a);Y.$a=Bc();Y.bb=a;return Y.$a}
|
| 50 |
+
function Gb(a,b,c){a>>>=0;b>>>=0;if(Y.$a==a)var d=Y.bb;else d=Error().stack.toString().split("\n"),"Error"==d[0]&&d.shift(),Cc(d);for(var f=3;d[f]&&Bc()!=a;)++f;for(a=0;a<c&&d[a+f];++a)r()[b+4*a>>>2>>>0]=Bc();return a}
|
| 51 |
+
var Dc={},Fc=()=>{if(!Ec){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:la||"./this.program"},b;for(b in Dc)void 0===Dc[b]?delete a[b]:a[b]=Dc[b];var c=[];for(b in a)c.push(`${b}=${a[b]}`);Ec=c}return Ec},Ec;
|
| 52 |
+
function Hb(a,b){if(C)return V(18,1,a,b);a>>>=0;b>>>=0;var c=0;Fc().forEach((d,f)=>{var h=b+c;f=u()[a+4*f>>>2>>>0]=h;for(h=0;h<d.length;++h)aa()[f++>>>0]=d.charCodeAt(h);aa()[f>>>0]=0;c+=d.length+1});return 0}function Ib(a,b){if(C)return V(19,1,a,b);a>>>=0;b>>>=0;var c=Fc();u()[a>>>2>>>0]=c.length;var d=0;c.forEach(f=>d+=f.length+1);u()[b>>>2>>>0]=d;return 0}function Kb(a){return C?V(20,1,a):52}function Lb(a,b,c,d){return C?V(21,1,a,b,c,d):52}function Mb(a,b,c,d){return C?V(22,1,a,b,c,d):70}
|
| 53 |
+
var Gc=[null,[],[]];function Nb(a,b,c,d){if(C)return V(23,1,a,b,c,d);b>>>=0;c>>>=0;d>>>=0;for(var f=0,h=0;h<c;h++){var k=u()[b>>>2>>>0],q=u()[b+4>>>2>>>0];b+=8;for(var y=0;y<q;y++){var v=n()[k+y>>>0],z=Gc[a];0===v||10===v?((1===a?ra:I)(sc(z,0)),z.length=0):z.push(v)}f+=q}u()[d>>>2>>>0]=f;return 0}var Hc=[31,29,31,30,31,30,31,31,30,31,30,31],Ic=[31,28,31,30,31,30,31,31,30,31,30,31];function Jc(a){var b=Array(tc(a)+1);uc(a,b,0,b.length);return b}var Kc=(a,b)=>{aa().set(a,b>>>0)};
|
| 54 |
+
function Pb(a,b,c,d){function f(e,p,t){for(e="number"==typeof e?e.toString():e||"";e.length<p;)e=t[0]+e;return e}function h(e,p){return f(e,p,"0")}function k(e,p){function t(Xb){return 0>Xb?-1:0<Xb?1:0}var J;0===(J=t(e.getFullYear()-p.getFullYear()))&&0===(J=t(e.getMonth()-p.getMonth()))&&(J=t(e.getDate()-p.getDate()));return J}function q(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),
|
| 55 |
+
0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function y(e){var p=e.Sa;for(e=new Date((new Date(e.Ta+1900,0,1)).getTime());0<p;){var t=e.getMonth(),J=(X(e.getFullYear())?Hc:Ic)[t];if(p>J-e.getDate())p-=J-e.getDate()+1,e.setDate(1),11>t?e.setMonth(t+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1));else{e.setDate(e.getDate()+p);break}}t=new Date(e.getFullYear()+1,0,4);p=q(new Date(e.getFullYear(),
|
| 56 |
+
0,4));t=q(t);return 0>=k(p,e)?0>=k(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}a>>>=0;b>>>=0;c>>>=0;d>>>=0;var v=u()[d+40>>>2>>>0];d={gb:r()[d>>>2>>>0],fb:r()[d+4>>>2>>>0],Va:r()[d+8>>>2>>>0],Ya:r()[d+12>>>2>>>0],Wa:r()[d+16>>>2>>>0],Ta:r()[d+20>>>2>>>0],Qa:r()[d+24>>>2>>>0],Sa:r()[d+28>>>2>>>0],ob:r()[d+32>>>2>>>0],eb:r()[d+36>>>2>>>0],hb:v?Q(v):""};c=Q(c);v={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y",
|
| 57 |
+
"%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var z in v)c=c.replace(new RegExp(z,"g"),v[z]);var Yb="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Zb="January February March April May June July August September October November December".split(" ");v={"%a":e=>Yb[e.Qa].substring(0,3),
|
| 58 |
+
"%A":e=>Yb[e.Qa],"%b":e=>Zb[e.Wa].substring(0,3),"%B":e=>Zb[e.Wa],"%C":e=>h((e.Ta+1900)/100|0,2),"%d":e=>h(e.Ya,2),"%e":e=>f(e.Ya,2," "),"%g":e=>y(e).toString().substring(2),"%G":y,"%H":e=>h(e.Va,2),"%I":e=>{e=e.Va;0==e?e=12:12<e&&(e-=12);return h(e,2)},"%j":e=>{for(var p=0,t=0;t<=e.Wa-1;p+=(X(e.Ta+1900)?Hc:Ic)[t++]);return h(e.Ya+p,3)},"%m":e=>h(e.Wa+1,2),"%M":e=>h(e.fb,2),"%n":()=>"\n","%p":e=>0<=e.Va&&12>e.Va?"AM":"PM","%S":e=>h(e.gb,2),"%t":()=>"\t","%u":e=>e.Qa||7,"%U":e=>h(Math.floor((e.Sa+
|
| 59 |
+
7-e.Qa)/7),2),"%V":e=>{var p=Math.floor((e.Sa+7-(e.Qa+6)%7)/7);2>=(e.Qa+371-e.Sa-2)%7&&p++;if(p)53==p&&(t=(e.Qa+371-e.Sa)%7,4==t||3==t&&X(e.Ta)||(p=1));else{p=52;var t=(e.Qa+7-e.Sa-1)%7;(4==t||5==t&&X(e.Ta%400-1))&&p++}return h(p,2)},"%w":e=>e.Qa,"%W":e=>h(Math.floor((e.Sa+7-(e.Qa+6)%7)/7),2),"%y":e=>(e.Ta+1900).toString().substring(2),"%Y":e=>e.Ta+1900,"%z":e=>{e=e.eb;var p=0<=e;e=Math.abs(e)/60;return(p?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.hb,"%%":()=>"%"};c=c.replace(/%%/g,
|
| 60 |
+
"\x00\x00");for(z in v)c.includes(z)&&(c=c.replace(new RegExp(z,"g"),v[z](d)));c=c.replace(/\0\0/g,"%");z=Jc(c);if(z.length>b)return 0;Kc(z,a);return z.length-1}function Qb(a,b,c,d){return Pb(a>>>0,b>>>0,c>>>0,d>>>0)}C||fc();
|
| 61 |
+
var xc=[Ob,dc,qc,Wa,Xa,Ya,Za,$a,ab,bb,cb,db,eb,fb,gb,hb,sb,tb,Hb,Ib,Kb,Lb,Mb,Nb],Sa,Z=function(){function a(c,d){Z=c.exports;Z=Lc();ec.push(Z.Ea);mc=Z.Fa;Ha.unshift(Z.$);Ea=d;Ka();return Z}var b=va();O++;if(w.instantiateWasm)try{return w.instantiateWasm(b,a)}catch(c){I(`Module.instantiateWasm callback failed with error: ${c}`),x(c)}Na||=w.locateFile?Ma("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":w.locateFile?w.locateFile("ort-wasm-simd-threaded.wasm",F):F+"ort-wasm-simd-threaded.wasm":
|
| 62 |
+
(new URL("ort-wasm-simd-threaded.wasm",import.meta.url)).href;Ra(b,function(c){a(c.instance,c.module)}).catch(x);return{}}();w._OrtInit=(a,b)=>(w._OrtInit=Z.aa)(a,b);w._OrtGetLastError=(a,b)=>(w._OrtGetLastError=Z.ba)(a,b);w._OrtCreateSessionOptions=(a,b,c,d,f,h,k,q,y,v)=>(w._OrtCreateSessionOptions=Z.ca)(a,b,c,d,f,h,k,q,y,v);w._OrtAppendExecutionProvider=(a,b)=>(w._OrtAppendExecutionProvider=Z.da)(a,b);w._OrtAddFreeDimensionOverride=(a,b,c)=>(w._OrtAddFreeDimensionOverride=Z.ea)(a,b,c);
|
| 63 |
+
w._OrtAddSessionConfigEntry=(a,b,c)=>(w._OrtAddSessionConfigEntry=Z.fa)(a,b,c);w._OrtReleaseSessionOptions=a=>(w._OrtReleaseSessionOptions=Z.ga)(a);w._OrtCreateSession=(a,b,c)=>(w._OrtCreateSession=Z.ha)(a,b,c);w._OrtReleaseSession=a=>(w._OrtReleaseSession=Z.ia)(a);w._OrtGetInputOutputCount=(a,b,c)=>(w._OrtGetInputOutputCount=Z.ja)(a,b,c);w._OrtGetInputName=(a,b)=>(w._OrtGetInputName=Z.ka)(a,b);w._OrtGetOutputName=(a,b)=>(w._OrtGetOutputName=Z.la)(a,b);w._OrtFree=a=>(w._OrtFree=Z.ma)(a);
|
| 64 |
+
w._OrtCreateTensor=(a,b,c,d,f,h)=>(w._OrtCreateTensor=Z.na)(a,b,c,d,f,h);w._OrtGetTensorData=(a,b,c,d,f)=>(w._OrtGetTensorData=Z.oa)(a,b,c,d,f);w._OrtReleaseTensor=a=>(w._OrtReleaseTensor=Z.pa)(a);w._OrtCreateRunOptions=(a,b,c,d)=>(w._OrtCreateRunOptions=Z.qa)(a,b,c,d);w._OrtAddRunConfigEntry=(a,b,c)=>(w._OrtAddRunConfigEntry=Z.ra)(a,b,c);w._OrtReleaseRunOptions=a=>(w._OrtReleaseRunOptions=Z.sa)(a);w._OrtCreateBinding=a=>(w._OrtCreateBinding=Z.ta)(a);
|
| 65 |
+
w._OrtBindInput=(a,b,c)=>(w._OrtBindInput=Z.ua)(a,b,c);w._OrtBindOutput=(a,b,c,d)=>(w._OrtBindOutput=Z.va)(a,b,c,d);w._OrtClearBoundOutputs=a=>(w._OrtClearBoundOutputs=Z.wa)(a);w._OrtReleaseBinding=a=>(w._OrtReleaseBinding=Z.xa)(a);w._OrtRunWithBinding=(a,b,c,d,f)=>(w._OrtRunWithBinding=Z.ya)(a,b,c,d,f);w._OrtRun=(a,b,c,d,f,h,k,q)=>(w._OrtRun=Z.za)(a,b,c,d,f,h,k,q);w._OrtEndProfiling=a=>(w._OrtEndProfiling=Z.Aa)(a);var K=()=>(K=Z.Ba)();w._malloc=a=>(w._malloc=Z.Ca)(a);w._free=a=>(w._free=Z.Da)(a);
|
| 66 |
+
var wa=(a,b,c,d,f,h)=>(wa=Z.Ga)(a,b,c,d,f,h),Da=()=>(Da=Z.Ha)(),bc=(a,b,c,d,f)=>(bc=Z.Ia)(a,b,c,d,f),hc=a=>(hc=Z.Ja)(a),Ba=a=>(Ba=Z.Ka)(a),vc=()=>(vc=Z.La)(),kc=(a,b)=>(kc=Z.Ma)(a,b),cc=a=>(cc=Z.Na)(a),ac=a=>(ac=Z.Oa)(a),$b=()=>($b=Z.Pa)();w.___start_em_js=838360;w.___stop_em_js=838421;
|
| 67 |
+
function Lc(){var a=Z;a=Object.assign({},a);var b=d=>()=>d()>>>0,c=d=>f=>d(f)>>>0;a.Ba=b(a.Ba);a.Ca=c(a.Ca);a.emscripten_main_runtime_thread_id=b(a.emscripten_main_runtime_thread_id);a.Oa=c(a.Oa);a.Pa=b(a.Pa);return a}w.stackSave=()=>$b();w.stackRestore=a=>cc(a);w.stackAlloc=a=>ac(a);w.UTF8ToString=Q;w.stringToUTF8=W;w.lengthBytesUTF8=tc;var Mc;P=function Nc(){Mc||Oc();Mc||(P=Nc)};
|
| 68 |
+
function Oc(){0<O||(C?(ha(w),C||jc(Ha),startWorker(w)):(jc(Ga),0<O||Mc||(Mc=!0,w.calledRun=!0,Fa||(C||jc(Ha),ha(w),C||jc(Ia)))))}Oc();moduleRtn=ia;
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
return moduleRtn;
|
| 72 |
+
}
|
| 73 |
+
);
|
| 74 |
+
})();
|
| 75 |
+
export default ortWasmThreaded;
|
| 76 |
+
var isPthread = globalThis.self?.name === 'em-pthread';
|
| 77 |
+
var isNode = typeof globalThis.process?.versions?.node == 'string';
|
| 78 |
+
if (isNode) isPthread = (await import('worker_threads')).workerData === 'em-pthread';
|
| 79 |
+
|
| 80 |
+
// When running as a pthread, construct a new instance on startup
|
| 81 |
+
isPthread && ortWasmThreaded();
|
web/ort/ort-wasm-simd-threaded.wasm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:207d02be4591c156b0a98f024f3d58005b5b04c92274d759fb390338c63559ea
|
| 3 |
+
size 11246032
|
web/ort/ort.wasm.min.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* ONNX Runtime Web v1.20.1
|
| 3 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 4 |
+
* Licensed under the MIT License.
|
| 5 |
+
*/
|
| 6 |
+
var Ge=Object.defineProperty;var Sr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var Or=Object.prototype.hasOwnProperty;var He=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var w=(t,e)=>()=>(t&&(e=t(t=0)),e);var je=(t,e)=>{for(var n in e)Ge(t,n,{get:e[n],enumerable:!0})},vr=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ar(e))!Or.call(t,r)&&r!==n&&Ge(t,r,{get:()=>e[r],enumerable:!(o=Sr(e,r))||o.enumerable});return t};var ut=t=>vr(Ge({},"__esModule",{value:!0}),t);var be,z,oe,xr,ge,Ee=w(()=>{"use strict";be=new Map,z=[],oe=(t,e,n)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let o=be.get(t);if(o===void 0)be.set(t,{backend:e,priority:n});else{if(o.priority>n)return;if(o.priority===n&&o.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){let r=z.indexOf(t);r!==-1&&z.splice(r,1);for(let i=0;i<z.length;i++)if(be.get(z[i]).priority<=n){z.splice(i,0,t);return}z.push(t)}return}throw new TypeError("not a valid backend")},xr=async t=>{let e=be.get(t);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let n=!!e.initPromise;try{return n||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(o){return n||(e.error=`${o}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},ge=async t=>{let e=t.executionProviders||[],n=e.map(a=>typeof a=="string"?a:a.name),o=n.length===0?z:n,r,i=[],s=new Set;for(let a of o){let u=await xr(a);typeof u=="string"?i.push({name:a,err:u}):(r||(r=u),r===u&&s.add(a))}if(!r)throw new Error(`no available backend found. ERR: ${i.map(a=>`[${a.name}] ${a.err}`).join(", ")}`);for(let{name:a,err:u}of i)n.includes(a)&&console.warn(`removing requested execution provider "${a}" from session options because it is not available: ${u}`);let f=e.filter(a=>s.has(typeof a=="string"?a:a.name));return[r,new Proxy(t,{get:(a,u)=>u==="executionProviders"?f:Reflect.get(a,u)})]}});var ft=w(()=>{"use strict";Ee()});var ct,lt=w(()=>{"use strict";ct="1.20.1"});var dt,U,Ve=w(()=>{"use strict";lt();dt="warning",U={wasm:{},webgl:{},webgpu:{},versions:{common:ct},set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);dt=t}},get logLevel(){return dt}};Object.defineProperty(U,"logLevel",{enumerable:!0})});var T,pt=w(()=>{"use strict";Ve();T=U});var mt,ht,yt=w(()=>{"use strict";mt=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=t.dims[3],n.height=t.dims[2];let o=n.getContext("2d");if(o!=null){let r,i;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(r=t.dims[2],i=t.dims[3]):(r=t.dims[3],i=t.dims[2]);let s=e?.format!==void 0?e.format:"RGB",f=e?.norm,a,u;f===void 0||f.mean===void 0?a=[255,255,255,255]:typeof f.mean=="number"?a=[f.mean,f.mean,f.mean,f.mean]:(a=[f.mean[0],f.mean[1],f.mean[2],0],f.mean[3]!==void 0&&(a[3]=f.mean[3])),f===void 0||f.bias===void 0?u=[0,0,0,0]:typeof f.bias=="number"?u=[f.bias,f.bias,f.bias,f.bias]:(u=[f.bias[0],f.bias[1],f.bias[2],0],f.bias[3]!==void 0&&(u[3]=f.bias[3]));let d=i*r,l=0,c=d,m=d*2,p=-1;s==="RGBA"?(l=0,c=d,m=d*2,p=d*3):s==="RGB"?(l=0,c=d,m=d*2):s==="RBG"&&(l=0,m=d,c=d*2);for(let h=0;h<i;h++)for(let E=0;E<r;E++){let O=(t.data[l++]-u[0])*a[0],y=(t.data[c++]-u[1])*a[1],b=(t.data[m++]-u[2])*a[2],A=p===-1?255:(t.data[p++]-u[3])*a[3];o.fillStyle="rgba("+O+","+y+","+b+","+A+")",o.fillRect(E,h,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},ht=(t,e)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),o;if(n!=null){let r,i,s;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(r=t.dims[2],i=t.dims[1],s=t.dims[3]):(r=t.dims[3],i=t.dims[2],s=t.dims[1]);let f=e!==void 0&&e.format!==void 0?e.format:"RGB",a=e?.norm,u,d;a===void 0||a.mean===void 0?u=[255,255,255,255]:typeof a.mean=="number"?u=[a.mean,a.mean,a.mean,a.mean]:(u=[a.mean[0],a.mean[1],a.mean[2],255],a.mean[3]!==void 0&&(u[3]=a.mean[3])),a===void 0||a.bias===void 0?d=[0,0,0,0]:typeof a.bias=="number"?d=[a.bias,a.bias,a.bias,a.bias]:(d=[a.bias[0],a.bias[1],a.bias[2],0],a.bias[3]!==void 0&&(d[3]=a.bias[3]));let l=i*r;if(e!==void 0&&(e.format!==void 0&&s===4&&e.format!=="RGBA"||s===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let c=4,m=0,p=1,h=2,E=3,O=0,y=l,b=l*2,A=-1;f==="RGBA"?(O=0,y=l,b=l*2,A=l*3):f==="RGB"?(O=0,y=l,b=l*2):f==="RBG"&&(O=0,b=l,y=l*2),o=n.createImageData(r,i);for(let M=0;M<i*r;m+=c,p+=c,h+=c,E+=c,M++)o.data[m]=(t.data[O++]-d[0])*u[0],o.data[p]=(t.data[y++]-d[1])*u[1],o.data[h]=(t.data[b++]-d[2])*u[2],o.data[E]=A===-1?255:(t.data[A++]-d[3])*u[3]}else throw new Error("Can not access image data");return o}});var Ye,wt,bt,gt,Et,Tt,St=w(()=>{"use strict";Te();Ye=(t,e)=>{if(t===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:n,width:o}=e,r=e.norm??{mean:255,bias:0},i,s;typeof r.mean=="number"?i=[r.mean,r.mean,r.mean,r.mean]:i=[r.mean[0],r.mean[1],r.mean[2],r.mean[3]??255],typeof r.bias=="number"?s=[r.bias,r.bias,r.bias,r.bias]:s=[r.bias[0],r.bias[1],r.bias[2],r.bias[3]??0];let f=e.format!==void 0?e.format:"RGBA",a=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",u=n*o,d=a==="RGBA"?new Float32Array(u*4):new Float32Array(u*3),l=4,c=0,m=1,p=2,h=3,E=0,O=u,y=u*2,b=-1;f==="RGB"&&(l=3,c=0,m=1,p=2,h=-1),a==="RGBA"?b=u*3:a==="RBG"?(E=0,y=u,O=u*2):a==="BGR"&&(y=0,O=u,E=u*2);for(let M=0;M<u;M++,c+=l,p+=l,m+=l,h+=l)d[E++]=(t[c]+s[0])/i[0],d[O++]=(t[m]+s[1])/i[1],d[y++]=(t[p]+s[2])/i[2],b!==-1&&h!==-1&&(d[b++]=(t[h]+s[3])/i[3]);return a==="RGBA"?new P("float32",d,[1,4,n,o]):new P("float32",d,[1,3,n,o])},wt=async(t,e)=>{let n=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,o=typeof ImageData<"u"&&t instanceof ImageData,r=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,i=typeof t=="string",s,f=e??{},a=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},u=d=>typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement||d instanceof OffscreenCanvas?d.getContext("2d"):null;if(n){let d=a();d.width=t.width,d.height=t.height;let l=u(d);if(l!=null){let c=t.height,m=t.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(c=e.resizedHeight,m=e.resizedWidth),e!==void 0){if(f=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");f.tensorFormat="RGBA",f.height=c,f.width=m}else f.tensorFormat="RGBA",f.height=c,f.width=m;l.drawImage(t,0,0),s=l.getImageData(0,0,m,c).data}else throw new Error("Can not access image data")}else if(o){let d,l;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(d=e.resizedHeight,l=e.resizedWidth):(d=t.height,l=t.width),e!==void 0&&(f=e),f.format="RGBA",f.height=d,f.width=l,e!==void 0){let c=a();c.width=l,c.height=d;let m=u(c);if(m!=null)m.putImageData(t,0,0),s=m.getImageData(0,0,l,d).data;else throw new Error("Can not access image data")}else s=t.data}else if(r){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let d=a();d.width=t.width,d.height=t.height;let l=u(d);if(l!=null){let c=t.height,m=t.width;return l.drawImage(t,0,0,m,c),s=l.getImageData(0,0,m,c).data,f.height=c,f.width=m,Ye(s,f)}else throw new Error("Can not access image data")}else{if(i)return new Promise((d,l)=>{let c=a(),m=u(c);if(!t||!m)return l();let p=new Image;p.crossOrigin="Anonymous",p.src=t,p.onload=()=>{c.width=p.width,c.height=p.height,m.drawImage(p,0,0,c.width,c.height);let h=m.getImageData(0,0,c.width,c.height);f.height=c.height,f.width=c.width,d(Ye(h.data,f))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Ye(s,f);throw new Error("Input data provided is not supported - aborted tensor creation")},bt=(t,e)=>{let{width:n,height:o,download:r,dispose:i}=e,s=[1,o,n,4];return new P({location:"texture",type:"float32",texture:t,dims:s,download:r,dispose:i})},gt=(t,e)=>{let{dataType:n,dims:o,download:r,dispose:i}=e;return new P({location:"gpu-buffer",type:n??"float32",gpuBuffer:t,dims:o,download:r,dispose:i})},Et=(t,e)=>{let{dataType:n,dims:o,download:r,dispose:i}=e;return new P({location:"ml-tensor",type:n??"float32",mlTensor:t,dims:o,download:r,dispose:i})},Tt=(t,e,n)=>new P({location:"cpu-pinned",type:t,data:e,dims:n??[e.length]})});var G,se,At,Ot,vt=w(()=>{"use strict";G=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),se=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),At=!1,Ot=()=>{if(!At){At=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;t&&(G.set("int64",BigInt64Array),se.set(BigInt64Array,"int64")),e&&(G.set("uint64",BigUint64Array),se.set(BigUint64Array,"uint64")),n?(G.set("float16",Float16Array),se.set(Float16Array,"float16")):G.set("float16",Uint16Array)}}});var xt,Pt,It=w(()=>{"use strict";Te();xt=t=>{let e=1;for(let n=0;n<t.length;n++){let o=t[n];if(typeof o!="number"||!Number.isSafeInteger(o))throw new TypeError(`dims[${n}] must be an integer, got: ${o}`);if(o<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${o}`);e*=o}return e},Pt=(t,e)=>{switch(t.location){case"cpu":return new P(t.type,t.data,e);case"cpu-pinned":return new P({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new P({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new P({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});case"ml-tensor":return new P({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}});var P,Te=w(()=>{"use strict";yt();St();vt();It();P=class{constructor(e,n,o){Ot();let r,i;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case"cpu-pinned":{let f=G.get(r);if(!f)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof f))throw new TypeError(`buffer should be of type ${f.name}`);this.cpuData=e.data;break}case"texture":{if(r!=="float32")throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break}case"gpu-buffer":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}case"ml-tensor":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint64"&&r!=="int8"&&r!=="uint8"&&r!=="bool")throw new TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let f,a;if(typeof e=="string")if(r=e,a=o,e==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");f=n}else{let u=G.get(e);if(u===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(n)){if(e==="float16"&&u===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${u.name} as data.`);e==="uint64"||e==="int64"?f=u.from(n,BigInt):f=u.from(n)}else if(n instanceof u)f=n;else if(n instanceof Uint8ClampedArray)if(e==="uint8")f=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${r} tensor's data must be type of ${u}`)}else if(a=n,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let u=typeof e[0];if(u==="string")r="string",f=e;else if(u==="boolean")r="bool",f=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${u}.`)}else if(e instanceof Uint8ClampedArray)r="uint8",f=Uint8Array.from(e);else{let u=se.get(e.constructor);if(u===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=u,f=e}if(a===void 0)a=[f.length];else if(!Array.isArray(a))throw new TypeError("A tensor's dims must be a number array");i=a,this.cpuData=f,this.dataLocation="cpu"}let s=xt(i);if(this.cpuData&&s!==this.cpuData.length&&!((r==="uint4"||r==="int4")&&Math.ceil(s/2)===this.cpuData.length))throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=s}static async fromImage(e,n){return wt(e,n)}static fromTexture(e,n){return bt(e,n)}static fromGpuBuffer(e,n){return gt(e,n)}static fromMLTensor(e,n){return Et(e,n)}static fromPinnedBuffer(e,n,o){return Tt(e,n,o)}toDataURL(e){return mt(this,e)}toImageData(e){return ht(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,e&&this.disposer&&(this.disposer(),this.disposer=void 0),n}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Pt(this,e)}}});var I,Se=w(()=>{"use strict";Te();I=P});var Lt,Bt,H,j,qe=w(()=>{"use strict";Ve();Lt=(t,e)=>{(typeof U.trace>"u"?!U.wasm.trace:!U.trace)||console.timeStamp(`${t}::ORT::${e}`)},Bt=(t,e)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],o=!1;for(let r=0;r<n.length;r++){if(o&&!n[r].includes("TRACE_FUNC")){let i=`FUNC_${t}::${n[r].trim().split(" ")[1]}`;e&&(i+=`::${e}`),Lt("CPU",i);return}n[r].includes("TRACE_FUNC")&&(o=!0)}},H=t=>{(typeof U.trace>"u"?!U.wasm.trace:!U.trace)||Bt("BEGIN",t)},j=t=>{(typeof U.trace>"u"?!U.wasm.trace:!U.trace)||Bt("END",t)}});var Ae,Ct=w(()=>{"use strict";Ee();Se();qe();Ae=class t{constructor(e){this.handler=e}async run(e,n,o){H();let r={},i={};if(typeof e!="object"||e===null||e instanceof I||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof I)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(n.length===0)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let u of n){if(typeof u!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(u)===-1)throw new RangeError(`'fetches' contains invalid output name: ${u}.`);r[u]=null}if(typeof o=="object"&&o!==null)i=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else{let u=!1,d=Object.getOwnPropertyNames(n);for(let l of this.outputNames)if(d.indexOf(l)!==-1){let c=n[l];(c===null||c instanceof I)&&(u=!0,s=!1,r[l]=c)}if(u){if(typeof o=="object"&&o!==null)i=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else i=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let u of this.inputNames)if(typeof e[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(s)for(let u of this.outputNames)r[u]=null;let f=await this.handler.run(e,r,i),a={};for(let u in f)if(Object.hasOwnProperty.call(f,u)){let d=f[u];d instanceof I?a[u]=d:a[u]=new I(d.type,d.data,d.dims)}return j(),a}async release(){return this.handler.dispose()}static async create(e,n,o,r){H();let i,s={};if(typeof e=="string"){if(i=e,typeof n=="object"&&n!==null)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(i=e,typeof n=="object"&&n!==null)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let d=e,l=0,c=e.byteLength;if(typeof n=="object"&&n!==null)s=n;else if(typeof n=="number"){if(l=n,!Number.isSafeInteger(l))throw new RangeError("'byteOffset' must be an integer.");if(l<0||l>=d.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${d.byteLength}).`);if(c=e.byteLength-l,typeof o=="number"){if(c=o,!Number.isSafeInteger(c))throw new RangeError("'byteLength' must be an integer.");if(c<=0||l+c>d.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${d.byteLength-l}].`);if(typeof r=="object"&&r!==null)s=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(typeof o<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");i=new Uint8Array(d,l,c)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[f,a]=await ge(s),u=await f.createInferenceSessionHandler(i,a);return j(),new t(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var Pr,Mt=w(()=>{"use strict";Ct();Pr=Ae});var Ut=w(()=>{"use strict"});var Dt=w(()=>{"use strict"});var Rt=w(()=>{"use strict"});var _t=w(()=>{"use strict"});var Ir,Oe,kt=w(()=>{"use strict";Ee();Se();Ir="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Oe=class t{constructor(e,n,o){this.handler=e,this.hasOptimizerModel=n,this.hasEvalModel=o}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(e,n){let o=e.evalModel||"",r=e.optimizerModel||"",i=n||{},[s,f]=await ge(i);if(s.createTrainingSessionHandler){let a=await s.createTrainingSessionHandler(e.checkpointState,e.trainModel,o,r,f);return new t(a,!!e.optimizerModel,!!e.evalModel)}else throw new Error(Ir)}typeNarrowingForRunStep(e,n,o,r,i){let s={},f={};if(typeof o!="object"||o===null||o instanceof I||Array.isArray(o))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof I)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let u of r){if(typeof u!="string")throw new TypeError("'fetches' must be a string array or an object.");if(n.indexOf(u)===-1)throw new RangeError(`'fetches' contains invalid output name: ${u}.`);s[u]=null}if(typeof i=="object"&&i!==null)f=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let u=!1,d=Object.getOwnPropertyNames(r);for(let l of n)if(d.indexOf(l)!==-1){let c=r[l];(c===null||c instanceof I)&&(u=!0,a=!1,s[l]=c)}if(u){if(typeof i=="object"&&i!==null)f=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else f=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let u of e)if(typeof o[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(a)for(let u of n)s[u]=null;return[s,f]}convertHandlerReturnTypeToMapOfTensors(e){let n={};for(let o in e)if(Object.hasOwnProperty.call(e,o)){let r=e[o];r instanceof I?n[o]=r:n[o]=new I(r.type,r.data,r.dims)}return n}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,n,o){let[r,i]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,n,o),s=await this.handler.runTrainStep(e,r,i);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(e){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(e||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(e,n,o){if(this.hasEvalModel){let[r,i]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,n,o),s=await this.handler.runEvalStep(e,r,i);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(e=!0){return this.handler.getParametersSize(e)}async loadParametersBuffer(e,n=!0){let o=await this.getParametersSize(n);if(e.length!==4*o)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(e,n)}async getContiguousParameters(e=!0){return this.handler.getContiguousParameters(e)}async release(){return this.handler.dispose()}}});var Lr,Ft=w(()=>{"use strict";kt();Lr=Oe});var Je={};je(Je,{InferenceSession:()=>Pr,TRACE:()=>Lt,TRACE_FUNC_BEGIN:()=>H,TRACE_FUNC_END:()=>j,Tensor:()=>I,TrainingSession:()=>Lr,env:()=>T,registerBackend:()=>oe});var V=w(()=>{"use strict";ft();pt();Mt();Se();Ut();Dt();qe();Rt();_t();Ft()});var ve=w(()=>{"use strict"});var zt={};je(zt,{default:()=>Br});var Wt,$t,Br,Gt=w(()=>{"use strict";Xe();Y();ie();Wt="ort-wasm-proxy-worker",$t=globalThis.self?.name===Wt;$t&&(self.onmessage=t=>{let{type:e,in:n}=t.data;try{switch(e){case"init-wasm":xe(n.wasm).then(()=>{Pe(n).then(()=>{postMessage({type:e})},o=>{postMessage({type:e,err:o})})},o=>{postMessage({type:e,err:o})});break;case"init-ep":{let{epName:o,env:r}=n;Ie(r,o).then(()=>{postMessage({type:e})},i=>{postMessage({type:e,err:i})});break}case"copy-from":{let{buffer:o}=n,r=ae(o);postMessage({type:e,out:r});break}case"create":{let{model:o,options:r}=n;Le(o,r).then(i=>{postMessage({type:e,out:i})},i=>{postMessage({type:e,err:i})});break}case"release":Be(n),postMessage({type:e});break;case"run":{let{sessionId:o,inputIndices:r,inputs:i,outputIndices:s,options:f}=n;Ce(o,r,i,s,new Array(s.length).fill(null),f).then(a=>{a.some(u=>u[3]!=="cpu")?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:a},Ue([...i,...a]))},a=>{postMessage({type:e,err:a})});break}case"end-profiling":Me(n),postMessage({type:e});break;default:}}catch(o){postMessage({type:e,err:o})}});Br=$t?null:t=>new Worker(t??R,{type:"module",name:Wt})});var R,Cr,jt,Mr,Ur,Vt,Dr,Ht,Yt,qt,ie=w(()=>{"use strict";ve();R=!1?void 0:import.meta.url??(typeof document<"u"?document.currentScript?.src:typeof self<"u"?self.location?.href:void 0),Cr=!1||typeof location>"u"?void 0:location.origin,jt=(t,e)=>{try{let n=e??R;return(n?new URL(t,n):new URL(t)).origin===Cr}catch{return!1}},Mr=(t,e)=>{let n=e??R;try{return(n?new URL(t,n):new URL(t)).href}catch{return}},Ur=(t,e)=>`${e??"./"}${t}`,Vt=async t=>{let n=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(n)},Dr=async t=>(await import(/*webpackIgnore:true*/t)).default,Ht=(Gt(),ut(zt)).default,Yt=async()=>{if(!R)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(jt(R))return[void 0,Ht()];let t=await Vt(R);return[t,Ht(t)]},qt=async(t,e,n)=>{{let o="ort-wasm-simd-threaded.mjs",r=t??Mr(o,e),i=!!1&&n&&r&&!jt(r,e),s=i?await Vt(r):r??Ur(o,e);return[i?s:void 0,await Dr(s)]}}});var Ke,Qe,De,Jt,Rr,_r,xe,v,Y=w(()=>{"use strict";ie();Qe=!1,De=!1,Jt=!1,Rr=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},_r=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},xe=async t=>{if(Qe)return Promise.resolve();if(De)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Jt)throw new Error("previous call to 'initializeWebAssembly()' failed.");De=!0;let e=t.initTimeout,n=t.numThreads;if(!_r())throw new Error("WebAssembly SIMD is not supported in the current environment.");let o=Rr();n>1&&!o&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+n+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),t.numThreads=n=1);let r=t.wasmPaths,i=typeof r=="string"?r:void 0,s=r?.mjs,f=s?.href??s,a=r?.wasm,u=a?.href??a,d=t.wasmBinary,[l,c]=await qt(f,i,n>1),m=!1,p=[];if(e>0&&p.push(new Promise(h=>{setTimeout(()=>{m=!0,h()},e)})),p.push(new Promise((h,E)=>{let O={numThreads:n};d?O.wasmBinary=d:(u||i)&&(O.locateFile=(y,b)=>u??(i??b)+y),c(O).then(y=>{De=!1,Qe=!0,Ke=y,h(),l&&URL.revokeObjectURL(l)},y=>{De=!1,Jt=!0,E(y)})})),await Promise.race(p),m)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},v=()=>{if(Qe&&Ke)return Ke;throw new Error("WebAssembly is not initialized yet.")}});var x,ue,S,Re=w(()=>{"use strict";Y();x=(t,e)=>{let n=v(),o=n.lengthBytesUTF8(t)+1,r=n._malloc(o);return n.stringToUTF8(t,r,o),e.push(r),r},ue=(t,e,n,o)=>{if(typeof t=="object"&&t!==null){if(n.has(t))throw new Error("Circular reference in options");n.add(t)}Object.entries(t).forEach(([r,i])=>{let s=e?e+r:r;if(typeof i=="object")ue(i,s+".",n,o);else if(typeof i=="string"||typeof i=="number")o(s,i.toString());else if(typeof i=="boolean")o(s,i?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof i}`)})},S=t=>{let e=v(),n=e.stackSave();try{let o=e.stackAlloc(8);e._OrtGetLastError(o,o+4);let r=e.HEAP32[o/4],i=e.HEAPU32[o/4+1],s=i?e.UTF8ToString(i):"";throw new Error(`${t} ERROR_CODE: ${r}, ERROR_MESSAGE: ${s}`)}finally{e.stackRestore(n)}}});var Xt,Kt=w(()=>{"use strict";Y();Re();Xt=t=>{let e=v(),n=0,o=[],r=t||{};try{if(t?.logSeverityLevel===void 0)r.logSeverityLevel=2;else if(typeof t.logSeverityLevel!="number"||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(t?.logVerbosityLevel===void 0)r.logVerbosityLevel=0;else if(typeof t.logVerbosityLevel!="number"||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);t?.terminate===void 0&&(r.terminate=!1);let i=0;return t?.tag!==void 0&&(i=x(t.tag,o)),n=e._OrtCreateRunOptions(r.logSeverityLevel,r.logVerbosityLevel,!!r.terminate,i),n===0&&S("Can't create run options."),t?.extra!==void 0&&ue(t.extra,"",new WeakSet,(s,f)=>{let a=x(s,o),u=x(f,o);e._OrtAddRunConfigEntry(n,a,u)!==0&&S(`Can't set a run config entry: ${s} - ${f}.`)}),[n,o]}catch(i){throw n!==0&&e._OrtReleaseRunOptions(n),o.forEach(s=>e._free(s)),i}}});var kr,Fr,Nr,Wr,Qt,Zt=w(()=>{"use strict";Y();Re();kr=t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}},Fr=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},Nr=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some(n=>(typeof n=="string"?n:n.name)==="webgpu")&&(t.enableMemPattern=!1)},Wr=(t,e,n)=>{for(let o of e){let r=typeof o=="string"?o:o.name;switch(r){case"webnn":if(r="WEBNN",typeof o!="string"){let f=o?.deviceType;if(f){let a=x("deviceType",n),u=x(f,n);v()._OrtAddSessionConfigEntry(t,a,u)!==0&&S(`Can't set a session config entry: 'deviceType' - ${f}.`)}}break;case"webgpu":if(r="JS",typeof o!="string"){let s=o;if(s?.preferredLayout){if(s.preferredLayout!=="NCHW"&&s.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${s.preferredLayout}`);let f=x("preferredLayout",n),a=x(s.preferredLayout,n);v()._OrtAddSessionConfigEntry(t,f,a)!==0&&S(`Can't set a session config entry: 'preferredLayout' - ${s.preferredLayout}.`)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${r}`)}let i=x(r,n);v()._OrtAppendExecutionProvider(t,i)!==0&&S(`Can't append execution provider: ${r}.`)}},Qt=t=>{let e=v(),n=0,o=[],r=t||{};Nr(r);try{let i=kr(r.graphOptimizationLevel??"all"),s=Fr(r.executionMode??"sequential"),f=typeof r.logId=="string"?x(r.logId,o):0,a=r.logSeverityLevel??2;if(!Number.isInteger(a)||a<0||a>4)throw new Error(`log serverity level is not valid: ${a}`);let u=r.logVerbosityLevel??0;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log verbosity level is not valid: ${u}`);let d=typeof r.optimizedModelFilePath=="string"?x(r.optimizedModelFilePath,o):0;if(n=e._OrtCreateSessionOptions(i,!!r.enableCpuMemArena,!!r.enableMemPattern,s,!!r.enableProfiling,0,f,a,u,d),n===0&&S("Can't create session options."),r.executionProviders&&Wr(n,r.executionProviders,o),r.enableGraphCapture!==void 0){if(typeof r.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${r.enableGraphCapture}`);let l=x("enableGraphCapture",o),c=x(r.enableGraphCapture.toString(),o);e._OrtAddSessionConfigEntry(n,l,c)!==0&&S(`Can't set a session config entry: 'enableGraphCapture' - ${r.enableGraphCapture}.`)}if(r.freeDimensionOverrides)for(let[l,c]of Object.entries(r.freeDimensionOverrides)){if(typeof l!="string")throw new Error(`free dimension override name must be a string: ${l}`);if(typeof c!="number"||!Number.isInteger(c)||c<0)throw new Error(`free dimension override value must be a non-negative integer: ${c}`);let m=x(l,o);e._OrtAddFreeDimensionOverride(n,m,c)!==0&&S(`Can't set a free dimension override: ${l} - ${c}.`)}return r.extra!==void 0&&ue(r.extra,"",new WeakSet,(l,c)=>{let m=x(l,o),p=x(c,o);e._OrtAddSessionConfigEntry(n,m,p)!==0&&S(`Can't set a session config entry: ${l} - ${c}.`)}),[n,o]}catch(i){throw n!==0&&e._OrtReleaseSessionOptions(n),o.forEach(s=>e._free(s)),i}}});var fe,er,ce,tr,rr,_e,ke,nr,Ze=w(()=>{"use strict";fe=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${t}`)}},er=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${t}`)}},ce=(t,e)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][t],o=typeof e=="number"?e:e.reduce((r,i)=>r*i,1);return n>0?Math.ceil(o*n):void 0},tr=t=>{switch(t){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}},rr=t=>{switch(t){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${t}`)}},_e=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",ke=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool",nr=t=>{switch(t){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${t}`)}}});var le,et=w(()=>{"use strict";ve();le=async t=>{if(typeof t=="string")if(!1)try{let{readFile:e}=He("node:fs/promises");return new Uint8Array(await e(t))}catch(e){if(e.code==="ERR_FS_FILE_TOO_LARGE"){let{createReadStream:n}=He("node:fs"),o=n(t),r=[];for await(let i of o)r.push(i);return new Uint8Array(Buffer.concat(r))}throw e}else{let e=await fetch(t);if(!e.ok)throw new Error(`failed to load external data file: ${t}`);let n=e.headers.get("Content-Length"),o=n?parseInt(n,10):0;if(o<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let r=e.body.getReader(),i;try{i=new ArrayBuffer(o)}catch(f){if(f instanceof RangeError){let a=Math.ceil(o/65536);i=new WebAssembly.Memory({initial:a,maximum:a}).buffer}else throw f}let s=0;for(;;){let{done:f,value:a}=await r.read();if(f)break;let u=a.byteLength;new Uint8Array(i,s,u).set(a),s+=u}return new Uint8Array(i,0,o)}}else return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}});var $r,Pe,Ie,Q,zr,ae,Le,Be,or,Ce,Me,Ue,Xe=w(()=>{"use strict";Kt();Zt();Ze();Y();Re();et();$r=(t,e)=>{v()._OrtInit(t,e)!==0&&S("Can't initialize onnxruntime.")},Pe=async t=>{$r(t.wasm.numThreads,rr(t.logLevel))},Ie=async(t,e)=>{},Q=new Map,zr=t=>{let e=v(),n=e.stackSave();try{let o=e.stackAlloc(8);return e._OrtGetInputOutputCount(t,o,o+4)!==0&&S("Can't get session input/output count."),[e.HEAP32[o/4],e.HEAP32[o/4+1]]}finally{e.stackRestore(n)}},ae=t=>{let e=v(),n=e._malloc(t.byteLength);if(n===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,n),[n,t.byteLength]},Le=async(t,e)=>{let n,o,r=v();Array.isArray(t)?[n,o]=t:t.buffer===r.HEAPU8.buffer?[n,o]=[t.byteOffset,t.byteLength]:[n,o]=ae(t);let i=0,s=0,f=0,a=[],u=[],d=[];try{if([s,a]=Qt(e),e?.externalData&&r.mountExternalData){let y=[];for(let b of e.externalData){let A=typeof b=="string"?b:b.path;y.push(le(typeof b=="string"?b:b.data).then(M=>{r.mountExternalData(A,M)}))}await Promise.all(y)}for(let y of e?.executionProviders??[])if((typeof y=="string"?y:y.name)==="webnn"){if(r.shouldTransferToMLTensor=!1,r.currentContext)throw new Error("WebNN execution provider is already set.");if(typeof y!="string"){let A=y,M=A?.context,te=A?.gpuDevice,pe=A?.deviceType,re=A?.numThreads,me=A?.powerPreference;M?r.currentContext=M:te?r.currentContext=await navigator.ml.createContext(te):r.currentContext=await navigator.ml.createContext({deviceType:pe,numThreads:re,powerPreference:me})}else r.currentContext=await navigator.ml.createContext();break}i=await r._OrtCreateSession(n,o,s),i===0&&S("Can't create a session."),r.currentContext&&(r.jsepRegisterMLContext(i,r.currentContext),r.currentContext=void 0,r.shouldTransferToMLTensor=!0);let[l,c]=zr(i),m=!!e?.enableGraphCapture,p=[],h=[],E=[];for(let y=0;y<l;y++){let b=r._OrtGetInputName(i,y);b===0&&S("Can't get an input name."),u.push(b),p.push(r.UTF8ToString(b))}for(let y=0;y<c;y++){let b=r._OrtGetOutputName(i,y);b===0&&S("Can't get an output name."),d.push(b);let A=r.UTF8ToString(b);h.push(A)}let O=null;return Q.set(i,[i,u,d,O,m,!1]),[i,p,h]}catch(l){throw u.forEach(c=>r._OrtFree(c)),d.forEach(c=>r._OrtFree(c)),f!==0&&r._OrtReleaseBinding(f),i!==0&&r._OrtReleaseSession(i),l}finally{r._free(n),s!==0&&r._OrtReleaseSessionOptions(s),a.forEach(l=>r._free(l)),r.unmountExternalData?.()}},Be=t=>{let e=v(),n=Q.get(t);if(!n)throw new Error(`cannot release session. invalid session id: ${t}`);let[o,r,i,s,f]=n;s&&(f&&e._OrtClearBoundOutputs(s.handle),e._OrtReleaseBinding(s.handle)),e.jsepOnReleaseSession?.(t),r.forEach(a=>e._OrtFree(a)),i.forEach(a=>e._OrtFree(a)),e._OrtReleaseSession(o),Q.delete(t)},or=(t,e,n,o,r,i=!1)=>{if(!t){e.push(0);return}let s=v(),f=t[0],a=t[1],u=t[3],d,l;if(f==="string"&&(u==="gpu-buffer"||u==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(i&&u!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${r} when enableGraphCapture is true.`);if(u==="gpu-buffer"){let p=t[2].gpuBuffer;l=ce(fe(f),a);let h=s.jsepRegisterBuffer;if(!h)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');d=h(o,r,p,l)}else if(u==="ml-tensor"){let p=t[2].mlTensor;l=ce(fe(f),a);let h=s.jsepRegisterMLTensor;if(!h)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');d=h(p,fe(f),a)}else{let p=t[2];if(Array.isArray(p)){l=4*p.length,d=s._malloc(l),n.push(d);let h=d/4;for(let E=0;E<p.length;E++){if(typeof p[E]!="string")throw new TypeError(`tensor data at index ${E} is not a string`);s.HEAPU32[h++]=x(p[E],n)}}else l=p.byteLength,d=s._malloc(l),n.push(d),s.HEAPU8.set(new Uint8Array(p.buffer,p.byteOffset,l),d)}let c=s.stackSave(),m=s.stackAlloc(4*a.length);try{let p=m/4;a.forEach(E=>s.HEAP32[p++]=E);let h=s._OrtCreateTensor(fe(f),d,l,m,a.length,nr(u));h===0&&S(`Can't create tensor for input/output. session=${o}, index=${r}.`),e.push(h)}finally{s.stackRestore(c)}},Ce=async(t,e,n,o,r,i)=>{let s=v(),f=Q.get(t);if(!f)throw new Error(`cannot run inference. invalid session id: ${t}`);let a=f[0],u=f[1],d=f[2],l=f[3],c=f[4],m=f[5],p=e.length,h=o.length,E=0,O=[],y=[],b=[],A=[],M=s.stackSave(),te=s.stackAlloc(p*4),pe=s.stackAlloc(p*4),re=s.stackAlloc(h*4),me=s.stackAlloc(h*4);try{s.jsepOnRunStart?.(a),[E,O]=Xt(i);for(let g=0;g<p;g++)or(n[g],y,A,t,e[g],c);for(let g=0;g<h;g++)or(r[g],b,A,t,p+o[g],c);let k=te/4,wr=pe/4,br=re/4,gr=me/4;for(let g=0;g<p;g++)s.HEAPU32[k++]=y[g],s.HEAPU32[wr++]=u[e[g]];for(let g=0;g<h;g++)s.HEAPU32[br++]=b[g],s.HEAPU32[gr++]=d[o[g]];let ot;ot=await s._OrtRun(a,pe,te,p,me,h,re,E),ot!==0&&S("failed to call OrtRun().");let X=[];for(let g=0;g<h;g++){let K=s.HEAPU32[re/4+g];if(K===b[g]){X.push(r[g]);continue}let st=s.stackSave(),N=s.stackAlloc(4*4),ne=!1,L,D=0;try{s._OrtGetTensorData(K,N,N+4,N+8,N+12)!==0&&S(`Can't access output tensor data on index ${g}.`);let he=N/4,ye=s.HEAPU32[he++];D=s.HEAPU32[he++];let it=s.HEAPU32[he++],Er=s.HEAPU32[he++],W=[];for(let B=0;B<Er;B++)W.push(s.HEAPU32[it/4+B]);s._OrtFree(it);let $=W.reduce((B,C)=>B*C,1);L=er(ye);let we=l?.outputPreferredLocations[o[g]];if(L==="string"){if(we==="gpu-buffer"||we==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let B=[],C=D/4;for(let F=0;F<$;F++){let at=s.HEAPU32[C++],Tr=F===$-1?void 0:s.HEAPU32[C]-at;B.push(s.UTF8ToString(at,Tr))}X.push([L,W,B,"cpu"])}else if(we==="gpu-buffer"&&$>0){let B=s.jsepGetBuffer;if(!B)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let C=B(D),F=ce(ye,$);if(F===void 0||!_e(L))throw new Error(`Unsupported data type: ${L}`);ne=!0,X.push([L,W,{gpuBuffer:C,download:s.jsepCreateDownloader(C,F,L),dispose:()=>{s._OrtReleaseTensor(K)}},"gpu-buffer"])}else if(we==="ml-tensor"&&$>0){let B=s.jsepEnsureTensor;if(!B)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ce(ye,$)===void 0||!ke(L))throw new Error(`Unsupported data type: ${L}`);let F=await B(D,ye,W,!1);ne=!0,X.push([L,W,{mlTensor:F,download:s.jsepCreateMLTensorDownloader(D,L),dispose:()=>{s.jsepReleaseTensorId(D),s._OrtReleaseTensor(K)}},"ml-tensor"])}else{let B=tr(L),C=new B($);new Uint8Array(C.buffer,C.byteOffset,C.byteLength).set(s.HEAPU8.subarray(D,D+C.byteLength)),X.push([L,W,C,"cpu"])}}finally{s.stackRestore(st),L==="string"&&D&&s._free(D),ne||s._OrtReleaseTensor(K)}}return l&&!c&&(s._OrtClearBoundOutputs(l.handle),Q.set(t,[a,u,d,l,c,!1])),X}finally{s.stackRestore(M),y.forEach(k=>s._OrtReleaseTensor(k)),b.forEach(k=>s._OrtReleaseTensor(k)),A.forEach(k=>s._free(k)),E!==0&&s._OrtReleaseRunOptions(E),O.forEach(k=>s._free(k))}},Me=t=>{let e=v(),n=Q.get(t);if(!n)throw new Error("invalid session id");let o=n[0],r=e._OrtEndProfiling(o);r===0&&S("Can't get an profile file name."),e._OrtFree(r)},Ue=t=>{let e=[];for(let n of t){let o=n[2];!Array.isArray(o)&&"buffer"in o&&e.push(o.buffer)}return e}});var J,_,de,Ne,We,Fe,tt,rt,Z,ee,Hr,sr,ir,ar,ur,fr,cr,lr,nt=w(()=>{"use strict";V();Xe();Y();ie();J=()=>!!T.wasm.proxy&&typeof document<"u",de=!1,Ne=!1,We=!1,rt=new Map,Z=(t,e)=>{let n=rt.get(t);n?n.push(e):rt.set(t,[e])},ee=()=>{if(de||!Ne||We||!_)throw new Error("worker not ready")},Hr=t=>{switch(t.data.type){case"init-wasm":de=!1,t.data.err?(We=!0,tt[1](t.data.err)):(Ne=!0,tt[0]()),Fe&&(URL.revokeObjectURL(Fe),Fe=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=rt.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}default:}},sr=async()=>{if(!Ne){if(de)throw new Error("multiple calls to 'initWasm()' detected.");if(We)throw new Error("previous call to 'initWasm()' failed.");if(de=!0,J())return new Promise((t,e)=>{_?.terminate(),Yt().then(([n,o])=>{try{_=o,_.onerror=i=>e(i),_.onmessage=Hr,tt=[t,e];let r={type:"init-wasm",in:T};_.postMessage(r),Fe=n}catch(r){e(r)}},e)});try{await xe(T.wasm),await Pe(T),Ne=!0}catch(t){throw We=!0,t}finally{de=!1}}},ir=async t=>{if(J())return ee(),new Promise((e,n)=>{Z("init-ep",[e,n]);let o={type:"init-ep",in:{epName:t,env:T}};_.postMessage(o)});await Ie(T,t)},ar=async t=>J()?(ee(),new Promise((e,n)=>{Z("copy-from",[e,n]);let o={type:"copy-from",in:{buffer:t}};_.postMessage(o,[t.buffer])})):ae(t),ur=async(t,e)=>{if(J()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return ee(),new Promise((n,o)=>{Z("create",[n,o]);let r={type:"create",in:{model:t,options:{...e}}},i=[];t instanceof Uint8Array&&i.push(t.buffer),_.postMessage(r,i)})}else return Le(t,e)},fr=async t=>{if(J())return ee(),new Promise((e,n)=>{Z("release",[e,n]);let o={type:"release",in:t};_.postMessage(o)});Be(t)},cr=async(t,e,n,o,r,i)=>{if(J()){if(n.some(s=>s[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(r.some(s=>s))throw new Error("pre-allocated output tensor is not supported for proxy.");return ee(),new Promise((s,f)=>{Z("run",[s,f]);let a=n,u={type:"run",in:{sessionId:t,inputIndices:e,inputs:a,outputIndices:o,options:i}};_.postMessage(u,Ue(a))})}else return Ce(t,e,n,o,r,i)},lr=async t=>{if(J())return ee(),new Promise((e,n)=>{Z("end-profiling",[e,n]);let o={type:"end-profiling",in:t};_.postMessage(o)});Me(t)}});var dr,jr,$e,pr=w(()=>{"use strict";V();nt();Ze();ve();et();dr=(t,e)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[t.type,t.dims,{mlTensor:t.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${t.location} for ${e()}`)}},jr=t=>{switch(t[3]){case"cpu":return new I(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!_e(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:n,download:o,dispose:r}=t[2];return I.fromGpuBuffer(n,{dataType:e,dims:t[1],download:o,dispose:r})}case"ml-tensor":{let e=t[0];if(!ke(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:n,download:o,dispose:r}=t[2];return I.fromMLTensor(n,{dataType:e,dims:t[1],download:o,dispose:r})}default:throw new Error(`invalid data location: ${t[3]}`)}},$e=class{async fetchModelAndCopyToWasmMemory(e){return ar(await le(e))}async loadModel(e,n){H();let o;typeof e=="string"?!1?o=await le(e):o=await this.fetchModelAndCopyToWasmMemory(e):o=e,[this.sessionId,this.inputNames,this.outputNames]=await ur(o,n),j()}async dispose(){return fr(this.sessionId)}async run(e,n,o){H();let r=[],i=[];Object.entries(e).forEach(c=>{let m=c[0],p=c[1],h=this.inputNames.indexOf(m);if(h===-1)throw new Error(`invalid input '${m}'`);r.push(p),i.push(h)});let s=[],f=[];Object.entries(n).forEach(c=>{let m=c[0],p=c[1],h=this.outputNames.indexOf(m);if(h===-1)throw new Error(`invalid output '${m}'`);s.push(p),f.push(h)});let a=r.map((c,m)=>dr(c,()=>`input "${this.inputNames[i[m]]}"`)),u=s.map((c,m)=>c?dr(c,()=>`output "${this.outputNames[f[m]]}"`):null),d=await cr(this.sessionId,i,a,f,u,o),l={};for(let c=0;c<d.length;c++)l[this.outputNames[f[c]]]=s[c]??jr(d[c]);return j(),l}startProfiling(){}endProfiling(){lr(this.sessionId)}}});var hr={};je(hr,{OnnxruntimeWebAssemblyBackend:()=>ze,initializeFlags:()=>mr,wasmBackend:()=>Vr});var mr,ze,Vr,yr=w(()=>{"use strict";V();nt();pr();ie();mr=()=>{if((typeof T.wasm.initTimeout!="number"||T.wasm.initTimeout<0)&&(T.wasm.initTimeout=0),T.wasm.simd===!1&&console.warn('Deprecated property "env.wasm.simd" is set to false. non-SIMD build is no longer provided, and this setting will be ignored.'),typeof T.wasm.proxy!="boolean"&&(T.wasm.proxy=!1),typeof T.wasm.trace!="boolean"&&(T.wasm.trace=!1),typeof T.wasm.numThreads!="number"||!Number.isInteger(T.wasm.numThreads)||T.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)T.wasm.numThreads=1;else{let t=typeof navigator>"u"?He("node:os").cpus().length:navigator.hardwareConcurrency;T.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}T.wasm.wasmPaths===void 0&&R&&R.indexOf("blob:")!==0&&(T.wasm.wasmPaths=R.substring(0,R.lastIndexOf("/")+1))},ze=class{async init(e){mr(),await sr(),await ir(e)}async createInferenceSessionHandler(e,n){let o=new $e;return await o.loadModel(e,n),Promise.resolve(o)}},Vr=new ze});V();V();V();var Nt="1.20.1";var Do=Je;{let t=(yr(),ut(hr)).wasmBackend;oe("cpu",t,10),oe("wasm",t,10)}Object.defineProperty(T.versions,"web",{value:Nt,enumerable:!0});export{Pr as InferenceSession,Lt as TRACE,H as TRACE_FUNC_BEGIN,j as TRACE_FUNC_END,I as Tensor,Lr as TrainingSession,Do as default,T as env,oe as registerBackend};
|
| 7 |
+
//# sourceMappingURL=ort.wasm.min.mjs.map
|
web/serve.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Local test server for this folder: python serve.py [port] -> http://127.0.0.1:8000/
|
| 2 |
+
Sets the right MIME types and the two headers that let the browser use several CPU cores (like .htaccess)."""
|
| 3 |
+
import http.server
|
| 4 |
+
import sys
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Handler(http.server.SimpleHTTPRequestHandler):
|
| 9 |
+
extensions_map = {**http.server.SimpleHTTPRequestHandler.extensions_map, ".js": "text/javascript",
|
| 10 |
+
".mjs": "text/javascript", ".wasm": "application/wasm", ".json": "application/json",
|
| 11 |
+
".onnx": "application/octet-stream"}
|
| 12 |
+
|
| 13 |
+
def __init__(self, *args, **kwargs):
|
| 14 |
+
super().__init__(*args, directory=str(Path(__file__).resolve().parent), **kwargs)
|
| 15 |
+
|
| 16 |
+
def end_headers(self):
|
| 17 |
+
self.send_header("Cross-Origin-Opener-Policy", "same-origin")
|
| 18 |
+
self.send_header("Cross-Origin-Embedder-Policy", "require-corp")
|
| 19 |
+
self.send_header("Cross-Origin-Resource-Policy", "same-origin")
|
| 20 |
+
super().end_headers()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
|
| 25 |
+
print(f"http://127.0.0.1:{port}/")
|
| 26 |
+
http.server.ThreadingHTTPServer(("127.0.0.1", port), Handler).serve_forever()
|