Update notebook
Browse files- tortoise_tts.ipynb +67 -37
tortoise_tts.ipynb
CHANGED
@@ -40,7 +40,8 @@
|
|
40 |
"source": [
|
41 |
"!git clone https://github.com/neonbjb/tortoise-tts.git\n",
|
42 |
"%cd tortoise-tts\n",
|
43 |
-
"!
|
|
|
44 |
]
|
45 |
},
|
46 |
{
|
@@ -54,8 +55,8 @@
|
|
54 |
"\n",
|
55 |
"import IPython\n",
|
56 |
"\n",
|
57 |
-
"from api import TextToSpeech\n",
|
58 |
-
"from utils.audio import load_audio,
|
59 |
"\n",
|
60 |
"# This will download all the models used by Tortoise from the HF hub.\n",
|
61 |
"tts = TextToSpeech()"
|
@@ -66,20 +67,6 @@
|
|
66 |
"execution_count": null,
|
67 |
"outputs": []
|
68 |
},
|
69 |
-
{
|
70 |
-
"cell_type": "code",
|
71 |
-
"source": [
|
72 |
-
"# List all the voices available. These are just some random clips I've gathered\n",
|
73 |
-
"# from the internet as well as a few voices from the training dataset.\n",
|
74 |
-
"# Feel free to add your own clips to the voices/ folder.\n",
|
75 |
-
"%ls voices"
|
76 |
-
],
|
77 |
-
"metadata": {
|
78 |
-
"id": "SSleVnRAiEE2"
|
79 |
-
},
|
80 |
-
"execution_count": null,
|
81 |
-
"outputs": []
|
82 |
-
},
|
83 |
{
|
84 |
"cell_type": "code",
|
85 |
"source": [
|
@@ -94,8 +81,6 @@
|
|
94 |
"Though as for that the passing there\n",
|
95 |
"Had worn them really about the same,\"\"\"\n",
|
96 |
"\n",
|
97 |
-
"# Pick one of the voices from above\n",
|
98 |
-
"voice = 'train_dotrice'\n",
|
99 |
"# Pick a \"preset mode\" to determine quality. Options: {\"ultra_fast\", \"fast\" (default), \"standard\", \"high_quality\"}. See docs in api.py\n",
|
100 |
"preset = \"fast\""
|
101 |
],
|
@@ -108,15 +93,32 @@
|
|
108 |
{
|
109 |
"cell_type": "code",
|
110 |
"source": [
|
111 |
-
"#
|
112 |
-
"voices
|
113 |
-
"
|
114 |
-
"
|
115 |
-
"
|
116 |
-
"
|
117 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
"\n",
|
119 |
-
"
|
|
|
|
|
|
|
120 |
"torchaudio.save('generated.wav', gen.squeeze(0).cpu(), 24000)\n",
|
121 |
"IPython.display.Audio('generated.wav')"
|
122 |
],
|
@@ -129,19 +131,29 @@
|
|
129 |
{
|
130 |
"cell_type": "code",
|
131 |
"source": [
|
132 |
-
"#
|
133 |
-
"#
|
134 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
"#\n",
|
136 |
"# Lets see what it would sound like if Picard and Kirk had a kid with a penchant for philosophy:\n",
|
137 |
-
"
|
138 |
-
"for v in ['pat', 'william']:\n",
|
139 |
-
" cond_paths = voices[v]\n",
|
140 |
-
" for cond_path in cond_paths:\n",
|
141 |
-
" c = load_audio(cond_path, 22050)\n",
|
142 |
-
" conds.append(c)\n",
|
143 |
"\n",
|
144 |
-
"gen = tts.tts_with_preset(\"They used to say that if man was meant to fly, he’d have wings. But he did fly. He discovered he had to.\",
|
|
|
145 |
"torchaudio.save('captain_kirkard.wav', gen.squeeze(0).cpu(), 24000)\n",
|
146 |
"IPython.display.Audio('captain_kirkard.wav')"
|
147 |
],
|
@@ -150,6 +162,24 @@
|
|
150 |
},
|
151 |
"execution_count": null,
|
152 |
"outputs": []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
]
|
155 |
}
|
|
|
40 |
"source": [
|
41 |
"!git clone https://github.com/neonbjb/tortoise-tts.git\n",
|
42 |
"%cd tortoise-tts\n",
|
43 |
+
"!pip3 install -r requirements.txt\n",
|
44 |
+
"!python3 setup.py install"
|
45 |
]
|
46 |
},
|
47 |
{
|
|
|
55 |
"\n",
|
56 |
"import IPython\n",
|
57 |
"\n",
|
58 |
+
"from tortoise.api import TextToSpeech\n",
|
59 |
+
"from tortoise.utils.audio import load_audio, load_voice, load_voices\n",
|
60 |
"\n",
|
61 |
"# This will download all the models used by Tortoise from the HF hub.\n",
|
62 |
"tts = TextToSpeech()"
|
|
|
67 |
"execution_count": null,
|
68 |
"outputs": []
|
69 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
{
|
71 |
"cell_type": "code",
|
72 |
"source": [
|
|
|
81 |
"Though as for that the passing there\n",
|
82 |
"Had worn them really about the same,\"\"\"\n",
|
83 |
"\n",
|
|
|
|
|
84 |
"# Pick a \"preset mode\" to determine quality. Options: {\"ultra_fast\", \"fast\" (default), \"standard\", \"high_quality\"}. See docs in api.py\n",
|
85 |
"preset = \"fast\""
|
86 |
],
|
|
|
93 |
{
|
94 |
"cell_type": "code",
|
95 |
"source": [
|
96 |
+
"# Tortoise will attempt to mimic voices you provide. It comes pre-packaged\n",
|
97 |
+
"# with some voices you might recognize.\n",
|
98 |
+
"\n",
|
99 |
+
"# Let's list all the voices available. These are just some random clips I've gathered\n",
|
100 |
+
"# from the internet as well as a few voices from the training dataset.\n",
|
101 |
+
"# Feel free to add your own clips to the voices/ folder.\n",
|
102 |
+
"%ls tortoise/voices\n",
|
103 |
+
"\n",
|
104 |
+
"IPython.display.Audio('tortoise/voices/tom/1.wav')"
|
105 |
+
],
|
106 |
+
"metadata": {
|
107 |
+
"id": "SSleVnRAiEE2"
|
108 |
+
},
|
109 |
+
"execution_count": null,
|
110 |
+
"outputs": []
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"cell_type": "code",
|
114 |
+
"source": [
|
115 |
+
"# Pick one of the voices from the output above\n",
|
116 |
+
"voice = 'tom'\n",
|
117 |
"\n",
|
118 |
+
"# Load it and send it through Tortoise.\n",
|
119 |
+
"voice_samples, conditioning_latents = load_voice(voice)\n",
|
120 |
+
"gen = tts.tts_with_preset(text, voice_samples=voice_samples, conditioning_latents=conditioning_latents, \n",
|
121 |
+
" preset=preset)\n",
|
122 |
"torchaudio.save('generated.wav', gen.squeeze(0).cpu(), 24000)\n",
|
123 |
"IPython.display.Audio('generated.wav')"
|
124 |
],
|
|
|
131 |
{
|
132 |
"cell_type": "code",
|
133 |
"source": [
|
134 |
+
"# Tortoise can also generate speech using a random voice. The voice changes each time you execute this!\n",
|
135 |
+
"# (Note: random voices can be prone to strange utterances)\n",
|
136 |
+
"gen = tts.tts_with_preset(text, voice_samples=None, conditioning_latents=None, preset=preset)\n",
|
137 |
+
"torchaudio.save('generated.wav', gen.squeeze(0).cpu(), 24000)\n",
|
138 |
+
"IPython.display.Audio('generated.wav')"
|
139 |
+
],
|
140 |
+
"metadata": {
|
141 |
+
"id": "16Xs2SSC3BXa"
|
142 |
+
},
|
143 |
+
"execution_count": null,
|
144 |
+
"outputs": []
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"cell_type": "code",
|
148 |
+
"source": [
|
149 |
+
"# You can also combine conditioning voices. Combining voices produces a new voice\n",
|
150 |
+
"# with traits from all the parents.\n",
|
151 |
"#\n",
|
152 |
"# Lets see what it would sound like if Picard and Kirk had a kid with a penchant for philosophy:\n",
|
153 |
+
"voice_samples, conditioning_latents = load_voices(['pat', 'william'])\n",
|
|
|
|
|
|
|
|
|
|
|
154 |
"\n",
|
155 |
+
"gen = tts.tts_with_preset(\"They used to say that if man was meant to fly, he’d have wings. But he did fly. He discovered he had to.\", \n",
|
156 |
+
" voice_samples=None, conditioning_latents=None, preset=preset)\n",
|
157 |
"torchaudio.save('captain_kirkard.wav', gen.squeeze(0).cpu(), 24000)\n",
|
158 |
"IPython.display.Audio('captain_kirkard.wav')"
|
159 |
],
|
|
|
162 |
},
|
163 |
"execution_count": null,
|
164 |
"outputs": []
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"cell_type": "code",
|
168 |
+
"source": [
|
169 |
+
"del tts # Will break other cells, but necessary to conserve RAM if you want to run this cell.\n",
|
170 |
+
"\n",
|
171 |
+
"# Tortoise comes with some scripts that does a lot of the lifting for you. For example,\n",
|
172 |
+
"# read.py will read a text file for you.\n",
|
173 |
+
"!python3 tortoise/read.py --voice=train_atkins --textfile=tortoise/data/riding_hood.txt --preset=ultra_fast --output_path=.\n",
|
174 |
+
"\n",
|
175 |
+
"IPython.display.Audio('train_atkins/combined.wav')\n",
|
176 |
+
"# This will take awhile.."
|
177 |
+
],
|
178 |
+
"metadata": {
|
179 |
+
"id": "t66yqWgu68KL"
|
180 |
+
},
|
181 |
+
"execution_count": null,
|
182 |
+
"outputs": []
|
183 |
}
|
184 |
]
|
185 |
}
|