Upload 561 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +131 -0
- .models/.gitattributes +1 -0
- .models/autoregressive.pth +3 -0
- .models/classifier.pth +3 -0
- .models/clvp2.pth +3 -0
- .models/cvvp.pth +3 -0
- .models/diffusion_decoder.pth +3 -0
- .models/rlg_auto.pth +3 -0
- .models/rlg_diffuser.pth +3 -0
- .models/vocoder.pth +3 -0
- CITATION.cff +10 -0
- LICENSE +201 -0
- README.md +260 -0
- api.py +373 -0
- data/mel_norms.pth +3 -0
- data/riding_hood.txt +54 -0
- data/tokenizer.json +1 -0
- do_tts.py +34 -0
- eval_multiple.py +38 -0
- examples/.gitattributes +5 -0
- examples/favorites/atkins_mha.mp3 +0 -0
- examples/favorites/atkins_omicron.mp3 +0 -0
- examples/favorites/atkins_value.mp3 +0 -0
- examples/favorites/daniel_craig_dumbledore.mp3 +0 -0
- examples/favorites/daniel_craig_training_ethics.mp3 +0 -0
- examples/favorites/dotrice_stop_for_death.mp3 +0 -0
- examples/favorites/emma_stone_courage.mp3 +0 -0
- examples/favorites/emma_stone_training_ethics.mp3 +0 -0
- examples/favorites/halle_barry_dumbledore.mp3 +0 -0
- examples/favorites/halle_barry_oar_to_oar.mp3 +0 -0
- examples/favorites/henry_cavill_metallic_hydrogen.mp3 +0 -0
- examples/favorites/kennard_road_not_taken.mp3 +0 -0
- examples/favorites/morgan_freeman_metallic_hydrogen.mp3 +0 -0
- examples/favorites/myself_gatsby.mp3 +0 -0
- examples/favorites/patrick_stewart_omicron.mp3 +0 -0
- examples/favorites/patrick_stewart_secret_of_life.mp3 +0 -0
- examples/favorites/robert_deniro_review.mp3 +0 -0
- examples/favorites/william_shatner_spacecraft_interview.mp3 +0 -0
- examples/riding_hood/angelina.mp3 +0 -0
- examples/riding_hood/craig.mp3 +0 -0
- examples/riding_hood/deniro.mp3 +0 -0
- examples/riding_hood/emma.mp3 +0 -0
- examples/riding_hood/freeman.mp3 +0 -0
- examples/riding_hood/geralt.mp3 +0 -0
- examples/riding_hood/halle.mp3 +0 -0
- examples/riding_hood/jlaw.mp3 +0 -0
- examples/riding_hood/lj.mp3 +0 -0
- examples/riding_hood/myself.mp3 +0 -0
- examples/riding_hood/pat.mp3 +0 -0
- examples/riding_hood/snakes.mp3 +0 -0
.gitignore
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
pip-wheel-metadata/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
*.py,cover
|
51 |
+
.hypothesis/
|
52 |
+
.pytest_cache/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
target/
|
76 |
+
|
77 |
+
# Jupyter Notebook
|
78 |
+
.ipynb_checkpoints
|
79 |
+
|
80 |
+
# IPython
|
81 |
+
profile_default/
|
82 |
+
ipython_config.py
|
83 |
+
|
84 |
+
# pyenv
|
85 |
+
.python-version
|
86 |
+
|
87 |
+
# pipenv
|
88 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
89 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
90 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
91 |
+
# install all needed dependencies.
|
92 |
+
#Pipfile.lock
|
93 |
+
|
94 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
95 |
+
__pypackages__/
|
96 |
+
|
97 |
+
# Celery stuff
|
98 |
+
celerybeat-schedule
|
99 |
+
celerybeat.pid
|
100 |
+
|
101 |
+
# SageMath parsed files
|
102 |
+
*.sage.py
|
103 |
+
|
104 |
+
# Environments
|
105 |
+
.env
|
106 |
+
.venv
|
107 |
+
env/
|
108 |
+
venv/
|
109 |
+
ENV/
|
110 |
+
env.bak/
|
111 |
+
venv.bak/
|
112 |
+
|
113 |
+
# Spyder project settings
|
114 |
+
.spyderproject
|
115 |
+
.spyproject
|
116 |
+
|
117 |
+
# Rope project settings
|
118 |
+
.ropeproject
|
119 |
+
|
120 |
+
# mkdocs documentation
|
121 |
+
/site
|
122 |
+
|
123 |
+
# mypy
|
124 |
+
.mypy_cache/
|
125 |
+
.dmypy.json
|
126 |
+
dmypy.json
|
127 |
+
|
128 |
+
# Pyre type checker
|
129 |
+
.pyre/
|
130 |
+
|
131 |
+
.idea/*
|
.models/.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
.models/autoregressive.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65c0c801fc6a7841d87e055e42c254c1f27703647af719d78f9e1002e90386db
|
3 |
+
size 1716988501
|
.models/classifier.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:95ab946010be0a963b5039e8fca74bbb8a6eebcf366c761db21ae7e94cd6ada3
|
3 |
+
size 60938957
|
.models/clvp2.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c
|
3 |
+
size 975620731
|
.models/cvvp.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d050e32592ad4a318e03a4f99b09c9c26baf68d78a9d7503ff2bc3883e897100
|
3 |
+
size 151223901
|
.models/diffusion_decoder.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4e089edfbbd73a7a23180068c86676400ff83809651070581302ef500d4bca99
|
3 |
+
size 1169472627
|
.models/rlg_auto.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4473c125482e2a3322a5ea762025a0c6ec657955c3002cf099c0635d79967551
|
3 |
+
size 25193729
|
.models/rlg_diffuser.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e84b1ce60631c56dc8dec3d27c131993dd99d3060e7919cc351857457dbfdac
|
3 |
+
size 100715777
|
.models/vocoder.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d
|
3 |
+
size 391384715
|
CITATION.cff
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cff-version: 1.3.0
|
2 |
+
message: "If you use this software, please cite it as below."
|
3 |
+
authors:
|
4 |
+
- family-names: "Betker"
|
5 |
+
given-names: "James"
|
6 |
+
orcid: "https://orcid.org/my-orcid?orcid=0000-0003-3259-4862"
|
7 |
+
title: "TorToiSe text-to-speech"
|
8 |
+
version: 2.0
|
9 |
+
date-released: 2022-04-28
|
10 |
+
url: "https://github.com/neonbjb/tortoise-tts"
|
LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
README.md
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# TorToiSe
|
2 |
+
|
3 |
+
Tortoise is a text-to-speech program built with the following priorities:
|
4 |
+
|
5 |
+
1. Strong multi-voice capabilities.
|
6 |
+
2. Highly realistic prosody and intonation.
|
7 |
+
|
8 |
+
This repo contains all the code needed to run Tortoise TTS in inference mode.
|
9 |
+
|
10 |
+
### New features
|
11 |
+
|
12 |
+
#### v2.1; 2022/5/2
|
13 |
+
- Added ability to produce totally random voices.
|
14 |
+
- Added ability to download voice conditioning latent via a script, and then use a user-provided conditioning latent.
|
15 |
+
- Added ability to use your own pretrained models.
|
16 |
+
- Refactored directory structures.
|
17 |
+
- Performance improvements & bug fixes.
|
18 |
+
|
19 |
+
## What's in a name?
|
20 |
+
|
21 |
+
I'm naming my speech-related repos after Mojave desert flora and fauna. Tortoise is a bit tongue in cheek: this model
|
22 |
+
is insanely slow. It leverages both an autoregressive decoder **and** a diffusion decoder; both known for their low
|
23 |
+
sampling rates. On a K80, expect to generate a medium sized sentence every 2 minutes.
|
24 |
+
|
25 |
+
## Demos
|
26 |
+
|
27 |
+
See [this page](http://nonint.com/static/tortoise_v2_examples.html) for a large list of example outputs.
|
28 |
+
|
29 |
+
## Usage guide
|
30 |
+
|
31 |
+
### Colab
|
32 |
+
|
33 |
+
Colab is the easiest way to try this out. I've put together a notebook you can use here:
|
34 |
+
https://colab.research.google.com/drive/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing
|
35 |
+
|
36 |
+
### Installation
|
37 |
+
|
38 |
+
If you want to use this on your own computer, you must have an NVIDIA GPU. First, install pytorch using these
|
39 |
+
instructions: [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
|
40 |
+
|
41 |
+
Then:
|
42 |
+
|
43 |
+
```shell
|
44 |
+
git clone https://github.com/neonbjb/tortoise-tts.git
|
45 |
+
cd tortoise-tts
|
46 |
+
python setup.py install
|
47 |
+
```
|
48 |
+
|
49 |
+
### do_tts.py
|
50 |
+
|
51 |
+
This script allows you to speak a single phrase with one or more voices.
|
52 |
+
```shell
|
53 |
+
python tortoise/do_tts.py --text "I'm going to speak this" --voice random --preset fast
|
54 |
+
```
|
55 |
+
|
56 |
+
### read.py
|
57 |
+
|
58 |
+
This script provides tools for reading large amounts of text.
|
59 |
+
|
60 |
+
```shell
|
61 |
+
python tortoise/read.py --textfile <your text to be read> --voice random
|
62 |
+
```
|
63 |
+
|
64 |
+
This will break up the textfile into sentences, and then convert them to speech one at a time. It will output a series
|
65 |
+
of spoken clips as they are generated. Once all the clips are generated, it will combine them into a single file and
|
66 |
+
output that as well.
|
67 |
+
|
68 |
+
Sometimes Tortoise screws up an output. You can re-generate any bad clips by re-running `read.py` with the --regenerate
|
69 |
+
argument.
|
70 |
+
|
71 |
+
### API
|
72 |
+
|
73 |
+
Tortoise can be used programmatically, like so:
|
74 |
+
|
75 |
+
```python
|
76 |
+
reference_clips = [utils.audio.load_audio(p, 22050) for p in clips_paths]
|
77 |
+
tts = api.TextToSpeech()
|
78 |
+
pcm_audio = tts.tts_with_preset("your text here", reference_clips, preset='fast')
|
79 |
+
```
|
80 |
+
|
81 |
+
## Voice customization guide
|
82 |
+
|
83 |
+
Tortoise was specifically trained to be a multi-speaker model. It accomplishes this by consulting reference clips.
|
84 |
+
|
85 |
+
These reference clips are recordings of a speaker that you provide to guide speech generation. These clips are used to determine many properties of the output, such as the pitch and tone of the voice, speaking speed, and even speaking defects like a lisp or stuttering. The reference clip is also used to determine non-voice related aspects of the audio output like volume, background noise, recording quality and reverb.
|
86 |
+
|
87 |
+
### Random voice
|
88 |
+
|
89 |
+
I've included a feature which randomly generates a voice. These voices don't actually exist and will be random every time you run
|
90 |
+
it. The results are quite fascinating and I recommend you play around with it!
|
91 |
+
|
92 |
+
You can use the random voice by passing in 'random' as the voice name. Tortoise will take care of the rest.
|
93 |
+
|
94 |
+
For the those in the ML space: this is created by projecting a random vector onto the voice conditioning latent space.
|
95 |
+
|
96 |
+
### Provided voices
|
97 |
+
|
98 |
+
This repo comes with several pre-packaged voices. You will be familiar with many of them. :)
|
99 |
+
|
100 |
+
Most of the provided voices were not found in the training set. Experimentally, it seems that voices from the training set
|
101 |
+
produce more realistic outputs then those outside of the training set. Any voice prepended with "train" came from the
|
102 |
+
training set.
|
103 |
+
|
104 |
+
### Adding a new voice
|
105 |
+
|
106 |
+
To add new voices to Tortoise, you will need to do the following:
|
107 |
+
|
108 |
+
1. Gather audio clips of your speaker(s). Good sources are YouTube interviews (you can use youtube-dl to fetch the audio), audiobooks or podcasts. Guidelines for good clips are in the next section.
|
109 |
+
2. Cut your clips into ~10 second segments. You want at least 3 clips. More is better, but I only experimented with up to 5 in my testing.
|
110 |
+
3. Save the clips as a WAV file with floating point format and a 22,050 sample rate.
|
111 |
+
4. Create a subdirectory in voices/
|
112 |
+
5. Put your clips in that subdirectory.
|
113 |
+
6. Run tortoise utilities with --voice=<your_subdirectory_name>.
|
114 |
+
|
115 |
+
### Picking good reference clips
|
116 |
+
|
117 |
+
As mentioned above, your reference clips have a profound impact on the output of Tortoise. Following are some tips for picking
|
118 |
+
good clips:
|
119 |
+
|
120 |
+
1. Avoid clips with background music, noise or reverb. These clips were removed from the training dataset. Tortoise is unlikely to do well with them.
|
121 |
+
2. Avoid speeches. These generally have distortion caused by the amplification system.
|
122 |
+
3. Avoid clips from phone calls.
|
123 |
+
4. Avoid clips that have excessive stuttering, stammering or words like "uh" or "like" in them.
|
124 |
+
5. Try to find clips that are spoken in such a way as you wish your output to sound like. For example, if you want to hear your target voice read an audiobook, try to find clips of them reading a book.
|
125 |
+
6. The text being spoken in the clips does not matter, but diverse text does seem to perform better.
|
126 |
+
|
127 |
+
## Advanced Usage
|
128 |
+
|
129 |
+
### Generation settings
|
130 |
+
|
131 |
+
Tortoise is primarily an autoregressive decoder model combined with a diffusion model. Both of these have a lot of knobs
|
132 |
+
that can be turned that I've abstracted away for the sake of ease of use. I did this by generating thousands of clips using
|
133 |
+
various permutations of the settings and using a metric for voice realism and intelligibility to measure their effects. I've
|
134 |
+
set the defaults to the best overall settings I was able to find. For specific use-cases, it might be effective to play with
|
135 |
+
these settings (and it's very likely that I missed something!)
|
136 |
+
|
137 |
+
These settings are not available in the normal scripts packaged with Tortoise. They are available, however, in the API. See
|
138 |
+
```api.tts``` for a full list.
|
139 |
+
|
140 |
+
### Prompt engineering
|
141 |
+
|
142 |
+
Some people have discovered that it is possible to do prompt engineering with Tortoise! For example, you can evoke emotion
|
143 |
+
by including things like "I am really sad," before your text. I've built an automated redaction system that you can use to
|
144 |
+
take advantage of this. It works by attempting to redact any text in the prompt surrounded by brackets. For example, the
|
145 |
+
prompt "\[I am really sad,\] Please feed me." will only speak the words "Please feed me" (with a sad tonality).
|
146 |
+
|
147 |
+
### Playing with the voice latent
|
148 |
+
|
149 |
+
Tortoise ingests reference clips by feeding them through individually through a small submodel that produces a point latent,
|
150 |
+
then taking the mean of all of the produced latents. The experimentation I have done has indicated that these point latents
|
151 |
+
are quite expressive, affecting everything from tone to speaking rate to speech abnormalities.
|
152 |
+
|
153 |
+
This lends itself to some neat tricks. For example, you can combine feed two different voices to tortoise and it will output
|
154 |
+
what it thinks the "average" of those two voices sounds like.
|
155 |
+
|
156 |
+
#### Generating conditioning latents from voices
|
157 |
+
|
158 |
+
Use the script `get_conditioning_latents.py` to extract conditioning latents for a voice you have installed. This script
|
159 |
+
will dump the latents to a .pth pickle file. The file will contain a single tuple, (autoregressive_latent, diffusion_latent).
|
160 |
+
|
161 |
+
Alternatively, use the api.TextToSpeech.get_conditioning_latents() to fetch the latents.
|
162 |
+
|
163 |
+
#### Using raw conditioning latents to generate speech
|
164 |
+
|
165 |
+
After you've played with them, you can use them to generate speech by creating a subdirectory in voices/ with a single
|
166 |
+
".pth" file containing the pickled conditioning latents as a tuple (autoregressive_latent, diffusion_latent).
|
167 |
+
|
168 |
+
### Send me feedback!
|
169 |
+
|
170 |
+
Probabilistic models like Tortoise are best thought of as an "augmented search" - in this case, through the space of possible
|
171 |
+
utterances of a specific string of text. The impact of community involvement in perusing these spaces (such as is being done with
|
172 |
+
GPT-3 or CLIP) has really surprised me. If you find something neat that you can do with Tortoise that isn't documented here,
|
173 |
+
please report it to me! I would be glad to publish it to this page.
|
174 |
+
|
175 |
+
## Tortoise-detect
|
176 |
+
|
177 |
+
Out of concerns that this model might be misused, I've built a classifier that tells the likelihood that an audio clip
|
178 |
+
came from Tortoise.
|
179 |
+
|
180 |
+
This classifier can be run on any computer, usage is as follows:
|
181 |
+
|
182 |
+
```commandline
|
183 |
+
python tortoise/is_this_from_tortoise.py --clip=<path_to_suspicious_audio_file>
|
184 |
+
```
|
185 |
+
|
186 |
+
This model has 100% accuracy on the contents of the results/ and voices/ folders in this repo. Still, treat this classifier
|
187 |
+
as a "strong signal". Classifiers can be fooled and it is likewise not impossible for this classifier to exhibit false
|
188 |
+
positives.
|
189 |
+
|
190 |
+
## Model architecture
|
191 |
+
|
192 |
+
Tortoise TTS is inspired by OpenAI's DALLE, applied to speech data and using a better decoder. It is made up of 5 separate
|
193 |
+
models that work together. I've assembled a write-up of the system architecture here:
|
194 |
+
[https://nonint.com/2022/04/25/tortoise-architectural-design-doc/](https://nonint.com/2022/04/25/tortoise-architectural-design-doc/)
|
195 |
+
|
196 |
+
## Training
|
197 |
+
|
198 |
+
These models were trained on my "homelab" server with 8 RTX 3090s over the course of several months. They were trained on a dataset consisting of
|
199 |
+
~50k hours of speech data, most of which was transcribed by [ocotillo](http://www.github.com/neonbjb/ocotillo). Training was done on my own
|
200 |
+
[DLAS](https://github.com/neonbjb/DL-Art-School) trainer.
|
201 |
+
|
202 |
+
I currently do not have plans to release the training configurations or methodology. See the next section..
|
203 |
+
|
204 |
+
## Ethical Considerations
|
205 |
+
|
206 |
+
Tortoise v2 works considerably better than I had planned. When I began hearing some of the outputs of the last few versions, I began
|
207 |
+
wondering whether or not I had an ethically unsound project on my hands. The ways in which a voice-cloning text-to-speech system
|
208 |
+
could be misused are many. It doesn't take much creativity to think up how.
|
209 |
+
|
210 |
+
After some thought, I have decided to go forward with releasing this. Following are the reasons for this choice:
|
211 |
+
|
212 |
+
1. It is primarily good at reading books and speaking poetry. Other forms of speech do not work well.
|
213 |
+
2. It was trained on a dataset which does not have the voices of public figures. While it will attempt to mimic these voices if they are provided as references, it does not do so in such a way that most humans would be fooled.
|
214 |
+
3. The above points could likely be resolved by scaling up the model and the dataset. For this reason, I am currently withholding details on how I trained the model, pending community feedback.
|
215 |
+
4. I am releasing a separate classifier model which will tell you whether a given audio clip was generated by Tortoise or not. See `tortoise-detect` above.
|
216 |
+
5. If I, a tinkerer with a BS in computer science with a ~$15k computer can build this, then any motivated corporation or state can as well. I would prefer that it be in the open and everyone know the kinds of things ML can do.
|
217 |
+
|
218 |
+
### Diversity
|
219 |
+
|
220 |
+
The diversity expressed by ML models is strongly tied to the datasets they were trained on.
|
221 |
+
|
222 |
+
Tortoise was trained primarily on a dataset consisting of audiobooks. I made no effort to
|
223 |
+
balance diversity in this dataset. For this reason, Tortoise will be particularly poor at generating the voices of minorities
|
224 |
+
or of people who speak with strong accents.
|
225 |
+
|
226 |
+
## Looking forward
|
227 |
+
|
228 |
+
Tortoise v2 is about as good as I think I can do in the TTS world with the resources I have access to. A phenomenon that happens when
|
229 |
+
training very large models is that as parameter count increases, the communication bandwidth needed to support distributed training
|
230 |
+
of the model increases multiplicatively. On enterprise-grade hardware, this is not an issue: GPUs are attached together with
|
231 |
+
exceptionally wide buses that can accommodate this bandwidth. I cannot afford enterprise hardware, though, so I am stuck.
|
232 |
+
|
233 |
+
I want to mention here
|
234 |
+
that I think Tortoise could do be a **lot** better. The three major components of Tortoise are either vanilla Transformer Encoder stacks
|
235 |
+
or Decoder stacks. Both of these types of models have a rich experimental history with scaling in the NLP realm. I see no reason
|
236 |
+
to believe that the same is not true of TTS.
|
237 |
+
|
238 |
+
The largest model in Tortoise v2 is considerably smaller than GPT-2 large. It is 20x smaller that the original DALLE transformer.
|
239 |
+
Imagine what a TTS model trained at or near GPT-3 or DALLE scale could achieve.
|
240 |
+
|
241 |
+
If you are an ethical organization with computational resources to spare interested in seeing what this model could do
|
242 |
+
if properly scaled out, please reach out to me! I would love to collaborate on this.
|
243 |
+
|
244 |
+
## Acknowledgements
|
245 |
+
|
246 |
+
This project has garnered more praise than I expected. I am standing on the shoulders of giants, though, and I want to
|
247 |
+
credit a few of the amazing folks in the community that have helped make this happen:
|
248 |
+
|
249 |
+
- Hugging Face, who wrote the GPT model and the generate API used by Tortoise, and who hosts the model weights.
|
250 |
+
- [Ramesh et al](https://arxiv.org/pdf/2102.12092.pdf) who authored the DALLE paper, which is the inspiration behind Tortoise.
|
251 |
+
- [Nichol and Dhariwal](https://arxiv.org/pdf/2102.09672.pdf) who authored the (revision of) the code that drives the diffusion model.
|
252 |
+
- [Jang et al](https://arxiv.org/pdf/2106.07889.pdf) who developed and open-sourced univnet, the vocoder this repo uses.
|
253 |
+
- [lucidrains](https://github.com/lucidrains) who writes awesome open source pytorch models, many of which are used here.
|
254 |
+
- [Patrick von Platen](https://huggingface.co/patrickvonplaten) whose guides on setting up wav2vec were invaluable to building my dataset.
|
255 |
+
|
256 |
+
## Notice
|
257 |
+
|
258 |
+
Tortoise was built entirely by me using my own hardware. My employer was not involved in any facet of Tortoise's development.
|
259 |
+
|
260 |
+
If you use this repo or the ideas therein for your research, please cite it! A bibtex entree can be found in the right pane on GitHub.
|
api.py
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
from urllib import request
|
5 |
+
|
6 |
+
import torch
|
7 |
+
import torch.nn.functional as F
|
8 |
+
import progressbar
|
9 |
+
import torchaudio
|
10 |
+
|
11 |
+
from models.classifier import AudioMiniEncoderWithClassifierHead
|
12 |
+
from models.cvvp import CVVP
|
13 |
+
from models.diffusion_decoder import DiffusionTts
|
14 |
+
from models.autoregressive import UnifiedVoice
|
15 |
+
from tqdm import tqdm
|
16 |
+
|
17 |
+
from models.arch_util import TorchMelSpectrogram
|
18 |
+
from models.clvp import CLVP
|
19 |
+
from models.vocoder import UnivNetGenerator
|
20 |
+
from utils.audio import load_audio, wav_to_univnet_mel, denormalize_tacotron_mel
|
21 |
+
from utils.diffusion import SpacedDiffusion, space_timesteps, get_named_beta_schedule
|
22 |
+
from utils.tokenizer import VoiceBpeTokenizer, lev_distance
|
23 |
+
|
24 |
+
|
25 |
+
pbar = None
|
26 |
+
|
27 |
+
|
28 |
+
def download_models(specific_models=None):
|
29 |
+
"""
|
30 |
+
Call to download all the models that Tortoise uses.
|
31 |
+
"""
|
32 |
+
MODELS = {
|
33 |
+
'autoregressive.pth': 'https://huggingface.co/jbetker/tortoise-tts-v2/resolve/hf/.models/autoregressive.pth',
|
34 |
+
'classifier.pth': 'https://huggingface.co/jbetker/tortoise-tts-v2/resolve/hf/.models/classifier.pth',
|
35 |
+
'clvp.pth': 'https://huggingface.co/jbetker/tortoise-tts-v2/resolve/hf/.models/clvp.pth',
|
36 |
+
'cvvp.pth': 'https://huggingface.co/jbetker/tortoise-tts-v2/resolve/hf/.models/cvvp.pth',
|
37 |
+
'diffusion_decoder.pth': 'https://huggingface.co/jbetker/tortoise-tts-v2/resolve/hf/.models/diffusion_decoder.pth',
|
38 |
+
'vocoder.pth': 'https://huggingface.co/jbetker/tortoise-tts-v2/resolve/hf/.models/vocoder.pth',
|
39 |
+
}
|
40 |
+
os.makedirs('.models', exist_ok=True)
|
41 |
+
def show_progress(block_num, block_size, total_size):
|
42 |
+
global pbar
|
43 |
+
if pbar is None:
|
44 |
+
pbar = progressbar.ProgressBar(maxval=total_size)
|
45 |
+
pbar.start()
|
46 |
+
|
47 |
+
downloaded = block_num * block_size
|
48 |
+
if downloaded < total_size:
|
49 |
+
pbar.update(downloaded)
|
50 |
+
else:
|
51 |
+
pbar.finish()
|
52 |
+
pbar = None
|
53 |
+
for model_name, url in MODELS.items():
|
54 |
+
if specific_models is not None and model_name not in specific_models:
|
55 |
+
continue
|
56 |
+
if os.path.exists(f'.models/{model_name}'):
|
57 |
+
continue
|
58 |
+
print(f'Downloading {model_name} from {url}...')
|
59 |
+
request.urlretrieve(url, f'.models/{model_name}', show_progress)
|
60 |
+
print('Done.')
|
61 |
+
|
62 |
+
|
63 |
+
def pad_or_truncate(t, length):
|
64 |
+
"""
|
65 |
+
Utility function for forcing <t> to have the specified sequence length, whether by clipping it or padding it with 0s.
|
66 |
+
"""
|
67 |
+
if t.shape[-1] == length:
|
68 |
+
return t
|
69 |
+
elif t.shape[-1] < length:
|
70 |
+
return F.pad(t, (0, length-t.shape[-1]))
|
71 |
+
else:
|
72 |
+
return t[..., :length]
|
73 |
+
|
74 |
+
|
75 |
+
def load_discrete_vocoder_diffuser(trained_diffusion_steps=4000, desired_diffusion_steps=200, cond_free=True, cond_free_k=1):
|
76 |
+
"""
|
77 |
+
Helper function to load a GaussianDiffusion instance configured for use as a vocoder.
|
78 |
+
"""
|
79 |
+
return SpacedDiffusion(use_timesteps=space_timesteps(trained_diffusion_steps, [desired_diffusion_steps]), model_mean_type='epsilon',
|
80 |
+
model_var_type='learned_range', loss_type='mse', betas=get_named_beta_schedule('linear', trained_diffusion_steps),
|
81 |
+
conditioning_free=cond_free, conditioning_free_k=cond_free_k)
|
82 |
+
|
83 |
+
|
84 |
+
def format_conditioning(clip, cond_length=132300):
|
85 |
+
"""
|
86 |
+
Converts the given conditioning signal to a MEL spectrogram and clips it as expected by the models.
|
87 |
+
"""
|
88 |
+
gap = clip.shape[-1] - cond_length
|
89 |
+
if gap < 0:
|
90 |
+
clip = F.pad(clip, pad=(0, abs(gap)))
|
91 |
+
elif gap > 0:
|
92 |
+
rand_start = random.randint(0, gap)
|
93 |
+
clip = clip[:, rand_start:rand_start + cond_length]
|
94 |
+
mel_clip = TorchMelSpectrogram()(clip.unsqueeze(0)).squeeze(0)
|
95 |
+
return mel_clip.unsqueeze(0).cuda()
|
96 |
+
|
97 |
+
|
98 |
+
def fix_autoregressive_output(codes, stop_token, complain=True):
|
99 |
+
"""
|
100 |
+
This function performs some padding on coded audio that fixes a mismatch issue between what the diffusion model was
|
101 |
+
trained on and what the autoregressive code generator creates (which has no padding or end).
|
102 |
+
This is highly specific to the DVAE being used, so this particular coding will not necessarily work if used with
|
103 |
+
a different DVAE. This can be inferred by feeding a audio clip padded with lots of zeros on the end through the DVAE
|
104 |
+
and copying out the last few codes.
|
105 |
+
|
106 |
+
Failing to do this padding will produce speech with a harsh end that sounds like "BLAH" or similar.
|
107 |
+
"""
|
108 |
+
# Strip off the autoregressive stop token and add padding.
|
109 |
+
stop_token_indices = (codes == stop_token).nonzero()
|
110 |
+
if len(stop_token_indices) == 0:
|
111 |
+
if complain:
|
112 |
+
print("No stop tokens found, enjoy that output of yours!")
|
113 |
+
return codes
|
114 |
+
else:
|
115 |
+
codes[stop_token_indices] = 83
|
116 |
+
stm = stop_token_indices.min().item()
|
117 |
+
codes[stm:] = 83
|
118 |
+
if stm - 3 < codes.shape[0]:
|
119 |
+
codes[-3] = 45
|
120 |
+
codes[-2] = 45
|
121 |
+
codes[-1] = 248
|
122 |
+
|
123 |
+
return codes
|
124 |
+
|
125 |
+
|
126 |
+
def do_spectrogram_diffusion(diffusion_model, diffuser, latents, conditioning_samples, temperature=1, verbose=True):
|
127 |
+
"""
|
128 |
+
Uses the specified diffusion model to convert discrete codes into a spectrogram.
|
129 |
+
"""
|
130 |
+
with torch.no_grad():
|
131 |
+
cond_mels = []
|
132 |
+
for sample in conditioning_samples:
|
133 |
+
# The diffuser operates at a sample rate of 24000 (except for the latent inputs)
|
134 |
+
sample = torchaudio.functional.resample(sample, 22050, 24000)
|
135 |
+
sample = pad_or_truncate(sample, 102400)
|
136 |
+
cond_mel = wav_to_univnet_mel(sample.to(latents.device), do_normalization=False)
|
137 |
+
cond_mels.append(cond_mel)
|
138 |
+
cond_mels = torch.stack(cond_mels, dim=1)
|
139 |
+
|
140 |
+
output_seq_len = latents.shape[1] * 4 * 24000 // 22050 # This diffusion model converts from 22kHz spectrogram codes to a 24kHz spectrogram signal.
|
141 |
+
output_shape = (latents.shape[0], 100, output_seq_len)
|
142 |
+
precomputed_embeddings = diffusion_model.timestep_independent(latents, cond_mels, output_seq_len, False)
|
143 |
+
|
144 |
+
noise = torch.randn(output_shape, device=latents.device) * temperature
|
145 |
+
mel = diffuser.p_sample_loop(diffusion_model, output_shape, noise=noise,
|
146 |
+
model_kwargs={'precomputed_aligned_embeddings': precomputed_embeddings},
|
147 |
+
progress=verbose)
|
148 |
+
return denormalize_tacotron_mel(mel)[:,:,:output_seq_len]
|
149 |
+
|
150 |
+
|
151 |
+
def classify_audio_clip(clip):
|
152 |
+
"""
|
153 |
+
Returns whether or not Tortoises' classifier thinks the given clip came from Tortoise.
|
154 |
+
:param clip: torch tensor containing audio waveform data (get it from load_audio)
|
155 |
+
:return: True if the clip was classified as coming from Tortoise and false if it was classified as real.
|
156 |
+
"""
|
157 |
+
download_models(['classifier.pth'])
|
158 |
+
classifier = AudioMiniEncoderWithClassifierHead(2, spec_dim=1, embedding_dim=512, depth=5, downsample_factor=4,
|
159 |
+
resnet_blocks=2, attn_blocks=4, num_attn_heads=4, base_channels=32,
|
160 |
+
dropout=0, kernel_size=5, distribute_zero_label=False)
|
161 |
+
classifier.load_state_dict(torch.load('.models/classifier.pth', map_location=torch.device('cpu')))
|
162 |
+
clip = clip.cpu().unsqueeze(0)
|
163 |
+
results = F.softmax(classifier(clip), dim=-1)
|
164 |
+
return results[0][0]
|
165 |
+
|
166 |
+
|
167 |
+
class TextToSpeech:
|
168 |
+
"""
|
169 |
+
Main entry point into Tortoise.
|
170 |
+
:param autoregressive_batch_size: Specifies how many samples to generate per batch. Lower this if you are seeing
|
171 |
+
GPU OOM errors. Larger numbers generates slightly faster.
|
172 |
+
"""
|
173 |
+
def __init__(self, autoregressive_batch_size=16):
|
174 |
+
self.autoregressive_batch_size = autoregressive_batch_size
|
175 |
+
self.tokenizer = VoiceBpeTokenizer()
|
176 |
+
download_models()
|
177 |
+
|
178 |
+
self.autoregressive = UnifiedVoice(max_mel_tokens=604, max_text_tokens=402, max_conditioning_inputs=2, layers=30,
|
179 |
+
model_dim=1024,
|
180 |
+
heads=16, number_text_tokens=255, start_text_token=255, checkpointing=False,
|
181 |
+
train_solo_embeddings=False,
|
182 |
+
average_conditioning_embeddings=True).cpu().eval()
|
183 |
+
self.autoregressive.load_state_dict(torch.load('.models/autoregressive.pth'))
|
184 |
+
|
185 |
+
self.clvp = CLVP(dim_text=512, dim_speech=512, dim_latent=512, num_text_tokens=256, text_enc_depth=12,
|
186 |
+
text_seq_len=350, text_heads=8,
|
187 |
+
num_speech_tokens=8192, speech_enc_depth=12, speech_heads=8, speech_seq_len=430,
|
188 |
+
use_xformers=True).cpu().eval()
|
189 |
+
self.clvp.load_state_dict(torch.load('.models/clvp.pth'))
|
190 |
+
|
191 |
+
self.cvvp = CVVP(model_dim=512, transformer_heads=8, dropout=0, mel_codes=8192, conditioning_enc_depth=8, cond_mask_percentage=0,
|
192 |
+
speech_enc_depth=8, speech_mask_percentage=0, latent_multiplier=1).cpu().eval()
|
193 |
+
self.cvvp.load_state_dict(torch.load('.models/cvvp.pth'))
|
194 |
+
|
195 |
+
self.diffusion = DiffusionTts(model_channels=1024, num_layers=10, in_channels=100, out_channels=200,
|
196 |
+
in_latent_channels=1024, in_tokens=8193, dropout=0, use_fp16=False, num_heads=16,
|
197 |
+
layer_drop=0, unconditioned_percentage=0).cpu().eval()
|
198 |
+
self.diffusion.load_state_dict(torch.load('.models/diffusion_decoder.pth'))
|
199 |
+
|
200 |
+
self.vocoder = UnivNetGenerator().cpu()
|
201 |
+
self.vocoder.load_state_dict(torch.load('.models/vocoder.pth')['model_g'])
|
202 |
+
self.vocoder.eval(inference=True)
|
203 |
+
|
204 |
+
def tts_with_preset(self, text, voice_samples, preset='fast', **kwargs):
|
205 |
+
"""
|
206 |
+
Calls TTS with one of a set of preset generation parameters. Options:
|
207 |
+
'ultra_fast': Produces speech at a speed which belies the name of this repo. (Not really, but it's definitely fastest).
|
208 |
+
'fast': Decent quality speech at a decent inference rate. A good choice for mass inference.
|
209 |
+
'standard': Very good quality. This is generally about as good as you are going to get.
|
210 |
+
'high_quality': Use if you want the absolute best. This is not really worth the compute, though.
|
211 |
+
"""
|
212 |
+
# Use generally found best tuning knobs for generation.
|
213 |
+
kwargs.update({'temperature': .8, 'length_penalty': 1.0, 'repetition_penalty': 2.0,
|
214 |
+
#'typical_sampling': True,
|
215 |
+
'top_p': .8,
|
216 |
+
'cond_free_k': 2.0, 'diffusion_temperature': 1.0})
|
217 |
+
# Presets are defined here.
|
218 |
+
presets = {
|
219 |
+
'ultra_fast': {'num_autoregressive_samples': 32, 'diffusion_iterations': 16, 'cond_free': False},
|
220 |
+
'fast': {'num_autoregressive_samples': 96, 'diffusion_iterations': 32},
|
221 |
+
'standard': {'num_autoregressive_samples': 256, 'diffusion_iterations': 128},
|
222 |
+
'high_quality': {'num_autoregressive_samples': 512, 'diffusion_iterations': 1024},
|
223 |
+
}
|
224 |
+
kwargs.update(presets[preset])
|
225 |
+
return self.tts(text, voice_samples, **kwargs)
|
226 |
+
|
227 |
+
def tts(self, text, voice_samples, k=1, verbose=True,
|
228 |
+
# autoregressive generation parameters follow
|
229 |
+
num_autoregressive_samples=512, temperature=.8, length_penalty=1, repetition_penalty=2.0, top_p=.8, max_mel_tokens=500,
|
230 |
+
typical_sampling=False, typical_mass=.9,
|
231 |
+
# CLVP & CVVP parameters
|
232 |
+
clvp_cvvp_slider=.5,
|
233 |
+
# diffusion generation parameters follow
|
234 |
+
diffusion_iterations=100, cond_free=True, cond_free_k=2, diffusion_temperature=1.0,
|
235 |
+
**hf_generate_kwargs):
|
236 |
+
"""
|
237 |
+
Produces an audio clip of the given text being spoken with the given reference voice.
|
238 |
+
:param text: Text to be spoken.
|
239 |
+
:param voice_samples: List of 2 or more ~10 second reference clips which should be torch tensors containing 22.05kHz waveform data.
|
240 |
+
:param k: The number of returned clips. The most likely (as determined by Tortoises' CLVP and CVVP models) clips are returned.
|
241 |
+
:param verbose: Whether or not to print log messages indicating the progress of creating a clip. Default=true.
|
242 |
+
~~AUTOREGRESSIVE KNOBS~~
|
243 |
+
:param num_autoregressive_samples: Number of samples taken from the autoregressive model, all of which are filtered using CLVP+CVVP.
|
244 |
+
As Tortoise is a probabilistic model, more samples means a higher probability of creating something "great".
|
245 |
+
:param temperature: The softmax temperature of the autoregressive model.
|
246 |
+
:param length_penalty: A length penalty applied to the autoregressive decoder. Higher settings causes the model to produce more terse outputs.
|
247 |
+
:param repetition_penalty: A penalty that prevents the autoregressive decoder from repeating itself during decoding. Can be used to reduce the incidence
|
248 |
+
of long silences or "uhhhhhhs", etc.
|
249 |
+
:param top_p: P value used in nucleus sampling. (0,1]. Lower values mean the decoder produces more "likely" (aka boring) outputs.
|
250 |
+
:param max_mel_tokens: Restricts the output length. (0,600] integer. Each unit is 1/20 of a second.
|
251 |
+
:param typical_sampling: Turns typical sampling on or off. This sampling mode is discussed in this paper: https://arxiv.org/abs/2202.00666
|
252 |
+
I was interested in the premise, but the results were not as good as I was hoping. This is off by default, but
|
253 |
+
could use some tuning.
|
254 |
+
:param typical_mass: The typical_mass parameter from the typical_sampling algorithm.
|
255 |
+
~~CLVP-CVVP KNOBS~~
|
256 |
+
:param clvp_cvvp_slider: Controls the influence of the CLVP and CVVP models in selecting the best output from the autoregressive model.
|
257 |
+
[0,1]. Values closer to 1 will cause Tortoise to emit clips that follow the text more. Values closer to
|
258 |
+
0 will cause Tortoise to emit clips that more closely follow the reference clip (e.g. the voice sounds more
|
259 |
+
similar).
|
260 |
+
~~DIFFUSION KNOBS~~
|
261 |
+
:param diffusion_iterations: Number of diffusion steps to perform. [0,4000]. More steps means the network has more chances to iteratively refine
|
262 |
+
the output, which should theoretically mean a higher quality output. Generally a value above 250 is not noticeably better,
|
263 |
+
however.
|
264 |
+
:param cond_free: Whether or not to perform conditioning-free diffusion. Conditioning-free diffusion performs two forward passes for
|
265 |
+
each diffusion step: one with the outputs of the autoregressive model and one with no conditioning priors. The output
|
266 |
+
of the two is blended according to the cond_free_k value below. Conditioning-free diffusion is the real deal, and
|
267 |
+
dramatically improves realism.
|
268 |
+
:param cond_free_k: Knob that determines how to balance the conditioning free signal with the conditioning-present signal. [0,inf].
|
269 |
+
As cond_free_k increases, the output becomes dominated by the conditioning-free signal.
|
270 |
+
Formula is: output=cond_present_output*(cond_free_k+1)-cond_absenct_output*cond_free_k
|
271 |
+
:param diffusion_temperature: Controls the variance of the noise fed into the diffusion model. [0,1]. Values at 0
|
272 |
+
are the "mean" prediction of the diffusion network and will sound bland and smeared.
|
273 |
+
~~OTHER STUFF~~
|
274 |
+
:param hf_generate_kwargs: The huggingface Transformers generate API is used for the autoregressive transformer.
|
275 |
+
Extra keyword args fed to this function get forwarded directly to that API. Documentation
|
276 |
+
here: https://huggingface.co/docs/transformers/internal/generation_utils
|
277 |
+
:return: Generated audio clip(s) as a torch tensor. Shape 1,S if k=1 else, (k,1,S) where S is the sample length.
|
278 |
+
Sample rate is 24kHz.
|
279 |
+
"""
|
280 |
+
text = torch.IntTensor(self.tokenizer.encode(text)).unsqueeze(0).cuda()
|
281 |
+
text = F.pad(text, (0, 1)) # This may not be necessary.
|
282 |
+
|
283 |
+
conds = []
|
284 |
+
if not isinstance(voice_samples, list):
|
285 |
+
voice_samples = [voice_samples]
|
286 |
+
for vs in voice_samples:
|
287 |
+
conds.append(format_conditioning(vs))
|
288 |
+
conds = torch.stack(conds, dim=1)
|
289 |
+
|
290 |
+
diffuser = load_discrete_vocoder_diffuser(desired_diffusion_steps=diffusion_iterations, cond_free=cond_free, cond_free_k=cond_free_k)
|
291 |
+
|
292 |
+
with torch.no_grad():
|
293 |
+
samples = []
|
294 |
+
num_batches = num_autoregressive_samples // self.autoregressive_batch_size
|
295 |
+
stop_mel_token = self.autoregressive.stop_mel_token
|
296 |
+
calm_token = 83 # This is the token for coding silence, which is fixed in place with "fix_autoregressive_output"
|
297 |
+
self.autoregressive = self.autoregressive.cuda()
|
298 |
+
if verbose:
|
299 |
+
print("Generating autoregressive samples..")
|
300 |
+
for b in tqdm(range(num_batches), disable=not verbose):
|
301 |
+
codes = self.autoregressive.inference_speech(conds, text,
|
302 |
+
do_sample=True,
|
303 |
+
top_p=top_p,
|
304 |
+
temperature=temperature,
|
305 |
+
num_return_sequences=self.autoregressive_batch_size,
|
306 |
+
length_penalty=length_penalty,
|
307 |
+
repetition_penalty=repetition_penalty,
|
308 |
+
max_generate_length=max_mel_tokens,
|
309 |
+
**hf_generate_kwargs)
|
310 |
+
padding_needed = max_mel_tokens - codes.shape[1]
|
311 |
+
codes = F.pad(codes, (0, padding_needed), value=stop_mel_token)
|
312 |
+
samples.append(codes)
|
313 |
+
self.autoregressive = self.autoregressive.cpu()
|
314 |
+
|
315 |
+
clip_results = []
|
316 |
+
self.clvp = self.clvp.cuda()
|
317 |
+
self.cvvp = self.cvvp.cuda()
|
318 |
+
if verbose:
|
319 |
+
print("Computing best candidates using CLVP and CVVP")
|
320 |
+
for batch in tqdm(samples, disable=not verbose):
|
321 |
+
for i in range(batch.shape[0]):
|
322 |
+
batch[i] = fix_autoregressive_output(batch[i], stop_mel_token)
|
323 |
+
clvp = self.clvp(text.repeat(batch.shape[0], 1), batch, return_loss=False)
|
324 |
+
cvvp_accumulator = 0
|
325 |
+
for cl in range(conds.shape[1]):
|
326 |
+
cvvp_accumulator = cvvp_accumulator + self.cvvp(conds[:, cl].repeat(batch.shape[0], 1, 1), batch, return_loss=False )
|
327 |
+
cvvp = cvvp_accumulator / conds.shape[1]
|
328 |
+
clip_results.append(clvp * clvp_cvvp_slider + cvvp * (1-clvp_cvvp_slider))
|
329 |
+
clip_results = torch.cat(clip_results, dim=0)
|
330 |
+
samples = torch.cat(samples, dim=0)
|
331 |
+
best_results = samples[torch.topk(clip_results, k=k).indices]
|
332 |
+
self.clvp = self.clvp.cpu()
|
333 |
+
self.cvvp = self.cvvp.cpu()
|
334 |
+
del samples
|
335 |
+
|
336 |
+
# The diffusion model actually wants the last hidden layer from the autoregressive model as conditioning
|
337 |
+
# inputs. Re-produce those for the top results. This could be made more efficient by storing all of these
|
338 |
+
# results, but will increase memory usage.
|
339 |
+
self.autoregressive = self.autoregressive.cuda()
|
340 |
+
best_latents = self.autoregressive(conds, text, torch.tensor([text.shape[-1]], device=conds.device), best_results,
|
341 |
+
torch.tensor([best_results.shape[-1]*self.autoregressive.mel_length_compression], device=conds.device),
|
342 |
+
return_latent=True, clip_inputs=False)
|
343 |
+
self.autoregressive = self.autoregressive.cpu()
|
344 |
+
|
345 |
+
if verbose:
|
346 |
+
print("Transforming autoregressive outputs into audio..")
|
347 |
+
wav_candidates = []
|
348 |
+
self.diffusion = self.diffusion.cuda()
|
349 |
+
self.vocoder = self.vocoder.cuda()
|
350 |
+
for b in range(best_results.shape[0]):
|
351 |
+
codes = best_results[b].unsqueeze(0)
|
352 |
+
latents = best_latents[b].unsqueeze(0)
|
353 |
+
|
354 |
+
# Find the first occurrence of the "calm" token and trim the codes to that.
|
355 |
+
ctokens = 0
|
356 |
+
for k in range(codes.shape[-1]):
|
357 |
+
if codes[0, k] == calm_token:
|
358 |
+
ctokens += 1
|
359 |
+
else:
|
360 |
+
ctokens = 0
|
361 |
+
if ctokens > 8: # 8 tokens gives the diffusion model some "breathing room" to terminate speech.
|
362 |
+
latents = latents[:, :k]
|
363 |
+
break
|
364 |
+
|
365 |
+
mel = do_spectrogram_diffusion(self.diffusion, diffuser, latents, voice_samples, temperature=diffusion_temperature, verbose=verbose)
|
366 |
+
wav = self.vocoder.inference(mel)
|
367 |
+
wav_candidates.append(wav.cpu())
|
368 |
+
self.diffusion = self.diffusion.cpu()
|
369 |
+
self.vocoder = self.vocoder.cpu()
|
370 |
+
|
371 |
+
if len(wav_candidates) > 1:
|
372 |
+
return wav_candidates
|
373 |
+
return wav_candidates[0]
|
data/mel_norms.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f69422a8a8f344c4fca2f0c6b8d41d2151d6615b7321e48e6bb15ae949b119c
|
3 |
+
size 1067
|
data/riding_hood.txt
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Once upon a time there lived in a certain village a little country girl, the prettiest creature who was ever seen. Her mother was excessively fond of her; and her grandmother doted on her still more. This good woman had a little red riding hood made for her. It suited the girl so extremely well that everybody called her Little Red Riding Hood.
|
2 |
+
One day her mother, having made some cakes, said to her, "Go, my dear, and see how your grandmother is doing, for I hear she has been very ill. Take her a cake, and this little pot of butter."
|
3 |
+
|
4 |
+
Little Red Riding Hood set out immediately to go to her grandmother, who lived in another village.
|
5 |
+
|
6 |
+
As she was going through the wood, she met with a wolf, who had a very great mind to eat her up, but he dared not, because of some woodcutters working nearby in the forest. He asked her where she was going. The poor child, who did not know that it was dangerous to stay and talk to a wolf, said to him, "I am going to see my grandmother and carry her a cake and a little pot of butter from my mother."
|
7 |
+
|
8 |
+
"Does she live far off?" said the wolf
|
9 |
+
|
10 |
+
"Oh I say," answered Little Red Riding Hood; "it is beyond that mill you see there, at the first house in the village."
|
11 |
+
|
12 |
+
"Well," said the wolf, "and I'll go and see her too. I'll go this way and go you that, and we shall see who will be there first."
|
13 |
+
|
14 |
+
The wolf ran as fast as he could, taking the shortest path, and the little girl took a roundabout way, entertaining herself by gathering nuts, running after butterflies, and gathering bouquets of little flowers. It was not long before the wolf arrived at the old woman's house. He knocked at the door: tap, tap.
|
15 |
+
|
16 |
+
"Who's there?"
|
17 |
+
|
18 |
+
"Your grandchild, Little Red Riding Hood," replied the wolf, counterfeiting her voice; "who has brought you a cake and a little pot of butter sent you by mother."
|
19 |
+
|
20 |
+
The good grandmother, who was in bed, because she was somewhat ill, cried out, "Pull the bobbin, and the latch will go up."
|
21 |
+
|
22 |
+
The wolf pulled the bobbin, and the door opened, and then he immediately fell upon the good woman and ate her up in a moment, for it been more than three days since he had eaten. He then shut the door and got into the grandmother's bed, expecting Little Red Riding Hood, who came some time afterwards and knocked at the door: tap, tap.
|
23 |
+
|
24 |
+
"Who's there?"
|
25 |
+
|
26 |
+
Little Red Riding Hood, hearing the big voice of the wolf, was at first afraid; but believing her grandmother had a cold and was hoarse, answered, "It is your grandchild Little Red Riding Hood, who has brought you a cake and a little pot of butter mother sends you."
|
27 |
+
|
28 |
+
The wolf cried out to her, softening his voice as much as he could, "Pull the bobbin, and the latch will go up."
|
29 |
+
|
30 |
+
Little Red Riding Hood pulled the bobbin, and the door opened.
|
31 |
+
|
32 |
+
The wolf, seeing her come in, said to her, hiding himself under the bedclothes, "Put the cake and the little pot of butter upon the stool, and come get into bed with me."
|
33 |
+
|
34 |
+
Little Red Riding Hood took off her clothes and got into bed. She was greatly amazed to see how her grandmother looked in her nightclothes, and said to her, "Grandmother, what big arms you have!"
|
35 |
+
|
36 |
+
"All the better to hug you with, my dear."
|
37 |
+
|
38 |
+
"Grandmother, what big legs you have!"
|
39 |
+
|
40 |
+
"All the better to run with, my child."
|
41 |
+
|
42 |
+
"Grandmother, what big ears you have!"
|
43 |
+
|
44 |
+
"All the better to hear with, my child."
|
45 |
+
|
46 |
+
"Grandmother, what big eyes you have!"
|
47 |
+
|
48 |
+
"All the better to see with, my child."
|
49 |
+
|
50 |
+
"Grandmother, what big teeth you have got!"
|
51 |
+
|
52 |
+
"All the better to eat you up with."
|
53 |
+
|
54 |
+
And, saying these words, this wicked wolf fell upon Little Red Riding Hood, and ate her all up.
|
data/tokenizer.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":"1.0","truncation":null,"padding":null,"added_tokens":[{"id":0,"special":true,"content":"[STOP]","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":1,"special":true,"content":"[UNK]","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":2,"special":true,"content":"[SPACE]","single_word":false,"lstrip":false,"rstrip":false,"normalized":false}],"normalizer":null,"pre_tokenizer":{"type":"Whitespace"},"post_processor":null,"decoder":null,"model":{"type":"BPE","dropout":null,"unk_token":"[UNK]","continuing_subword_prefix":null,"end_of_word_suffix":null,"fuse_unk":false,"vocab":{"[STOP]":0,"[UNK]":1,"[SPACE]":2,"!":3,"'":4,"(":5,")":6,",":7,"-":8,".":9,"/":10,":":11,";":12,"?":13,"a":14,"b":15,"c":16,"d":17,"e":18,"f":19,"g":20,"h":21,"i":22,"j":23,"k":24,"l":25,"m":26,"n":27,"o":28,"p":29,"q":30,"r":31,"s":32,"t":33,"u":34,"v":35,"w":36,"x":37,"y":38,"z":39,"th":40,"in":41,"the":42,"an":43,"er":44,"ou":45,"re":46,"on":47,"at":48,"ed":49,"en":50,"to":51,"ing":52,"and":53,"is":54,"as":55,"al":56,"or":57,"of":58,"ar":59,"it":60,"es":61,"he":62,"st":63,"le":64,"om":65,"se":66,"be":67,"ad":68,"ow":69,"ly":70,"ch":71,"wh":72,"that":73,"you":74,"li":75,"ve":76,"ac":77,"ti":78,"ld":79,"me":80,"was":81,"gh":82,"id":83,"ll":84,"wi":85,"ent":86,"for":87,"ay":88,"ro":89,"ver":90,"ic":91,"her":92,"ke":93,"his":94,"no":95,"ut":96,"un":97,"ir":98,"lo":99,"we":100,"ri":101,"ha":102,"with":103,"ght":104,"out":105,"im":106,"ion":107,"all":108,"ab":109,"one":110,"ne":111,"ge":112,"ould":113,"ter":114,"mo":115,"had":116,"ce":117,"she":118,"go":119,"sh":120,"ur":121,"am":122,"so":123,"pe":124,"my":125,"de":126,"are":127,"but":128,"ome":129,"fr":130,"ther":131,"fe":132,"su":133,"do":134,"con":135,"te":136,"ain":137,"ere":138,"po":139,"if":140,"they":141,"us":142,"ag":143,"tr":144,"now":145,"oun":146,"this":147,"have":148,"not":149,"sa":150,"il":151,"up":152,"thing":153,"from":154,"ap":155,"him":156,"ack":157,"ation":158,"ant":159,"our":160,"op":161,"like":162,"ust":163,"ess":164,"bo":165,"ok":166,"ul":167,"ind":168,"ex":169,"com":170,"some":171,"there":172,"ers":173,"co":174,"res":175,"man":176,"ard":177,"pl":178,"wor":179,"way":180,"tion":181,"fo":182,"ca":183,"were":184,"by":185,"ate":186,"pro":187,"ted":188,"ound":189,"own":190,"would":191,"ts":192,"what":193,"qu":194,"ally":195,"ight":196,"ck":197,"gr":198,"when":199,"ven":200,"can":201,"ough":202,"ine":203,"end":204,"per":205,"ous":206,"od":207,"ide":208,"know":209,"ty":210,"very":211,"si":212,"ak":213,"who":214,"about":215,"ill":216,"them":217,"est":218,"red":219,"ye":220,"could":221,"ong":222,"your":223,"their":224,"em":225,"just":226,"other":227,"into":228,"any":229,"whi":230,"um":231,"tw":232,"ast":233,"der":234,"did":235,"ie":236,"been":237,"ace":238,"ink":239,"ity":240,"back":241,"ting":242,"br":243,"more":244,"ake":245,"pp":246,"then":247,"sp":248,"el":249,"use":250,"bl":251,"said":252,"over":253,"get":254},"merges":["t h","i n","th e","a n","e r","o u","r e","o n","a t","e d","e n","t o","in g","an d","i s","a s","a l","o r","o f","a r","i t","e s","h e","s t","l e","o m","s e","b e","a d","o w","l y","c h","w h","th at","y ou","l i","v e","a c","t i","l d","m e","w as","g h","i d","l l","w i","en t","f or","a y","r o","v er","i c","h er","k e","h is","n o","u t","u n","i r","l o","w e","r i","h a","wi th","gh t","ou t","i m","i on","al l","a b","on e","n e","g e","ou ld","t er","m o","h ad","c e","s he","g o","s h","u r","a m","s o","p e","m y","d e","a re","b ut","om e","f r","the r","f e","s u","d o","c on","t e","a in","er e","p o","i f","the y","u s","a g","t r","n ow","ou n","th is","ha ve","no t","s a","i l","u p","th ing","fr om","a p","h im","ac k","at ion","an t","ou r","o p","li ke","u st","es s","b o","o k","u l","in d","e x","c om","s ome","the re","er s","c o","re s","m an","ar d","p l","w or","w ay","ti on","f o","c a","w ere","b y","at e","p ro","t ed","oun d","ow n","w ould","t s","wh at","q u","al ly","i ght","c k","g r","wh en","v en","c an","ou gh","in e","en d","p er","ou s","o d","id e","k now","t y","ver y","s i","a k","wh o","ab out","i ll","the m","es t","re d","y e","c ould","on g","you r","the ir","e m","j ust","o ther","in to","an y","wh i","u m","t w","as t","d er","d id","i e","be en","ac e","in k","it y","b ack","t ing","b r","mo re","a ke","p p","the n","s p","e l","u se","b l","sa id","o ver","ge t"]}}
|
do_tts.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
|
4 |
+
import torchaudio
|
5 |
+
|
6 |
+
from api import TextToSpeech
|
7 |
+
from utils.audio import load_audio, get_voices
|
8 |
+
|
9 |
+
if __name__ == '__main__':
|
10 |
+
parser = argparse.ArgumentParser()
|
11 |
+
parser.add_argument('--text', type=str, help='Text to speak.', default="I am a language model that has learned to speak.")
|
12 |
+
parser.add_argument('--voice', type=str, help='Selects the voice to use for generation. See options in voices/ directory (and add your own!) '
|
13 |
+
'Use the & character to join two voices together. Use a comma to perform inference on multiple voices.', default='pat')
|
14 |
+
parser.add_argument('--preset', type=str, help='Which voice preset to use.', default='standard')
|
15 |
+
parser.add_argument('--voice_diversity_intelligibility_slider', type=float,
|
16 |
+
help='How to balance vocal diversity with the quality/intelligibility of the spoken text. 0 means highly diverse voice (not recommended), 1 means maximize intellibility',
|
17 |
+
default=.5)
|
18 |
+
parser.add_argument('--output_path', type=str, help='Where to store outputs.', default='results/')
|
19 |
+
args = parser.parse_args()
|
20 |
+
os.makedirs(args.output_path, exist_ok=True)
|
21 |
+
|
22 |
+
tts = TextToSpeech()
|
23 |
+
|
24 |
+
voices = get_voices()
|
25 |
+
selected_voices = args.voice.split(',')
|
26 |
+
for voice in selected_voices:
|
27 |
+
cond_paths = voices[voice]
|
28 |
+
conds = []
|
29 |
+
for cond_path in cond_paths:
|
30 |
+
c = load_audio(cond_path, 22050)
|
31 |
+
conds.append(c)
|
32 |
+
gen = tts.tts_with_preset(args.text, conds, preset=args.preset, clvp_cvvp_slider=args.voice_diversity_intelligibility_slider)
|
33 |
+
torchaudio.save(os.path.join(args.output_path, f'{voice}.wav'), gen.squeeze(0).cpu(), 24000)
|
34 |
+
|
eval_multiple.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
import torchaudio
|
4 |
+
|
5 |
+
from api import TextToSpeech
|
6 |
+
from utils.audio import load_audio
|
7 |
+
|
8 |
+
if __name__ == '__main__':
|
9 |
+
fname = 'Y:\\clips\\books2\\subset512-oco.tsv'
|
10 |
+
stop_after = 128
|
11 |
+
outpath_base = 'D:\\tmp\\tortoise-tts-eval\\audiobooks'
|
12 |
+
outpath_real = 'D:\\tmp\\tortoise-tts-eval\\real'
|
13 |
+
|
14 |
+
os.makedirs(outpath_real, exist_ok=True)
|
15 |
+
with open(fname, 'r', encoding='utf-8') as f:
|
16 |
+
lines = [l.strip().split('\t') for l in f.readlines()]
|
17 |
+
|
18 |
+
tts = TextToSpeech()
|
19 |
+
for k in range(3):
|
20 |
+
outpath = f'{outpath_base}_{k}'
|
21 |
+
os.makedirs(outpath, exist_ok=True)
|
22 |
+
recorder = open(os.path.join(outpath, 'transcript.tsv'), 'w', encoding='utf-8')
|
23 |
+
for e, line in enumerate(lines):
|
24 |
+
if e >= stop_after:
|
25 |
+
break
|
26 |
+
transcript = line[0]
|
27 |
+
path = os.path.join(os.path.dirname(fname), line[1])
|
28 |
+
cond_audio = load_audio(path, 22050)
|
29 |
+
torchaudio.save(os.path.join(outpath_real, os.path.basename(line[1])), cond_audio, 22050)
|
30 |
+
sample = tts.tts_with_preset(transcript, [cond_audio, cond_audio], preset='standard')
|
31 |
+
|
32 |
+
down = torchaudio.functional.resample(sample, 24000, 22050)
|
33 |
+
fout_path = os.path.join(outpath, os.path.basename(line[1]))
|
34 |
+
torchaudio.save(fout_path, down.squeeze(0), 22050)
|
35 |
+
|
36 |
+
recorder.write(f'{transcript}\t{fout_path}\n')
|
37 |
+
recorder.flush()
|
38 |
+
recorder.close()
|
examples/.gitattributes
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
favorite_riding_hood.mp3 filter=lfs diff=lfs merge=lfs -text
|
2 |
+
favorites filter=lfs diff=lfs merge=lfs -text
|
3 |
+
riding_hood filter=lfs diff=lfs merge=lfs -text
|
4 |
+
tacotron_comparison filter=lfs diff=lfs merge=lfs -text
|
5 |
+
various filter=lfs diff=lfs merge=lfs -text
|
examples/favorites/atkins_mha.mp3
ADDED
Binary file (31.6 kB). View file
|
|
examples/favorites/atkins_omicron.mp3
ADDED
Binary file (41.3 kB). View file
|
|
examples/favorites/atkins_value.mp3
ADDED
Binary file (18.5 kB). View file
|
|
examples/favorites/daniel_craig_dumbledore.mp3
ADDED
Binary file (24 kB). View file
|
|
examples/favorites/daniel_craig_training_ethics.mp3
ADDED
Binary file (48.9 kB). View file
|
|
examples/favorites/dotrice_stop_for_death.mp3
ADDED
Binary file (28.8 kB). View file
|
|
examples/favorites/emma_stone_courage.mp3
ADDED
Binary file (34.1 kB). View file
|
|
examples/favorites/emma_stone_training_ethics.mp3
ADDED
Binary file (48 kB). View file
|
|
examples/favorites/halle_barry_dumbledore.mp3
ADDED
Binary file (21.5 kB). View file
|
|
examples/favorites/halle_barry_oar_to_oar.mp3
ADDED
Binary file (40.9 kB). View file
|
|
examples/favorites/henry_cavill_metallic_hydrogen.mp3
ADDED
Binary file (32 kB). View file
|
|
examples/favorites/kennard_road_not_taken.mp3
ADDED
Binary file (28.5 kB). View file
|
|
examples/favorites/morgan_freeman_metallic_hydrogen.mp3
ADDED
Binary file (35.4 kB). View file
|
|
examples/favorites/myself_gatsby.mp3
ADDED
Binary file (28.1 kB). View file
|
|
examples/favorites/patrick_stewart_omicron.mp3
ADDED
Binary file (37.6 kB). View file
|
|
examples/favorites/patrick_stewart_secret_of_life.mp3
ADDED
Binary file (36.5 kB). View file
|
|
examples/favorites/robert_deniro_review.mp3
ADDED
Binary file (36.1 kB). View file
|
|
examples/favorites/william_shatner_spacecraft_interview.mp3
ADDED
Binary file (47.3 kB). View file
|
|
examples/riding_hood/angelina.mp3
ADDED
Binary file (866 kB). View file
|
|
examples/riding_hood/craig.mp3
ADDED
Binary file (826 kB). View file
|
|
examples/riding_hood/deniro.mp3
ADDED
Binary file (851 kB). View file
|
|
examples/riding_hood/emma.mp3
ADDED
Binary file (807 kB). View file
|
|
examples/riding_hood/freeman.mp3
ADDED
Binary file (943 kB). View file
|
|
examples/riding_hood/geralt.mp3
ADDED
Binary file (788 kB). View file
|
|
examples/riding_hood/halle.mp3
ADDED
Binary file (785 kB). View file
|
|
examples/riding_hood/jlaw.mp3
ADDED
Binary file (667 kB). View file
|
|
examples/riding_hood/lj.mp3
ADDED
Binary file (817 kB). View file
|
|
examples/riding_hood/myself.mp3
ADDED
Binary file (951 kB). View file
|
|
examples/riding_hood/pat.mp3
ADDED
Binary file (887 kB). View file
|
|
examples/riding_hood/snakes.mp3
ADDED
Binary file (790 kB). View file
|
|