cdminix commited on
Commit
e82ce68
·
verified ·
1 Parent(s): 61f4626

Add tortoise weights

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +78 -0
  2. .gitignore +131 -0
  3. .models/.gitattributes +1 -0
  4. .models/.locks/models--Manmay--tortoise-tts/16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d.lock +0 -0
  5. .models/.locks/models--Manmay--tortoise-tts/6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c.lock +0 -0
  6. .models/.locks/models--Manmay--tortoise-tts/9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51.lock +0 -0
  7. .models/.locks/models--Manmay--tortoise-tts/ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1.lock +0 -0
  8. .models/autoregressive.pth +3 -0
  9. .models/classifier.pth +3 -0
  10. .models/clvp.pth +3 -0
  11. .models/clvp2.pth +3 -0
  12. .models/cvvp.pth +3 -0
  13. .models/diffusion_decoder.pth +3 -0
  14. .models/models--Manmay--tortoise-tts/blobs/16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d +3 -0
  15. .models/models--Manmay--tortoise-tts/blobs/6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c +3 -0
  16. .models/models--Manmay--tortoise-tts/blobs/9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51 +3 -0
  17. .models/models--Manmay--tortoise-tts/blobs/ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1 +3 -0
  18. .models/models--Manmay--tortoise-tts/refs/main +1 -0
  19. .models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/autoregressive.pth +3 -0
  20. .models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/clvp2.pth +3 -0
  21. .models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/diffusion_decoder.pth +3 -0
  22. .models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/vocoder.pth +3 -0
  23. .models/rlg_auto.pth +3 -0
  24. .models/rlg_diffuser.pth +3 -0
  25. .models/vocoder.pth +3 -0
  26. CITATION.cff +10 -0
  27. LICENSE +201 -0
  28. README.md +115 -0
  29. api.py +373 -0
  30. checkpoints/tacotron_symbols/.gitattributes +27 -0
  31. checkpoints/tacotron_symbols/README.md +3 -0
  32. checkpoints/tacotron_symbols/special_tokens_map.json +1 -0
  33. checkpoints/tacotron_symbols/tokenizer_config.json +1 -0
  34. checkpoints/tacotron_symbols/vocab.json +1 -0
  35. checkpoints/wav2vec2-large-960h/.gitattributes +17 -0
  36. checkpoints/wav2vec2-large-960h/README.md +92 -0
  37. checkpoints/wav2vec2-large-960h/config.json +51 -0
  38. checkpoints/wav2vec2-large-960h/preprocessor_config.json +8 -0
  39. checkpoints/wav2vec2-large-960h/pytorch_model.bin +3 -0
  40. checkpoints/wav2vec2-large-960h/special_tokens_map.json +1 -0
  41. checkpoints/wav2vec2-large-960h/tokenizer_config.json +1 -0
  42. checkpoints/wav2vec2-large-960h/vocab.json +1 -0
  43. checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/.gitattributes +27 -0
  44. checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/README.md +11 -0
  45. checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/config.json +109 -0
  46. checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/pytorch_model.bin +3 -0
  47. data/mel_norms.pth +3 -0
  48. data/riding_hood.txt +54 -0
  49. data/tokenizer.json +1 -0
  50. do_tts.py +34 -0
