Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- LICENSE +333 -0
- app.py +164 -0
- requirements.txt +41 -0
LICENSE
ADDED
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Creative Commons Attribution-NonCommercial 4.0 International Public
|
2 |
+
License
|
3 |
+
|
4 |
+
By exercising the Licensed Rights (defined below), You accept and agree
|
5 |
+
to be bound by the terms and conditions of this Creative Commons
|
6 |
+
Attribution-NonCommercial 4.0 International Public License ("Public
|
7 |
+
License"). To the extent this Public License may be interpreted as a
|
8 |
+
contract, You are granted the Licensed Rights in consideration of Your
|
9 |
+
acceptance of these terms and conditions, and the Licensor grants You
|
10 |
+
such rights in consideration of benefits the Licensor receives from
|
11 |
+
making the Licensed Material available under these terms and
|
12 |
+
conditions.
|
13 |
+
|
14 |
+
|
15 |
+
Section 1 -- Definitions.
|
16 |
+
|
17 |
+
a. Adapted Material means material subject to Copyright and Similar
|
18 |
+
Rights that is derived from or based upon the Licensed Material
|
19 |
+
and in which the Licensed Material is translated, altered,
|
20 |
+
arranged, transformed, or otherwise modified in a manner requiring
|
21 |
+
permission under the Copyright and Similar Rights held by the
|
22 |
+
Licensor. For purposes of this Public License, where the Licensed
|
23 |
+
Material is a musical work, performance, or sound recording,
|
24 |
+
Adapted Material is always produced where the Licensed Material is
|
25 |
+
synched in timed relation with a moving image.
|
26 |
+
|
27 |
+
b. Adapter's License means the license You apply to Your Copyright
|
28 |
+
and Similar Rights in Your contributions to Adapted Material in
|
29 |
+
accordance with the terms and conditions of this Public License.
|
30 |
+
|
31 |
+
c. Copyright and Similar Rights means copyright and/or similar rights
|
32 |
+
closely related to copyright including, without limitation,
|
33 |
+
performance, broadcast, sound recording, and Sui Generis Database
|
34 |
+
Rights, without regard to how the rights are labeled or
|
35 |
+
categorized. For purposes of this Public License, the rights
|
36 |
+
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
37 |
+
Rights.
|
38 |
+
d. Effective Technological Measures means those measures that, in the
|
39 |
+
absence of proper authority, may not be circumvented under laws
|
40 |
+
fulfilling obligations under Article 11 of the WIPO Copyright
|
41 |
+
Treaty adopted on December 20, 1996, and/or similar international
|
42 |
+
agreements.
|
43 |
+
|
44 |
+
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
45 |
+
any other exception or limitation to Copyright and Similar Rights
|
46 |
+
that applies to Your use of the Licensed Material.
|
47 |
+
|
48 |
+
f. Licensed Material means the artistic or literary work, database,
|
49 |
+
or other material to which the Licensor applied this Public
|
50 |
+
License.
|
51 |
+
|
52 |
+
g. Licensed Rights means the rights granted to You subject to the
|
53 |
+
terms and conditions of this Public License, which are limited to
|
54 |
+
all Copyright and Similar Rights that apply to Your use of the
|
55 |
+
Licensed Material and that the Licensor has authority to license.
|
56 |
+
|
57 |
+
h. Licensor means the individual(s) or entity(ies) granting rights
|
58 |
+
under this Public License.
|
59 |
+
|
60 |
+
i. NonCommercial means not primarily intended for or directed towards
|
61 |
+
commercial advantage or monetary compensation. For purposes of
|
62 |
+
this Public License, the exchange of the Licensed Material for
|
63 |
+
other material subject to Copyright and Similar Rights by digital
|
64 |
+
file-sharing or similar means is NonCommercial provided there is
|
65 |
+
no payment of monetary compensation in connection with the
|
66 |
+
exchange.
|
67 |
+
|
68 |
+
j. Share means to provide material to the public by any means or
|
69 |
+
process that requires permission under the Licensed Rights, such
|
70 |
+
as reproduction, public display, public performance, distribution,
|
71 |
+
dissemination, communication, or importation, and to make material
|
72 |
+
available to the public including in ways that members of the
|
73 |
+
public may access the material from a place and at a time
|
74 |
+
individually chosen by them.
|
75 |
+
|
76 |
+
k. Sui Generis Database Rights means rights other than copyright
|
77 |
+
resulting from Directive 96/9/EC of the European Parliament and of
|
78 |
+
the Council of 11 March 1996 on the legal protection of databases,
|
79 |
+
as amended and/or succeeded, as well as other essentially
|
80 |
+
equivalent rights anywhere in the world.
|
81 |
+
|
82 |
+
l. You means the individual or entity exercising the Licensed Rights
|
83 |
+
under this Public License. Your has a corresponding meaning.
|
84 |
+
|
85 |
+
|
86 |
+
Section 2 -- Scope.
|
87 |
+
|
88 |
+
a. License grant.
|
89 |
+
|
90 |
+
1. Subject to the terms and conditions of this Public License,
|
91 |
+
the Licensor hereby grants You a worldwide, royalty-free,
|
92 |
+
non-sublicensable, non-exclusive, irrevocable license to
|
93 |
+
exercise the Licensed Rights in the Licensed Material to:
|
94 |
+
|
95 |
+
a. reproduce and Share the Licensed Material, in whole or
|
96 |
+
in part, for NonCommercial purposes only; and
|
97 |
+
|
98 |
+
b. produce, reproduce, and Share Adapted Material for
|
99 |
+
NonCommercial purposes only.
|
100 |
+
|
101 |
+
2. Exceptions and Limitations. For the avoidance of doubt, where
|
102 |
+
Exceptions and Limitations apply to Your use, this Public
|
103 |
+
License does not apply, and You do not need to comply with
|
104 |
+
its terms and conditions.
|
105 |
+
|
106 |
+
3. Term. The term of this Public License is specified in Section
|
107 |
+
6(a).
|
108 |
+
|
109 |
+
4. Media and formats; technical modifications allowed. The
|
110 |
+
Licensor authorizes You to exercise the Licensed Rights in
|
111 |
+
all media and formats whether now known or hereafter created,
|
112 |
+
and to make technical modifications necessary to do so. The
|
113 |
+
Licensor waives and/or agrees not to assert any right or
|
114 |
+
authority to forbid You from making technical modifications
|
115 |
+
necessary to exercise the Licensed Rights, including
|
116 |
+
technical modifications necessary to circumvent Effective
|
117 |
+
Technological Measures. For purposes of this Public License,
|
118 |
+
simply making modifications authorized by this Section 2(a)
|
119 |
+
(4) never produces Adapted Material.
|
120 |
+
|
121 |
+
5. Downstream recipients.
|
122 |
+
|
123 |
+
a. Offer from the Licensor -- Licensed Material. Every
|
124 |
+
recipient of the Licensed Material automatically
|
125 |
+
receives an offer from the Licensor to exercise the
|
126 |
+
Licensed Rights under the terms and conditions of this
|
127 |
+
Public License.
|
128 |
+
|
129 |
+
b. No downstream restrictions. You may not offer or impose
|
130 |
+
any additional or different terms or conditions on, or
|
131 |
+
apply any Effective Technological Measures to, the
|
132 |
+
Licensed Material if doing so restricts exercise of the
|
133 |
+
Licensed Rights by any recipient of the Licensed
|
134 |
+
Material.
|
135 |
+
|
136 |
+
6. No endorsement. Nothing in this Public License constitutes or
|
137 |
+
may be construed as permission to assert or imply that You
|
138 |
+
are, or that Your use of the Licensed Material is, connected
|
139 |
+
with, or sponsored, endorsed, or granted official status by,
|
140 |
+
the Licensor or others designated to receive attribution as
|
141 |
+
provided in Section 3(a)(1)(A)(i).
|
142 |
+
|
143 |
+
b. Other rights.
|
144 |
+
|
145 |
+
1. Moral rights, such as the right of integrity, are not
|
146 |
+
licensed under this Public License, nor are publicity,
|
147 |
+
privacy, and/or other similar personality rights; however, to
|
148 |
+
the extent possible, the Licensor waives and/or agrees not to
|
149 |
+
assert any such rights held by the Licensor to the limited
|
150 |
+
extent necessary to allow You to exercise the Licensed
|
151 |
+
Rights, but not otherwise.
|
152 |
+
|
153 |
+
2. Patent and trademark rights are not licensed under this
|
154 |
+
Public License.
|
155 |
+
|
156 |
+
3. To the extent possible, the Licensor waives any right to
|
157 |
+
collect royalties from You for the exercise of the Licensed
|
158 |
+
Rights, whether directly or through a collecting society
|
159 |
+
under any voluntary or waivable statutory or compulsory
|
160 |
+
licensing scheme. In all other cases the Licensor expressly
|
161 |
+
reserves any right to collect such royalties, including when
|
162 |
+
the Licensed Material is used other than for NonCommercial
|
163 |
+
purposes.
|
164 |
+
|
165 |
+
|
166 |
+
Section 3 -- License Conditions.
|
167 |
+
|
168 |
+
Your exercise of the Licensed Rights is expressly made subject to the
|
169 |
+
following conditions.
|
170 |
+
|
171 |
+
a. Attribution.
|
172 |
+
|
173 |
+
1. If You Share the Licensed Material (including in modified
|
174 |
+
form), You must:
|
175 |
+
|
176 |
+
a. retain the following if it is supplied by the Licensor
|
177 |
+
with the Licensed Material:
|
178 |
+
|
179 |
+
i. identification of the creator(s) of the Licensed
|
180 |
+
Material and any others designated to receive
|
181 |
+
attribution, in any reasonable manner requested by
|
182 |
+
the Licensor (including by pseudonym if
|
183 |
+
designated);
|
184 |
+
|
185 |
+
ii. a copyright notice;
|
186 |
+
|
187 |
+
iii. a notice that refers to this Public License;
|
188 |
+
|
189 |
+
iv. a notice that refers to the disclaimer of
|
190 |
+
warranties;
|
191 |
+
|
192 |
+
v. a URI or hyperlink to the Licensed Material to the
|
193 |
+
extent reasonably practicable;
|
194 |
+
|
195 |
+
b. indicate if You modified the Licensed Material and
|
196 |
+
retain an indication of any previous modifications; and
|
197 |
+
|
198 |
+
c. indicate the Licensed Material is licensed under this
|
199 |
+
Public License, and include the text of, or the URI or
|
200 |
+
hyperlink to, this Public License.
|
201 |
+
|
202 |
+
2. You may satisfy the conditions in Section 3(a)(1) in any
|
203 |
+
reasonable manner based on the medium, means, and context in
|
204 |
+
which You Share the Licensed Material. For example, it may be
|
205 |
+
reasonable to satisfy the conditions by providing a URI or
|
206 |
+
hyperlink to a resource that includes the required
|
207 |
+
information.
|
208 |
+
|
209 |
+
3. If requested by the Licensor, You must remove any of the
|
210 |
+
information required by Section 3(a)(1)(A) to the extent
|
211 |
+
reasonably practicable.
|
212 |
+
|
213 |
+
4. If You Share Adapted Material You produce, the Adapter's
|
214 |
+
License You apply must not prevent recipients of the Adapted
|
215 |
+
Material from complying with this Public License.
|
216 |
+
|
217 |
+
|
218 |
+
Section 4 -- Sui Generis Database Rights.
|
219 |
+
|
220 |
+
Where the Licensed Rights include Sui Generis Database Rights that
|
221 |
+
apply to Your use of the Licensed Material:
|
222 |
+
|
223 |
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
224 |
+
to extract, reuse, reproduce, and Share all or a substantial
|
225 |
+
portion of the contents of the database for NonCommercial purposes
|
226 |
+
only;
|
227 |
+
|
228 |
+
b. if You include all or a substantial portion of the database
|
229 |
+
contents in a database in which You have Sui Generis Database
|
230 |
+
Rights, then the database in which You have Sui Generis Database
|
231 |
+
Rights (but not its individual contents) is Adapted Material; and
|
232 |
+
|
233 |
+
c. You must comply with the conditions in Section 3(a) if You Share
|
234 |
+
all or a substantial portion of the contents of the database.
|
235 |
+
|
236 |
+
For the avoidance of doubt, this Section 4 supplements and does not
|
237 |
+
replace Your obligations under this Public License where the Licensed
|
238 |
+
Rights include other Copyright and Similar Rights.
|
239 |
+
|
240 |
+
|
241 |
+
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
242 |
+
|
243 |
+
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
244 |
+
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
245 |
+
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
246 |
+
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
247 |
+
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
248 |
+
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
249 |
+
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
250 |
+
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
251 |
+
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
252 |
+
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
253 |
+
|
254 |
+
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
255 |
+
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
256 |
+
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
257 |
+
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
258 |
+
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
259 |
+
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
260 |
+
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
261 |
+
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
262 |
+
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
263 |
+
|
264 |
+
c. The disclaimer of warranties and limitation of liability provided
|
265 |
+
above shall be interpreted in a manner that, to the extent
|
266 |
+
possible, most closely approximates an absolute disclaimer and
|
267 |
+
waiver of all liability.
|
268 |
+
|
269 |
+
|
270 |
+
Section 6 -- Term and Termination.
|
271 |
+
|
272 |
+
a. This Public License applies for the term of the Copyright and
|
273 |
+
Similar Rights licensed here. However, if You fail to comply with
|
274 |
+
this Public License, then Your rights under this Public License
|
275 |
+
terminate automatically.
|
276 |
+
|
277 |
+
b. Where Your right to use the Licensed Material has terminated under
|
278 |
+
Section 6(a), it reinstates:
|
279 |
+
|
280 |
+
1. automatically as of the date the violation is cured, provided
|
281 |
+
it is cured within 30 days of Your discovery of the
|
282 |
+
violation; or
|
283 |
+
|
284 |
+
2. upon express reinstatement by the Licensor.
|
285 |
+
|
286 |
+
For the avoidance of doubt, this Section 6(b) does not affect any
|
287 |
+
right the Licensor may have to seek remedies for Your violations
|
288 |
+
of this Public License.
|
289 |
+
|
290 |
+
c. For the avoidance of doubt, the Licensor may also offer the
|
291 |
+
Licensed Material under separate terms or conditions or stop
|
292 |
+
distributing the Licensed Material at any time; however, doing so
|
293 |
+
will not terminate this Public License.
|
294 |
+
|
295 |
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
296 |
+
License.
|
297 |
+
|
298 |
+
|
299 |
+
Section 7 -- Other Terms and Conditions.
|
300 |
+
|
301 |
+
a. The Licensor shall not be bound by any additional or different
|
302 |
+
terms or conditions communicated by You unless expressly agreed.
|
303 |
+
|
304 |
+
b. Any arrangements, understandings, or agreements regarding the
|
305 |
+
Licensed Material not stated herein are separate from and
|
306 |
+
independent of the terms and conditions of this Public License.
|
307 |
+
|
308 |
+
|
309 |
+
Section 8 -- Interpretation.
|
310 |
+
|
311 |
+
a. For the avoidance of doubt, this Public License does not, and
|
312 |
+
shall not be interpreted to, reduce, limit, restrict, or impose
|
313 |
+
conditions on any use of the Licensed Material that could lawfully
|
314 |
+
be made without permission under this Public License.
|
315 |
+
|
316 |
+
b. To the extent possible, if any provision of this Public License is
|
317 |
+
deemed unenforceable, it shall be automatically reformed to the
|
318 |
+
minimum extent necessary to make it enforceable. If the provision
|
319 |
+
cannot be reformed, it shall be severed from this Public License
|
320 |
+
without affecting the enforceability of the remaining terms and
|
321 |
+
conditions.
|
322 |
+
|
323 |
+
c. No term or condition of this Public License will be waived and no
|
324 |
+
failure to comply consented to unless expressly agreed to by the
|
325 |
+
Licensor.
|
326 |
+
|
327 |
+
d. Nothing in this Public License constitutes or may be interpreted
|
328 |
+
as a limitation upon, or waiver of, any privileges and immunities
|
329 |
+
that apply to the Licensor or You, including from the legal
|
330 |
+
processes of any jurisdiction or authority.
|
331 |
+
|
332 |
+
=======================================================================
|
333 |
+
|
app.py
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import spaces
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
import argparse
|
5 |
+
|
6 |
+
import torch
|
7 |
+
import gradio as gr
|
8 |
+
import numpy as np
|
9 |
+
|
10 |
+
import ChatTTS
|
11 |
+
|
12 |
+
import se_extractor
|
13 |
+
from api import ToneColorConverter
|
14 |
+
import soundfile
|
15 |
+
|
16 |
+
print("loading ChatTTS model...")
|
17 |
+
chat = ChatTTS.Chat()
|
18 |
+
chat.load_models()
|
19 |
+
|
20 |
+
|
21 |
+
def generate_seed():
|
22 |
+
new_seed = random.randint(1, 100000000)
|
23 |
+
return {
|
24 |
+
"__type__": "update",
|
25 |
+
"value": new_seed
|
26 |
+
}
|
27 |
+
|
28 |
+
@spaces.GPU
|
29 |
+
def chat_tts(text, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input, output_path=None):
|
30 |
+
|
31 |
+
torch.manual_seed(audio_seed_input)
|
32 |
+
rand_spk = torch.randn(768)
|
33 |
+
params_infer_code = {
|
34 |
+
'spk_emb': rand_spk,
|
35 |
+
'temperature': temperature,
|
36 |
+
'top_P': top_P,
|
37 |
+
'top_K': top_K,
|
38 |
+
}
|
39 |
+
params_refine_text = {'prompt': '[oral_2][laugh_0][break_6]'}
|
40 |
+
|
41 |
+
torch.manual_seed(text_seed_input)
|
42 |
+
|
43 |
+
if refine_text_flag:
|
44 |
+
if refine_text_input:
|
45 |
+
params_refine_text['prompt'] = refine_text_input
|
46 |
+
text = chat.infer(text,
|
47 |
+
skip_refine_text=False,
|
48 |
+
refine_text_only=True,
|
49 |
+
params_refine_text=params_refine_text,
|
50 |
+
params_infer_code=params_infer_code
|
51 |
+
)
|
52 |
+
print("Text has been refined!")
|
53 |
+
|
54 |
+
wav = chat.infer(text,
|
55 |
+
skip_refine_text=True,
|
56 |
+
params_refine_text=params_refine_text,
|
57 |
+
params_infer_code=params_infer_code
|
58 |
+
)
|
59 |
+
|
60 |
+
audio_data = np.array(wav[0]).flatten()
|
61 |
+
sample_rate = 22050
|
62 |
+
text_data = text[0] if isinstance(text, list) else text
|
63 |
+
|
64 |
+
if output_path is None:
|
65 |
+
return [(sample_rate, audio_data), text_data]
|
66 |
+
else:
|
67 |
+
soundfile.write(output_path, audio_data, sample_rate)
|
68 |
+
return text_data
|
69 |
+
|
70 |
+
# OpenVoice Clone
|
71 |
+
ckpt_converter_en = 'checkpoints/converter'
|
72 |
+
device = 'cuda:0'
|
73 |
+
|
74 |
+
#device = "cpu"
|
75 |
+
|
76 |
+
tone_color_converter = ToneColorConverter(f'{ckpt_converter_en}/config.json', device=device)
|
77 |
+
tone_color_converter.load_ckpt(f'{ckpt_converter_en}/checkpoint.pth')
|
78 |
+
|
79 |
+
|
80 |
+
def generate_audio(text, audio_ref, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input):
|
81 |
+
save_path = "output.wav"
|
82 |
+
|
83 |
+
if audio_ref is not None:
|
84 |
+
# Run the base speaker tts
|
85 |
+
src_path = "tmp.wav"
|
86 |
+
text_data = chat_tts(text, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input, src_path)
|
87 |
+
print("Ready for voice cloning!")
|
88 |
+
|
89 |
+
source_se, audio_name = se_extractor.get_se(src_path, tone_color_converter, target_dir='processed', vad=True)
|
90 |
+
reference_speaker = audio_ref
|
91 |
+
target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, target_dir='processed', vad=True)
|
92 |
+
|
93 |
+
print("Get voices segment!")
|
94 |
+
|
95 |
+
# Run the tone color converter
|
96 |
+
encode_message = "@Hilley"
|
97 |
+
# convert from file
|
98 |
+
tone_color_converter.convert(
|
99 |
+
audio_src_path=src_path,
|
100 |
+
src_se=source_se,
|
101 |
+
tgt_se=target_se,
|
102 |
+
output_path=save_path,
|
103 |
+
message=encode_message)
|
104 |
+
else:
|
105 |
+
chat_tts(text, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input, save_path)
|
106 |
+
|
107 |
+
print("Finished!")
|
108 |
+
|
109 |
+
return [save_path, text_data]
|
110 |
+
|
111 |
+
|
112 |
+
with gr.Blocks() as demo:
|
113 |
+
gr.Markdown("# Enjoy chatting with your ai friends on website, telegram and so on! (https://linkin.love)")
|
114 |
+
|
115 |
+
default_text = "Today a man knocked on my door and asked for a small donation toward the local swimming pool. I gave him a glass of water."
|
116 |
+
text_input = gr.Textbox(label="Input Text", lines=4, placeholder="Please Input Text...", value=default_text)
|
117 |
+
|
118 |
+
|
119 |
+
default_refine_text = "[oral_2][laugh_0][break_6]"
|
120 |
+
refine_text_checkbox = gr.Checkbox(label="Refine text:'oral' means add filler words, 'laugh' means add laughter, and 'break' means add a pause. (0-10) ", value=True)
|
121 |
+
refine_text_input = gr.Textbox(label="Refine Prompt", lines=1, placeholder="Please Refine Prompt...", value=default_refine_text)
|
122 |
+
with gr.Column():
|
123 |
+
voice_ref = gr.Audio(label="请上传您喜欢的语音文件", type="filepath", value="")
|
124 |
+
|
125 |
+
with gr.Row():
|
126 |
+
temperature_slider = gr.Slider(minimum=0.00001, maximum=1.0, step=0.00001, value=0.3, label="Audio temperature")
|
127 |
+
top_p_slider = gr.Slider(minimum=0.1, maximum=0.9, step=0.05, value=0.7, label="top_P")
|
128 |
+
top_k_slider = gr.Slider(minimum=1, maximum=20, step=1, value=20, label="top_K")
|
129 |
+
|
130 |
+
with gr.Row():
|
131 |
+
audio_seed_input = gr.Number(value=42, label="Speaker Seed")
|
132 |
+
generate_audio_seed = gr.Button("\U0001F3B2")
|
133 |
+
text_seed_input = gr.Number(value=42, label="Text Seed")
|
134 |
+
generate_text_seed = gr.Button("\U0001F3B2")
|
135 |
+
|
136 |
+
generate_button = gr.Button("Generate")
|
137 |
+
|
138 |
+
text_output = gr.Textbox(label="Refined Text", interactive=False)
|
139 |
+
audio_output = gr.Audio(label="Output Audio")
|
140 |
+
|
141 |
+
generate_audio_seed.click(generate_seed,
|
142 |
+
inputs=[],
|
143 |
+
outputs=audio_seed_input)
|
144 |
+
|
145 |
+
generate_text_seed.click(generate_seed,
|
146 |
+
inputs=[],
|
147 |
+
outputs=text_seed_input)
|
148 |
+
|
149 |
+
generate_button.click(generate_audio,
|
150 |
+
inputs=[text_input, voice_ref, temperature_slider, top_p_slider, top_k_slider, audio_seed_input, text_seed_input, refine_text_checkbox, refine_text_input],
|
151 |
+
outputs=[audio_output,text_output])
|
152 |
+
|
153 |
+
parser = argparse.ArgumentParser(description='ChatTTS demo Launch')
|
154 |
+
parser.add_argument('--server_name', type=str, default='0.0.0.0', help='Server name')
|
155 |
+
parser.add_argument('--server_port', type=int, default=8080, help='Server port')
|
156 |
+
args = parser.parse_args()
|
157 |
+
|
158 |
+
# demo.launch(server_name=args.server_name, server_port=args.server_port, inbrowser=True)
|
159 |
+
|
160 |
+
|
161 |
+
|
162 |
+
|
163 |
+
if __name__ == '__main__':
|
164 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# PyTorch and related libraries
|
2 |
+
torch
|
3 |
+
torchvision
|
4 |
+
torchaudio
|
5 |
+
|
6 |
+
# Hugging Face transformers library
|
7 |
+
transformers
|
8 |
+
|
9 |
+
# Configuration management with OmegaConf
|
10 |
+
omegaconf
|
11 |
+
|
12 |
+
# Interactive widgets for Jupyter Notebooks
|
13 |
+
ipywidgets
|
14 |
+
|
15 |
+
# Gradio for creating web UIs
|
16 |
+
gradio
|
17 |
+
|
18 |
+
# Vector quantization for PyTorch
|
19 |
+
vector_quantize_pytorch
|
20 |
+
|
21 |
+
# Hugging Face Hub client
|
22 |
+
huggingface_hub
|
23 |
+
|
24 |
+
vocos
|
25 |
+
|
26 |
+
# OpenVoice
|
27 |
+
librosa
|
28 |
+
faster-whisper
|
29 |
+
pydub
|
30 |
+
wavmark
|
31 |
+
numpy
|
32 |
+
eng_to_ipa
|
33 |
+
inflect
|
34 |
+
unidecode
|
35 |
+
whisper-timestamped
|
36 |
+
openai
|
37 |
+
python-dotenv
|
38 |
+
pypinyin
|
39 |
+
jieba
|
40 |
+
cn2an
|
41 |
+
edge_tts
|