perilli jbetker commited on
Commit
9cf44bd
0 Parent(s):

Duplicate from jbetker/tortoise

Browse files

Co-authored-by: James Betker <jbetker@users.noreply.huggingface.co>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +131 -0
  2. .models/.gitattributes +1 -0
  3. .models/autoregressive.pth +3 -0
  4. .models/classifier.pth +3 -0
  5. .models/clvp.pth +3 -0
  6. .models/cvvp.pth +3 -0
  7. .models/diffusion_decoder.pth +3 -0
  8. .models/rlg_auto.pth +3 -0
  9. .models/rlg_diffuser.pth +3 -0
  10. .models/vocoder.pth +3 -0
  11. CITATION.cff +10 -0
  12. LICENSE +201 -0
  13. README.md +15 -0
  14. api.py +373 -0
  15. app.py +7 -0
  16. data/mel_norms.pth +0 -0
  17. data/riding_hood.txt +54 -0
  18. data/tokenizer.json +1 -0
  19. do_tts.py +34 -0
  20. eval_multiple.py +38 -0
  21. examples/.gitattributes +5 -0
  22. examples/favorite_riding_hood.mp3 +3 -0
  23. examples/favorites/atkins_mha.mp3 +0 -0
  24. examples/favorites/atkins_omicron.mp3 +0 -0
  25. examples/favorites/atkins_value.mp3 +0 -0
  26. examples/favorites/daniel_craig_dumbledore.mp3 +0 -0
  27. examples/favorites/daniel_craig_training_ethics.mp3 +0 -0
  28. examples/favorites/dotrice_stop_for_death.mp3 +0 -0
  29. examples/favorites/emma_stone_courage.mp3 +0 -0
  30. examples/favorites/emma_stone_training_ethics.mp3 +0 -0
  31. examples/favorites/halle_barry_dumbledore.mp3 +0 -0
  32. examples/favorites/halle_barry_oar_to_oar.mp3 +0 -0
  33. examples/favorites/henry_cavill_metallic_hydrogen.mp3 +0 -0
  34. examples/favorites/kennard_road_not_taken.mp3 +0 -0
  35. examples/favorites/morgan_freeman_metallic_hydrogen.mp3 +0 -0
  36. examples/favorites/myself_gatsby.mp3 +0 -0
  37. examples/favorites/patrick_stewart_omicron.mp3 +0 -0
  38. examples/favorites/patrick_stewart_secret_of_life.mp3 +0 -0
  39. examples/favorites/robert_deniro_review.mp3 +0 -0
  40. examples/favorites/william_shatner_spacecraft_interview.mp3 +0 -0
  41. examples/riding_hood/angelina.mp3 +0 -0
  42. examples/riding_hood/craig.mp3 +0 -0
  43. examples/riding_hood/deniro.mp3 +0 -0
  44. examples/riding_hood/emma.mp3 +0 -0
  45. examples/riding_hood/freeman.mp3 +0 -0
  46. examples/riding_hood/geralt.mp3 +0 -0
  47. examples/riding_hood/halle.mp3 +0 -0
  48. examples/riding_hood/jlaw.mp3 +0 -0
  49. examples/riding_hood/lj.mp3 +0 -0
  50. examples/riding_hood/myself.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:9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51
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/clvp.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d9f19a110b1d08bed88ade7067947edc274e58b72d74e6897283f6cd844d7c9
3
+ size 271601435
.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:ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1
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,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: TorToiSe
3
+ emoji: 🐢
4
+ colorFrom: yellow
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 2.9.4
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ models: jbetker/tortoise-tts-v2
12
+ duplicated_from: jbetker/tortoise
13
+ ---
14
+
15
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
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]
app.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def greet(name):
4
+ return "Hello " + name + "!!"
5
+
6
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ iface.launch()
data/mel_norms.pth ADDED
Binary file (1.07 kB). View file
 
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/favorite_riding_hood.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8fc300bce87fcf771fcade7df5b4708d41c635e0f940468cdbb8b0a1d4feb78
3
+ size 970413
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