.gitattributes CHANGED
@@ -33,3 +33,81 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ .models/models--Manmay--tortoise-tts/blobs/16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d filter=lfs diff=lfs merge=lfs -text
37
+ .models/models--Manmay--tortoise-tts/blobs/6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c filter=lfs diff=lfs merge=lfs -text
38
+ .models/models--Manmay--tortoise-tts/blobs/9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51 filter=lfs diff=lfs merge=lfs -text
39
+ .models/models--Manmay--tortoise-tts/blobs/ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1 filter=lfs diff=lfs merge=lfs -text
40
+ examples/favorite_riding_hood.mp3 filter=lfs diff=lfs merge=lfs -text
41
+ examples/riding_hood/angelina.mp3 filter=lfs diff=lfs merge=lfs -text
42
+ examples/riding_hood/craig.mp3 filter=lfs diff=lfs merge=lfs -text
43
+ examples/riding_hood/deniro.mp3 filter=lfs diff=lfs merge=lfs -text
44
+ examples/riding_hood/emma.mp3 filter=lfs diff=lfs merge=lfs -text
45
+ examples/riding_hood/freeman.mp3 filter=lfs diff=lfs merge=lfs -text
46
+ examples/riding_hood/geralt.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ examples/riding_hood/halle.mp3 filter=lfs diff=lfs merge=lfs -text
48
+ examples/riding_hood/jlaw.mp3 filter=lfs diff=lfs merge=lfs -text
49
+ examples/riding_hood/lj.mp3 filter=lfs diff=lfs merge=lfs -text
50
+ examples/riding_hood/myself.mp3 filter=lfs diff=lfs merge=lfs -text
51
+ examples/riding_hood/pat.mp3 filter=lfs diff=lfs merge=lfs -text
52
+ examples/riding_hood/snakes.mp3 filter=lfs diff=lfs merge=lfs -text
53
+ examples/riding_hood/tom.mp3 filter=lfs diff=lfs merge=lfs -text
54
+ examples/riding_hood/weaver.mp3 filter=lfs diff=lfs merge=lfs -text
55
+ examples/riding_hood/william.mp3 filter=lfs diff=lfs merge=lfs -text
56
+ tortoise/voices/angie/1.wav filter=lfs diff=lfs merge=lfs -text
57
+ tortoise/voices/angie/3.wav filter=lfs diff=lfs merge=lfs -text
58
+ tortoise/voices/daniel/1.wav filter=lfs diff=lfs merge=lfs -text
59
+ tortoise/voices/daniel/2.wav filter=lfs diff=lfs merge=lfs -text
60
+ tortoise/voices/daniel/3.wav filter=lfs diff=lfs merge=lfs -text
61
+ tortoise/voices/daniel/4.wav filter=lfs diff=lfs merge=lfs -text
62
+ tortoise/voices/deniro/1.wav filter=lfs diff=lfs merge=lfs -text
63
+ tortoise/voices/deniro/3.wav filter=lfs diff=lfs merge=lfs -text
64
+ tortoise/voices/deniro/4.wav filter=lfs diff=lfs merge=lfs -text
65
+ tortoise/voices/emma/1.wav filter=lfs diff=lfs merge=lfs -text
66
+ tortoise/voices/emma/2.wav filter=lfs diff=lfs merge=lfs -text
67
+ tortoise/voices/emma/3.wav filter=lfs diff=lfs merge=lfs -text
68
+ tortoise/voices/freeman/1.wav filter=lfs diff=lfs merge=lfs -text
69
+ tortoise/voices/freeman/2.wav filter=lfs diff=lfs merge=lfs -text
70
+ tortoise/voices/freeman/3.wav filter=lfs diff=lfs merge=lfs -text
71
+ tortoise/voices/geralt/1.wav filter=lfs diff=lfs merge=lfs -text
72
+ tortoise/voices/geralt/2.wav filter=lfs diff=lfs merge=lfs -text
73
+ tortoise/voices/geralt/3.wav filter=lfs diff=lfs merge=lfs -text
74
+ tortoise/voices/halle/1.wav filter=lfs diff=lfs merge=lfs -text
75
+ tortoise/voices/halle/2.wav filter=lfs diff=lfs merge=lfs -text
76
+ tortoise/voices/halle/3.wav filter=lfs diff=lfs merge=lfs -text
77
+ tortoise/voices/jlaw/1.wav filter=lfs diff=lfs merge=lfs -text
78
+ tortoise/voices/jlaw/2.wav filter=lfs diff=lfs merge=lfs -text
79
+ tortoise/voices/jlaw/3.wav filter=lfs diff=lfs merge=lfs -text
80
+ tortoise/voices/jlaw/4.wav filter=lfs diff=lfs merge=lfs -text
81
+ tortoise/voices/lj/1.wav filter=lfs diff=lfs merge=lfs -text
82
+ tortoise/voices/lj/2.wav filter=lfs diff=lfs merge=lfs -text
83
+ tortoise/voices/mol/1.wav filter=lfs diff=lfs merge=lfs -text
84
+ tortoise/voices/mol/2.wav filter=lfs diff=lfs merge=lfs -text
85
+ tortoise/voices/myself/1.wav filter=lfs diff=lfs merge=lfs -text
86
+ tortoise/voices/myself/2.wav filter=lfs diff=lfs merge=lfs -text
87
+ tortoise/voices/myself/3.wav filter=lfs diff=lfs merge=lfs -text
88
+ tortoise/voices/pat/1.wav filter=lfs diff=lfs merge=lfs -text
89
+ tortoise/voices/pat/2.wav filter=lfs diff=lfs merge=lfs -text
90
+ tortoise/voices/pat/3.wav filter=lfs diff=lfs merge=lfs -text
91
+ tortoise/voices/pat/4.wav filter=lfs diff=lfs merge=lfs -text
92
+ tortoise/voices/pat2/00159.mp3 filter=lfs diff=lfs merge=lfs -text
93
+ tortoise/voices/tom/1.wav filter=lfs diff=lfs merge=lfs -text
94
+ tortoise/voices/tom/2.wav filter=lfs diff=lfs merge=lfs -text
95
+ tortoise/voices/tom/3.wav filter=lfs diff=lfs merge=lfs -text
96
+ tortoise/voices/tom/4.wav filter=lfs diff=lfs merge=lfs -text
97
+ tortoise/voices/train_atkins/1.wav filter=lfs diff=lfs merge=lfs -text
98
+ tortoise/voices/train_atkins/2.wav filter=lfs diff=lfs merge=lfs -text
99
+ tortoise/voices/train_dotrice/1.wav filter=lfs diff=lfs merge=lfs -text
100
+ tortoise/voices/train_dotrice/2.wav filter=lfs diff=lfs merge=lfs -text
101
+ tortoise/voices/train_grace/1.wav filter=lfs diff=lfs merge=lfs -text
102
+ tortoise/voices/train_grace/2.wav filter=lfs diff=lfs merge=lfs -text
103
+ tortoise/voices/train_kennard/1.wav filter=lfs diff=lfs merge=lfs -text
104
+ tortoise/voices/train_kennard/2.wav filter=lfs diff=lfs merge=lfs -text
105
+ tortoise/voices/train_lescault/1.wav filter=lfs diff=lfs merge=lfs -text
106
+ tortoise/voices/train_lescault/2.wav filter=lfs diff=lfs merge=lfs -text
107
+ tortoise/voices/weaver/1.wav filter=lfs diff=lfs merge=lfs -text
108
+ tortoise/voices/weaver/2.wav filter=lfs diff=lfs merge=lfs -text
109
+ tortoise/voices/weaver/3.wav filter=lfs diff=lfs merge=lfs -text
110
+ tortoise/voices/william/1.wav filter=lfs diff=lfs merge=lfs -text
111
+ tortoise/voices/william/2.wav filter=lfs diff=lfs merge=lfs -text
112
+ tortoise/voices/william/3.wav filter=lfs diff=lfs merge=lfs -text
113
+ tortoise/voices/william/4.wav filter=lfs diff=lfs merge=lfs -text
.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/.locks/models--Manmay--tortoise-tts/16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d.lock ADDED
File without changes
.models/.locks/models--Manmay--tortoise-tts/6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c.lock ADDED
File without changes
.models/.locks/models--Manmay--tortoise-tts/9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51.lock ADDED
File without changes
.models/.locks/models--Manmay--tortoise-tts/ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1.lock ADDED
File without changes
.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/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:ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1
3
+ size 1169472627
.models/models--Manmay--tortoise-tts/blobs/16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d
3
+ size 391384715
.models/models--Manmay--tortoise-tts/blobs/6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c
3
+ size 975620731
.models/models--Manmay--tortoise-tts/blobs/9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51
3
+ size 1716988501
.models/models--Manmay--tortoise-tts/blobs/ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea776fc354eabb70cfae145777153483fad72e3e0c5ea345505ded2231a90ce1
3
+ size 1169472627
.models/models--Manmay--tortoise-tts/refs/main ADDED
@@ -0,0 +1 @@
 
 
1
+ 50672670cecf2265aa61edb4eef5d1a293a8a373
.models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/autoregressive.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c6651b9996df6cef6a1fc459738ae207ab60f902ec49b4d0623ca8ab6110d51
3
+ size 1716988501
.models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/clvp2.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6097e708cf692eb93bd770880660953935e87e8995eb864819bbe51b7d91342c
3
+ size 975620731
.models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/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/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/vocoder.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16e8153e9f8ffb00b116f7f67833df2802fcf81e6bc173acc3b3b4bf9f04189d
3
+ size 391384715
.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,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ # Generated at 2026-01-29T20:36:13Z from templates/weights/README.md.j2
3
+ license: other
4
+ language:
5
+ - eng
6
+ tags:
7
+ - tts
8
+ - text-to-speech
9
+ - speech-synthesis
10
+ - voice-cloning
11
+ library_name: ttsdb
12
+ pipeline_tag: text-to-speech
13
+ base_model:
14
+ - jbetker/tortoise-tts-v2
15
+
16
+ ---
17
+
18
+ # TorToise
19
+
20
+ > **This is a mirror of the original weights for use with [TTSDB](https://github.com/ttsds/ttsdb).**
21
+ >
22
+ > Original weights: [https://huggingface.co/jbetker/tortoise-tts-v2](https://huggingface.co/jbetker/tortoise-tts-v2)
23
+ > Original code: [https://github.com/neonbjb/tortoise-tts.git](https://github.com/neonbjb/tortoise-tts.git)
24
+
25
+
26
+ Tortoise TTS voice cloning model.
27
+
28
+
29
+
30
+ ## Original Work
31
+
32
+ This model was created by the original authors. Please cite their work if you use this model:
33
+
34
+
35
+ ```bibtex
36
+ @misc{betker2023betterspeechsynthesisscaling,
37
+ title={Better speech synthesis through scaling},
38
+ author={James Betker},
39
+ year={2023},
40
+ eprint={2305.07243},
41
+ archivePrefix={arXiv},
42
+ primaryClass={cs.SD},
43
+ url={https://arxiv.org/abs/2305.07243},
44
+ }
45
+ ```
46
+
47
+
48
+
49
+ **Papers:**
50
+
51
+ - https://arxiv.org/abs/2305.07243
52
+
53
+
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install ttsdb-tortoise
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ ```python
64
+ from ttsdb_tortoise import TorToise
65
+
66
+ # Load the model (downloads weights automatically)
67
+ model = TorToise(model_id="ttsds/TorToise")
68
+
69
+ # Synthesize speech
70
+ audio, sample_rate = model.synthesize(
71
+ text="Hello, this is a test of TorToise.",
72
+ reference_audio="path/to/reference.wav",
73
+ text_reference="Transcript of the reference audio.",
74
+ language="en",
75
+ )
76
+
77
+ # Save the output
78
+ model.save_audio(audio, sample_rate, "output.wav")
79
+ ```
80
+
81
+ ## Model Details
82
+
83
+ | Property | Value |
84
+ |----------|-------|
85
+ | **Sample Rate** | 24000 Hz |
86
+ | **Parameters** | 960M |
87
+ | **Architecture** | Autoregressive, Diffusion, Language Modeling |
88
+ | **Languages** | English |
89
+ | **Release Date** | 2022-05-17 |
90
+
91
+
92
+ ### Training Data
93
+
94
+
95
+ - [LibriTTS](https://www.openslr.org/60/)
96
+
97
+
98
+ - [HifiTTS]()
99
+
100
+
101
+
102
+
103
+ ## License
104
+
105
+ - **Weights:** Other (see original repository)
106
+ - **Code:** Apache License 2.0
107
+
108
+ Please refer to the original repositories for full license terms.
109
+
110
+ ## Links
111
+
112
+ - **Original Code:** [https://github.com/neonbjb/tortoise-tts.git](https://github.com/neonbjb/tortoise-tts.git)
113
+ - **Original Weights:** [https://huggingface.co/jbetker/tortoise-tts-v2](https://huggingface.co/jbetker/tortoise-tts-v2)
114
+ - **TTSDB Package:** [ttsdb-tortoise](https://pypi.org/project/ttsdb-tortoise/)
115
+ - **TTSDB GitHub:** [https://github.com/ttsds/ttsdb](https://github.com/ttsds/ttsdb)
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]
checkpoints/tacotron_symbols/.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
checkpoints/tacotron_symbols/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
checkpoints/tacotron_symbols/special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>"}
checkpoints/tacotron_symbols/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "<pad>", "do_lower_case": false, "word_delimiter_token": "|", "tokenizer_class": "Wav2Vec2CTCTokenizer"}
checkpoints/tacotron_symbols/vocab.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"<s>": 148, "</s>": 149, "<unk>": 150, "<pad>": 0, "-": 1, "!": 2, "'": 3, "(": 4, ")": 5, ",": 6, ".": 7, ":": 8, ";": 9, "?": 10, "|": 11, "A": 12, "B": 13, "C": 14, "D": 15, "E": 16, "F": 17, "G": 18, "H": 19, "I": 20, "J": 21, "K": 22, "L": 23, "M": 24, "N": 25, "O": 26, "P": 27, "Q": 28, "R": 29, "S": 30, "T": 31, "U": 32, "V": 33, "W": 34, "X": 35, "Y": 36, "Z": 37, "a": 38, "b": 39, "c": 40, "d": 41, "e": 42, "f": 43, "g": 44, "h": 45, "i": 46, "j": 47, "k": 48, "l": 49, "m": 50, "n": 51, "o": 52, "p": 53, "q": 54, "r": 55, "s": 56, "t": 57, "u": 58, "v": 59, "w": 60, "x": 61, "y": 62, "z": 63, "@AA": 64, "@AA0": 65, "@AA1": 66, "@AA2": 67, "@AE": 68, "@AE0": 69, "@AE1": 70, "@AE2": 71, "@AH": 72, "@AH0": 73, "@AH1": 74, "@AH2": 75, "@AO": 76, "@AO0": 77, "@AO1": 78, "@AO2": 79, "@AW": 80, "@AW0": 81, "@AW1": 82, "@AW2": 83, "@AY": 84, "@AY0": 85, "@AY1": 86, "@AY2": 87, "@B": 88, "@CH": 89, "@D": 90, "@DH": 91, "@EH": 92, "@EH0": 93, "@EH1": 94, "@EH2": 95, "@ER": 96, "@ER0": 97, "@ER1": 98, "@ER2": 99, "@EY": 100, "@EY0": 101, "@EY1": 102, "@EY2": 103, "@F": 104, "@G": 105, "@HH": 106, "@IH": 107, "@IH0": 108, "@IH1": 109, "@IH2": 110, "@IY": 111, "@IY0": 112, "@IY1": 113, "@IY2": 114, "@JH": 115, "@K": 116, "@L": 117, "@M": 118, "@N": 119, "@NG": 120, "@OW": 121, "@OW0": 122, "@OW1": 123, "@OW2": 124, "@OY": 125, "@OY0": 126, "@OY1": 127, "@OY2": 128, "@P": 129, "@R": 130, "@S": 131, "@SH": 132, "@T": 133, "@TH": 134, "@UH": 135, "@UH0": 136, "@UH1": 137, "@UH2": 138, "@UW": 139, "@UW0": 140, "@UW1": 141, "@UW2": 142, "@V": 143, "@W": 144, "@Y": 145, "@Z": 146, "@ZH": 147}
checkpoints/wav2vec2-large-960h/.gitattributes ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.arrow filter=lfs diff=lfs merge=lfs -text
10
+ *.ftz filter=lfs diff=lfs merge=lfs -text
11
+ *.joblib filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.pb filter=lfs diff=lfs merge=lfs -text
15
+ *.pt filter=lfs diff=lfs merge=lfs -text
16
+ *.pth filter=lfs diff=lfs merge=lfs -text
17
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
checkpoints/wav2vec2-large-960h/README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - librispeech_asr
5
+ tags:
6
+ - speech
7
+
8
+ license: apache-2.0
9
+ ---
10
+
11
+ # Wav2Vec2-Large-960h
12
+
13
+ [Facebook's Wav2Vec2](https://ai.facebook.com/blog/wav2vec-20-learning-the-structure-of-speech-from-raw-audio/)
14
+
15
+ The large model pretrained and fine-tuned on 960 hours of Librispeech on 16kHz sampled speech audio. When using the model
16
+ make sure that your speech input is also sampled at 16Khz.
17
+
18
+ [Paper](https://arxiv.org/abs/2006.11477)
19
+
20
+ Authors: Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli
21
+
22
+ **Abstract**
23
+
24
+ We show for the first time that learning powerful representations from speech audio alone followed by fine-tuning on transcribed speech can outperform the best semi-supervised methods while being conceptually simpler. wav2vec 2.0 masks the speech input in the latent space and solves a contrastive task defined over a quantization of the latent representations which are jointly learned. Experiments using all labeled data of Librispeech achieve 1.8/3.3 WER on the clean/other test sets. When lowering the amount of labeled data to one hour, wav2vec 2.0 outperforms the previous state of the art on the 100 hour subset while using 100 times less labeled data. Using just ten minutes of labeled data and pre-training on 53k hours of unlabeled data still achieves 4.8/8.2 WER. This demonstrates the feasibility of speech recognition with limited amounts of labeled data.
25
+
26
+ The original model can be found under https://github.com/pytorch/fairseq/tree/master/examples/wav2vec#wav2vec-20.
27
+
28
+
29
+ # Usage
30
+
31
+ To transcribe audio files the model can be used as a standalone acoustic model as follows:
32
+
33
+ ```python
34
+ from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
35
+ from datasets import load_dataset
36
+ import torch
37
+
38
+ # load model and processor
39
+ processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-large-960h")
40
+ model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-large-960h")
41
+
42
+ # load dummy dataset and read soundfiles
43
+ ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
44
+
45
+ # tokenize
46
+ input_values = processor(ds[0]["audio"]["array"],, return_tensors="pt", padding="longest").input_values # Batch size 1
47
+
48
+ # retrieve logits
49
+ logits = model(input_values).logits
50
+
51
+ # take argmax and decode
52
+ predicted_ids = torch.argmax(logits, dim=-1)
53
+ transcription = processor.batch_decode(predicted_ids)
54
+ ```
55
+
56
+ ## Evaluation
57
+
58
+ This code snippet shows how to evaluate **facebook/wav2vec2-large-960h** on LibriSpeech's "clean" and "other" test data.
59
+
60
+ ```python
61
+ from datasets import load_dataset
62
+ from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
63
+ import soundfile as sf
64
+ import torch
65
+ from jiwer import wer
66
+
67
+
68
+ librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
69
+
70
+ model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-large-960h").to("cuda")
71
+ processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-large-960h")
72
+
73
+ def map_to_pred(batch):
74
+ input_values = processor(batch["audio"]["array"], return_tensors="pt", padding="longest").input_values
75
+ with torch.no_grad():
76
+ logits = model(input_values.to("cuda")).logits
77
+
78
+ predicted_ids = torch.argmax(logits, dim=-1)
79
+ transcription = processor.batch_decode(predicted_ids)
80
+ batch["transcription"] = transcription
81
+ return batch
82
+
83
+ result = librispeech_eval.map(map_to_pred, batched=True, batch_size=1, remove_columns=["speech"])
84
+
85
+ print("WER:", wer(result["text"], result["transcription"]))
86
+ ```
87
+
88
+ *Result (WER)*:
89
+
90
+ | "clean" | "other" |
91
+ |---|---|
92
+ | 2.8 | 6.3 |
checkpoints/wav2vec2-large-960h/config.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Wav2Vec2ForCTC"
4
+ ],
5
+ "conv_bias": false,
6
+ "conv_dim": [
7
+ 512,
8
+ 512,
9
+ 512,
10
+ 512,
11
+ 512,
12
+ 512,
13
+ 512
14
+ ],
15
+ "conv_kernel": [
16
+ 10,
17
+ 3,
18
+ 3,
19
+ 3,
20
+ 3,
21
+ 2,
22
+ 2
23
+ ],
24
+ "conv_stride": [
25
+ 5,
26
+ 2,
27
+ 2,
28
+ 2,
29
+ 2,
30
+ 2,
31
+ 2
32
+ ],
33
+ "do_stable_layer_norm": false,
34
+ "feat_extract_activation": "gelu",
35
+ "feat_extract_dropout": 0.0,
36
+ "feat_extract_norm": "group",
37
+ "hidden_act": "gelu",
38
+ "hidden_dropout_prob": 0.1,
39
+ "hidden_size": 1024,
40
+ "initializer_range": 0.02,
41
+ "intermediate_size": 4096,
42
+ "layer_norm_eps": 1e-05,
43
+ "model_type": "wav2vec2",
44
+ "num_attention_heads": 16,
45
+ "num_conv_pos_embedding_groups": 16,
46
+ "num_conv_pos_embeddings": 128,
47
+ "num_feat_extract_layers": 7,
48
+ "num_hidden_layers": 24,
49
+ "transformers_version": "4.3.0.dev0",
50
+ "vocab_size": 32
51
+ }
checkpoints/wav2vec2-large-960h/preprocessor_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "feature_size": 1,
4
+ "padding_side": "right",
5
+ "padding_value": 0.0,
6
+ "return_attention_mask": false,
7
+ "sampling_rate": 16000
8
+ }
checkpoints/wav2vec2-large-960h/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7aef99395c7b7ab5b78b6d00bdf71aebd93a7340b72d614303d598de8f94a10f
3
+ size 1262009187
checkpoints/wav2vec2-large-960h/special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>"}
checkpoints/wav2vec2-large-960h/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "<pad>", "do_lower_case": false, "return_attention_mask": false, "do_normalize": true}
checkpoints/wav2vec2-large-960h/vocab.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"<pad>": 0, "<s>": 1, "</s>": 2, "<unk>": 3, "|": 4, "E": 5, "T": 6, "A": 7, "O": 8, "N": 9, "I": 10, "H": 11, "S": 12, "R": 13, "D": 14, "L": 15, "U": 16, "M": 17, "W": 18, "C": 19, "F": 20, "G": 21, "Y": 22, "P": 23, "B": 24, "V": 25, "K": 26, "'": 27, "X": 28, "J": 29, "Q": 30, "Z": 31}
checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This checkpoint is a wav2vec2-large model that is useful for generating transcriptions with punctuation. It is intended for use in building transcriptions for TTS models, where punctuation is very important for prosody.
2
+
3
+ This model was created by fine-tuning the `facebook/wav2vec2-large-robust-ft-libri-960h` checkpoint on the [libritts](https://research.google/tools/datasets/libri-tts/) and [voxpopuli](https://github.com/facebookresearch/voxpopuli) datasets with a new vocabulary that includes punctuation.
4
+
5
+ The model gets a respectable WER of 4.45% on the librispeech validation set. The baseline, `facebook/wav2vec2-large-robust-ft-libri-960h`, got 4.3%.
6
+
7
+ Since the model was fine-tuned on clean audio, it is not well-suited for noisy audio like CommonVoice (though I may upload a checkpoint for that soon too). It still does pretty good, though.
8
+
9
+ The vocabulary is uploaded to the model hub as well `jbetker/tacotron_symbols`.
10
+
11
+ Check out my speech transcription script repo, [ocotillo](https://github.com/neonbjb/ocotillo) for usage examples: https://github.com/neonbjb/ocotillo
checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/config.json ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/wav2vec2-large-robust-ft-libri-960h",
3
+ "activation_dropout": 0.1,
4
+ "adapter_kernel_size": 3,
5
+ "adapter_stride": 2,
6
+ "add_adapter": false,
7
+ "apply_spec_augment": true,
8
+ "architectures": [
9
+ "Wav2Vec2ForCTC"
10
+ ],
11
+ "attention_dropout": 0.1,
12
+ "bos_token_id": 1,
13
+ "classifier_proj_size": 256,
14
+ "codevector_dim": 768,
15
+ "contrastive_logits_temperature": 0.1,
16
+ "conv_bias": true,
17
+ "conv_dim": [
18
+ 512,
19
+ 512,
20
+ 512,
21
+ 512,
22
+ 512,
23
+ 512,
24
+ 512
25
+ ],
26
+ "conv_kernel": [
27
+ 10,
28
+ 3,
29
+ 3,
30
+ 3,
31
+ 3,
32
+ 2,
33
+ 2
34
+ ],
35
+ "conv_stride": [
36
+ 5,
37
+ 2,
38
+ 2,
39
+ 2,
40
+ 2,
41
+ 2,
42
+ 2
43
+ ],
44
+ "ctc_loss_reduction": "sum",
45
+ "ctc_zero_infinity": false,
46
+ "diversity_loss_weight": 0.1,
47
+ "do_stable_layer_norm": true,
48
+ "eos_token_id": 2,
49
+ "feat_extract_activation": "gelu",
50
+ "feat_extract_dropout": 0.0,
51
+ "feat_extract_norm": "layer",
52
+ "feat_proj_dropout": 0.1,
53
+ "feat_quantizer_dropout": 0.0,
54
+ "final_dropout": 0.1,
55
+ "gradient_checkpointing": false,
56
+ "hidden_act": "gelu",
57
+ "hidden_dropout": 0.1,
58
+ "hidden_dropout_prob": 0.1,
59
+ "hidden_size": 1024,
60
+ "initializer_range": 0.02,
61
+ "intermediate_size": 4096,
62
+ "layer_norm_eps": 1e-05,
63
+ "layerdrop": 0.1,
64
+ "mask_feature_length": 10,
65
+ "mask_feature_min_masks": 0,
66
+ "mask_feature_prob": 0.0,
67
+ "mask_time_length": 10,
68
+ "mask_time_min_masks": 2,
69
+ "mask_time_prob": 0.05,
70
+ "model_type": "wav2vec2",
71
+ "num_adapter_layers": 3,
72
+ "num_attention_heads": 16,
73
+ "num_codevector_groups": 2,
74
+ "num_codevectors_per_group": 320,
75
+ "num_conv_pos_embedding_groups": 16,
76
+ "num_conv_pos_embeddings": 128,
77
+ "num_feat_extract_layers": 7,
78
+ "num_hidden_layers": 24,
79
+ "num_negatives": 100,
80
+ "output_hidden_size": 1024,
81
+ "pad_token_id": 0,
82
+ "proj_codevector_dim": 768,
83
+ "tdnn_dilation": [
84
+ 1,
85
+ 2,
86
+ 3,
87
+ 1,
88
+ 1
89
+ ],
90
+ "tdnn_dim": [
91
+ 512,
92
+ 512,
93
+ 512,
94
+ 512,
95
+ 1500
96
+ ],
97
+ "tdnn_kernel": [
98
+ 5,
99
+ 3,
100
+ 3,
101
+ 1,
102
+ 1
103
+ ],
104
+ "torch_dtype": "float32",
105
+ "transformers_version": "4.16.2",
106
+ "use_weighted_layer_sum": false,
107
+ "vocab_size": 148,
108
+ "xvector_output_dim": 512
109
+ }
checkpoints/wav2vec2-large-robust-ft-libritts-voxpopuli/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a537b517ac4ca198ab42be3edde720fddaff7df959b9e826daae185ccad54f09
3
+ size 1262524593
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
+