Commit ·
cd8454d
1
Parent(s): 8c8537f
first push of codes and models for g2p, t2u, tokenizer and detokenizer
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+14
- .gitignoreAdded+138
- 00004557-00000030.wavAdded+3
- 004892.wavAdded+3
- LICENSEAdded+202
- README.md+45-3
- README_CN.mdAdded+48
- Third_Party_Open_Source_Software_NoticeAdded+1289
- evaluation/README.mdAdded+9
- evaluation/eval_detok_en.pyAdded+269
- evaluation/eval_detok_zh.pyAdded+144
- evaluation/eval_sim.pyAdded+188
- evaluation/patch_unispeech.pyAdded+131
- evaluation/patch_utils.pyAdded+122
- evaluation/requirements_sim.txtAdded+7
- evaluation/requirements_wer.txtAdded+12
- figs/CADiT.jpgAdded
- figs/F5-streaming.jpgAdded
- figs/TTS.jpgAdded
- figs/eval1.jpgAdded
- figs/eval2.jpgAdded
- figs/eval3.jpgAdded
- figs/reconstruction.jpgAdded
- figs/tokenizer.jpgAdded
- install_requirements.shAdded+5
- reconstuction_example.pyAdded+178
- requirements_npu.txtAdded+18
- semantic_detokenizer/__init__.pyAdded
- semantic_detokenizer/chunk_infer.pyAdded+478
- semantic_detokenizer/ckpt/model.ptAdded+3
- semantic_detokenizer/ckpt/model.pt.md5Added+1
- semantic_detokenizer/ckpt/model.yamlAdded+51
- semantic_detokenizer/ckpt/vocab_4096.txtAdded+4096
- semantic_detokenizer/f5tts_npu_patch.pyAdded+106
- semantic_detokenizer/model/__init__.pyAdded
- semantic_detokenizer/model/cadit.pyAdded+263
- semantic_detokenizer/model/modules.pyAdded+223
- semantic_detokenizer/patch_utils.pyAdded+122
- semantic_detokenizer/requirements.txtAdded+13
- semantic_detokenizer/utils_infer.pyAdded+298
- semantic_tokenizer/__init__.pyAdded
- semantic_tokenizer/f40ms/README.mdAdded+7
- semantic_tokenizer/f40ms/__init__.pyAdded
- semantic_tokenizer/f40ms/ckpt/model.ptAdded+3
- semantic_tokenizer/f40ms/ckpt/model.pt.md5Added+1
- semantic_tokenizer/f40ms/config/dict.km.txtAdded+1000
- semantic_tokenizer/f40ms/config/hubert_config.yamlAdded+344
- semantic_tokenizer/f40ms/fairseq_npu_patch.pyAdded+34
- semantic_tokenizer/f40ms/infer_for_eval.pyAdded+140
- semantic_tokenizer/f40ms/models/__init__.pyAdded
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines333435363738394041424344454647484932 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textsemantic_detokenizer/ckpt/model.pt filter=lfs diff=lfs merge=lfs -textsemantic_tokenizer/f40ms/ckpt/model.pt filter=lfs diff=lfs merge=lfs -texttext2token/ckpt/40ms.checkpoint15.pt filter=lfs diff=lfs merge=lfs -textthirdparty/G2P/text/ja_userdic/userdict.csv filter=lfs diff=lfs merge=lfs -textfigs/CADiT.jpg filter=lfs diff=lfs merge=lfs -textfigs/F5-streaming.jpg filter=lfs diff=lfs merge=lfs -textfigs/TTS.jpg filter=lfs diff=lfs merge=lfs -textfigs/eval1.jpg filter=lfs diff=lfs merge=lfs -textfigs/eval2.jpg filter=lfs diff=lfs merge=lfs -textfigs/eval3.jpg filter=lfs diff=lfs merge=lfs -textfigs/reconstruction.jpg filter=lfs diff=lfs merge=lfs -textfigs/tokenizer.jpg filter=lfs diff=lfs merge=lfs -text004892.wav filter=lfs diff=lfs merge=lfs -text00004557-00000030.wav filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class
# C extensions*.so
# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/share/python-wheels/*.egg-info/.installed.cfg*.eggMANIFEST
# PyInstaller# Usually these files are written by a python script from a template# before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec
# Installer logspip-log.txtpip-delete-this-directory.txt
# Unit test / coverage reportshtmlcov/.tox/.nox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover*.py,cover.hypothesis/.pytest_cache/cover/
# Translations*.mo*.pot
# Django stuff:*.loglocal_settings.pydb.sqlite3db.sqlite3-journal
# Flask stuff:instance/.webassets-cache
# Scrapy stuff:.scrapy
# Sphinx documentationdocs/_build/
# PyBuilder.pybuilder/target/
# Jupyter Notebook.ipynb_checkpoints
# IPythonprofile_default/ipython_config.py
# pyenv# For a library or package, you might want to ignore these files since the code is# intended to run in multiple environments; otherwise, check them in:# .python-version
# pipenv# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.# However, in case of collaboration, if having platform-specific dependencies or dependencies# having no cross-platform support, pipenv may install dependencies that don't work, or not# install all needed dependencies.#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow__pypackages__/
# Celery stuffcelerybeat-schedulecelerybeat.pid
# SageMath parsed files*.sage.py
# Environments.env.venvenv/venv/ENV/env.bak/venv.bak/
# Spyder project settings.spyderproject.spyproject
# Rope project settings.ropeproject
# mkdocs documentation/site
# mypy.mypy_cache/.dmypy.jsondmypy.json
# Pyre type checker.pyre/
# pytype static type analyzer.pytype/
# Cython debug symbolscython_debug/123version https://git-lfs.github.com/spec/v1oid sha256:8a3b3747139278b3e4318d24e2e844cdbe534602d95fa5430786721d14480a9bsize 249388123version https://git-lfs.github.com/spec/v1oid sha256:255a96ce54c0b502b2aa785a4b1fdf0729d4c8975236fc4a1ba325c09637bf79size 297358123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445# Discrete Speech Tokenization Toolkit## Release Notes:V1.0This release consists of the following models:1. A speech semantic tokenzier (25Hz, codebook size=4096) for Chinese and English2. A corresponding speech detokenizer for for Chinese and English3. A text2token model (T2U) converts text to speech tokens.these models achieved top-tier performance on TTS and speech reconstruction on the seed-tts-eval dataset:<p align="center"><img src="figs/eval1.jpg" width="1200"></p><p align="center"><img src="figs/eval2.jpg" width="1200"></p>We also evaluated the ASR performance of our semantic tokenizer using a LLM as backbone. Our model achieve comparable performance to models that use continuous speech representation.<p align="center"><img src="figs/eval3.jpg" width="1200"></p>## Speech Semantic Tokenizerthe speech semantic tokenizer is train with labelled data.<p align="center"><img src="figs/tokenizer.jpg" width="800"></p>## Speech DetokenizerOur speech detokenizer is developed based on [F5-TTS](https://github.com/SWivid/F5-TTS) with two major updates added.1. we adopt DiT block with cross attention, which is similar to the detokenizer of [GLM-4-Voice](https://github.com/zai-org/GLM-4-Voice).<p align="center"><img src="figs/CADiT.jpg" height="600"></p>2. we intruduced a chunk-wise streaming inferece process that can generate speech of any length.<p align="center"><img src="figs/F5-streaming.jpg" width="1200"></p>## Text2Token(T2U)Text2Token is transformer machine translation model, which is trained on about 380k hours of speech-text pairs with [fairseq](https://github.com/facebookresearch/fairseq).## TTS pipelineAs shown in tts_example.py, the 3 models could form a pipeline for TTS task.<p align="center"><img src="figs/TTS.jpg" width="1200"></p>## Non-parallel Speech Reconstruction PipelineAs shown in reconstruction_example.py, the tokenizer and detokenizer could form a pipeline for speech reconstruction task.<p align="center"><img src="figs/reconstruction.jpg" width="1200"></p># Core Developers:[Daxin Tan](tan.daxin1@huawei.com), [Dehua Tao](TaoDehua@huawei.com), [Yusen Sun](sun.yusen2@huawei.com) and [Xiao Chen](chen.xiao2@huawei.com)## Contributors:[Hanlin Zhang](zhang.hanlin@huawei.com)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748# Discrete Speech Tokenization Toolkit## Release Notes:V1.0
本次发布的工具包包括一下几个模型:1. 一个语音tokenizer(25Hz, codebook size=4096)支持中英文2. 一个对应的detokenizer支持中英文3. 一个text2token模型(T2U)可将文本转换为语音token.
这些模型在seed-tts-eval数据集的TTS和语音重建任务上上达到了一流的精度:<p align="center"><img src="figs/eval1.jpg" width="1200"></p> <p align="center"><img src="figs/eval2.jpg" width="1200"></p>
我们基于LLM测试了本语音tokenizer的ASR精度,我们的tokenizer达到了与采用连续语音表征的模型相近的水平.<p align="center"><img src="figs/eval3.jpg" width="1200"></p>
## Speech Semantic Tokenizer本tokenizer的采用了监督学习方法。训练中我们使用了从开源数据中采样的大约4000小时中英文语音文本对数据,语种比例为1:1.<p align="center"><img src="figs/tokenizer.jpg" width="800"></p>
## Speech Detokenizer本detokenizer是基于[F5-TTS](https://github.com/SWivid/F5-TTS)开发,但是对齐进行了两项改进:1. 采用了DiT with cross attention,类似于[GLM-4-Voice](https://github.com/zai-org/GLM-4-Voice)的detokenizer.<p align="center"><img src="figs/CADiT.jpg" height="600"></p>
2. 开发了以chunk为单元的流式推理流程.<p align="center"><img src="figs/F5-streaming.jpg" width="1200"></p>
本次发布的detokenizer使用了约6000小时的中英文数据包括Wenet4TTS(premium,standard),LibriTTS等等。
## Text2Token(T2U)Text2Token是一个transformer机器翻译模型,用[fairseq](https://github.com/facebookresearch/fairseq)在约38万小时的语音文本对数据上训练得到。
## TTS pipeline在tts_example.py中, 我们给出了一个实例,串联使用上述三个模型实现TTS的功能.<p align="center"><img src="figs/TTS.jpg" width="1200"></p>
## Non-parallel Speech Reconstruction Pipeline在reconstruction_example.py中, 有另外一个实例,串联使用tokenizer和detokenizer实现语音重建的功能.<p align="center"><img src="figs/reconstruction.jpg" width="1200"></p>
# Core Developers:[Daxin Tan](tan.daxin1@huawei.com), [Dehua Tao](TaoDehua@huawei.com), [Yusen Sun](sun.yusen2@huawei.com) and [Xiao Chen](chen.xiao2@huawei.com)
## Contributors:[Hanlin Zhang](zhang.hanlin@huawei.com)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289OPEN SOURCE SOFTWARE NOTICE FOR LIST
This document contains licenses and copyright notices for third-party software components used in the list project, which are legally required to be disclosed under their respective open source licenses.
The below components are provided under separate licenses. The applicable license terms for each component are provided in the corresponding license text below. These licenses are granted by the original copyright holders.
When using the open source software components contained in list, the applicable open source license(s) shall prevail over any other license terms that may be contained in this distribution, including but not limited to: Apache-2.0, BSD-3-Clause, MIT, NOASSERTION.
WARRANTY DISCLAIMER
THE OPEN SOURCE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For full warranty details and limitations, refer to the individual license texts provided below.
================================================================================
[SoftWare] fairseq 0.12.2
Copyright Notice(s): • Copyright (c) Facebook, Inc. and its affiliates.
License: MIT License
Full License Text:Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
================================================================================
[SoftWare] f5-tts 0.12.2
Copyright Notice(s): • Copyright (c) 2024 Yushen CHEN
License: MIT License
Full License Text:Copyright (c) 2024 Yushen CHENPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
================================================================================
[SoftWare] GPT-SoVITS
Copyright Notice(s): • Copyright (c) 2024 RVC-Boss
License: MIT License
Full License Text:Copyright (c) 2024 RVC-Boss
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
================================================================================
[SoftWare] WeTextProcessing
Copyright Notice(s): • Copyright (c) 2022 Zhendong Peng (pzd17@tsinghua.org.cn)
License: Apache License V2.0
Full License Text: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================================================
[SoftWare] icefall 1.0
Copyright Notice(s): • Copyright (c) 2021-2024 Xiaomi Corp.
License: Apache License V2.0
Full License Text: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================================================
[SoftWare] espnet 0.10.5
Copyright Notice(s): • Copyright 2017 Johns Hopkins University
License: Apache License V2.0
Full License Text: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================================================
[SoftWare] vixen build-560
License: freeware
Full License Text:
Vixen is unlicensed and free to use. This software is provided 'as-is', without any express or implied warranty. In no event will the authors or any contributors be held liable for any damages or liabilities arising from the use of this software.
Vixen uses many 3rd party libraries that are required to be present on the path for the full functionality. Some of those have licenses that can be found as follows.
NLog http://raw.github.com/NLog/NLog/master/LICENSE.txtNLog.Config http://raw.github.com/NLog/NLog/master/LICENSE.txtNLog.Schema http://raw.github.com/NLog/NLog/master/LICENSE.txtDockPanelSuite http://www.opensource.org/licenses/mit-license.phpDockPanelSuite.ThemeVS2015 http://www.opensource.org/licenses/mit-license.phpNewtonsoft.Json https://raw.github.com/JamesNK/Newtonsoft.Json/master/LICENSE.mdNowin http://www.opensource.org/licenses/mit-license.phpOwin https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txtNShape https://nshape.codeplex.com/licenseZedGraph https://www.gnu.org/licenses/lgpl-2.1.txtAccord.Net http://accord-framework.net/license.txtAccord.Video.FFMPEG http://accord-framework.net/gpl.txt
Some portions of the Effect editor code are based on work that is licensed under the Apache 2.0 license.http://www.apache.org/licenses/LICENSE-2.0
NumericTextBox is derived from NumericalTextBox control licensed under the Apache 2.0 License. http://www.apache.org/licenses/LICENSE-2.0
================================================================================
[SoftWare] g2pK 3bb9d5a
License: Apache License V2.0
Full License Text: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================================================
[SoftWare] Parakeet 0.4.0
Copyright Notice(s): • Copyright 2017 Johns Hopkins University
License: Apache License V2.0
Full License Text: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================================================
[SoftWare] PaddleSpeech 0.2.0
Copyright Notice(s): • Copyright (c) 2021 PaddlePaddle Authors
License: Apache License V2.0
Full License Text: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS ================================================================================
[SoftWare] espresso 3add524
Copyright Notice(s): • Copyright (c) Yiming Wang
License: MIT License
Full License Text: MIT License
Copyright for the original fairseq code are held by Facebook, Inc. and its affiliates as part of project Espresso. All other copyright for project Espressoare held by Espresso authors.
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
================================================================================123456789evaluation:
for evaluation of speaker similarity, user should downloade the latest version of UniSpeech from github:
git clone https://github.com/Sanyuan-Chen/UniSpeech.git
and add the path of UniSpeech to PYTHONPATH:
export PYTHONPATH=/path/to/UniSpeech/downstreams/speaker_verification:$PYTHONPATH123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
from transformers import WhisperProcessor, WhisperForConditionalGenerationimport soundfile as sfimport scipyimport argparsefrom whisper_normalizer.english import EnglishTextNormalizerimport osimport stringimport lingvo.tasks.asr.tools.simple_wer_v2 as WERfrom tqdm import tqdmimport loggingimport torch
keyphrases = Noneenglish_normalizer = EnglishTextNormalizer()device = torch.device("cuda")en_asr_model_path = "./whisper-large-v3"
wer_obj = WER.SimpleWER( key_phrases=keyphrases, html_handler=WER.HighlightAlignedHtmlHandler(WER.HighlightAlignedHtml), preprocess_handler=WER.RemoveCommentTxtPreprocess,)
def dummy_split_text(text): return text
def remove_punct(text): puncts = set(string.punctuation) output = "" for char in text: if char not in puncts: output += char output = output.replace(" ", " ") return output
def get_gt_ref_texts_and_wav_files( args, gt_test_lst, gt_folder, punct_remover, text_spliter): wav_file_list = [] reference = [] with open(gt_test_lst, "r") as fp: for line in fp: fields = line.strip().split("|") wav_file = f"{gt_folder}/{fields[0]}.wav"
if not os.path.isfile(wav_file): continue
wav_file_list.append(wav_file) text = fields[-1].lower() if args.norm_text: truth_text = english_normalizer(text) # " ".join(fields[-1]) elif args.remove_punct: truth_text = punct_remover(text) else: truth_text = text truth_text = text_spliter(truth_text) reference.append([truth_text, fields[-1]])
assert len(reference) == len(wav_file_list) return reference, wav_file_list
def get_ref_texts_and_gen_files( args, test_lst, test_folder, punct_remover, text_spliter): reference = [] gen_file_list = [] with open(test_lst, "r") as fp: for line in fp: fields = line.strip().split("|") filename = fields[2].split("/")[-1] filename = filename.split(".")[0] gen_file = f"{filename}_gen.wav" gen_file_list.append(f"{test_folder}/{gen_file}")
text = fields[-1].lower() if args.norm_text: truth_text = english_normalizer(text) # " ".join(fields[-1]) elif args.remove_punct: truth_text = punct_remover(text) else: truth_text = text
truth_text = text_spliter(truth_text) reference.append([truth_text, fields[-1]])
assert len(reference) == len(gen_file_list) return reference, gen_file_list
def get_hypo_texts(args, results_list, punct_remover, text_spliter): hypothesis = [] for res in results_list: text = res["text"].lower() if args.norm_text: hypo_text = english_normalizer(text) elif args.remove_punct: hypo_text = punct_remover(text) else: hypo_text = text hypo_text = text_spliter(hypo_text) hypothesis.append([hypo_text, res["text"]])
return hypothesis
def calc_wer(reference, hypothesis, test_lst): logging.info(f"calc WER:") for idx in tqdm(range(len(hypothesis))): hypo = hypothesis[idx][0].strip() ref = reference[idx][0].strip() wer_obj.AddHypRef(hypo, ref)
str_summary, str_details, str_keyphrases_info = wer_obj.GetSummaries() logging.info(f"WER summary:") logging.info(str_summary) logging.info(str_details) logging.info(str_keyphrases_info)
try: fn_output = test_lst + "_diagnosis.html" aligned_html = "<br>".join(wer_obj.aligned_htmls) with open(fn_output, "wt") as fp: fp.write("<body><html>") fp.write("<div>%s</div>" % aligned_html) fp.write("</body></html>") fp.close()
text_output = test_lst + "_rawtext.lst" with open(text_output, "w") as fp: for ref, hypo in zip(reference, hypothesis): fp.write(f"{ref[1]}|{hypo[1]}\n") fp.close() logging.info(f"Save {fn_output} and {text_output} for diagnosis") except IOError: logging.info("failed to write diagnosis html")
def load_en_model(): processor = WhisperProcessor.from_pretrained(en_asr_model_path) model = WhisperForConditionalGeneration.from_pretrained(en_asr_model_path).to( device ) return processor, model
def process_wavs(wav_file_list, batch_size=300): results = [] processor, model = load_en_model() for wav_file_path in tqdm(wav_file_list): wav, sr = sf.read(wav_file_path) if sr != 16000: wav = scipy.signal.resample(wav, int(len(wav) * 16000 / sr)) input_features = processor( wav, sampling_rate=16000, return_tensors="pt" ).input_features input_features = input_features.to(device) forced_decoder_ids = processor.get_decoder_prompt_ids( language="english", task="transcribe" ) predicted_ids = model.generate( input_features, forced_decoder_ids=forced_decoder_ids ) transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[ 0 ] results.append({"text": transcription.strip()})
return results
def main(args): handler = logging.FileHandler(filename=args.log_file, mode="w") logging.root.setLevel(logging.INFO) logging.root.addHandler(handler)
test_path = ( args.test_path ) # './40ms.AISHELL2.test_with_single_ref.base.chunk25.gen' lst_path = args.test_lst # "40ms.AISHELL2.test_with_single_ref.base.lst" logging.info( f"Evaluate {args.test_path} with Text Normalization: {args.norm_text} and Remove Punct: {args.remove_punct}" )
if args.eval_gt: logging.info(f"run ASR for GT: {lst_path}") reference, wav_file_list = get_gt_ref_texts_and_wav_files( args, lst_path, test_path, remove_punct, dummy_split_text ) results = process_wavs(wav_file_list, batch_size=12) else: logging.info(f"run ASR for detok: {lst_path}") reference, gen_file_list = get_ref_texts_and_gen_files( args, lst_path, test_path, remove_punct, dummy_split_text ) results = process_wavs(gen_file_list, batch_size=12)
hypothesis = get_hypo_texts(args, results, remove_punct, dummy_split_text)
assert len(hypothesis) == len(reference) logging.info(f"Finish runing ASR for {lst_path}") logging.info(f"hypothesis: {len(hypothesis)} vs reference: {len(reference)}")
calc_wer(reference, hypothesis, test_path) logging.info(f"Finish evaluate {lst_path}, results are in {args.log_file}")
if __name__ == "__main__":
parser = argparse.ArgumentParser() parser.add_argument( "--test-path", required=True, type=str, help=f"folder of wav files", ) parser.add_argument( "--test-lst", required=True, type=str, help=f"path to test file lst", ) parser.add_argument( "--log-file", required=False, type=str, default=None, help=f"path to test file lst", ) parser.add_argument( "--norm-text", default=False, action="store_true", help=f"normalized GT and hypo texts", ) parser.add_argument( "--remove-punct", default=False, action="store_true", help=f"remove punct from GT and hypo texts", ) parser.add_argument( "--eval-gt", default=False, action="store_true", help=f"remove punct from GT and hypo texts", ) args = parser.parse_args()
main(args)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
import loggingfrom funasr import AutoModelimport argparsefrom zhon.hanzi import punctuationimport zhconvimport stringfrom tqdm import tqdmfrom eval_detok_en import ( get_gt_ref_texts_and_wav_files, get_ref_texts_and_gen_files, get_hypo_texts, calc_wer,)
model_path = "./paraformer-zh" # "./speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
def split_text(text): text = " ".join(text) return text
def dummy_split_text(text): return text
def remove_punct(text): puncts = set(punctuation + string.punctuation) output = "" for char in text: if char not in puncts: output += char output = output.replace(" ", " ") return output
def process_wavs(wav_file_list, batch_size=300): model = AutoModel( model=model_path, disable_update=True, )
results = [] for wav_file_path in tqdm(wav_file_list): res = model.generate( input=wav_file_path, batch_size_s=batch_size, ) transcription = zhconv.convert(res[0]["text"], "zh-cn") results.append({"text": transcription}) return results
def main(args): handler = logging.FileHandler(filename=args.log_file, mode="w") logging.root.setLevel(logging.INFO) logging.root.addHandler(handler)
test_path = ( args.test_path ) # './40ms.AISHELL2.test_with_single_ref.base.chunk25.gen' lst_path = args.test_lst # "40ms.AISHELL2.test_with_single_ref.base.lst"
if args.eval_gt: logging.info(f"run ASR for GT: {lst_path}") reference, wav_file_list = get_gt_ref_texts_and_wav_files( args, lst_path, test_path, remove_punct, split_text ) results = process_wavs(wav_file_list, batch_size=300) else: logging.info(f"run ASR for detok: {lst_path}") reference, gen_file_list = get_ref_texts_and_gen_files( args, lst_path, test_path, remove_punct, split_text ) results = process_wavs(gen_file_list, batch_size=300)
hypothesis = get_hypo_texts(args, results, remove_punct, split_text)
assert len(hypothesis) == len(reference) logging.info(f"Finish runing ASR for {lst_path}") logging.info(f"hypothesis: {len(hypothesis)} vs reference: {len(reference)}")
calc_wer(reference, hypothesis, test_path) logging.info(f"Finish evaluate {lst_path}, results are in {args.log_file}")
if __name__ == "__main__":
parser = argparse.ArgumentParser() parser.add_argument( "--test-path", required=True, type=str, help=f"folder of wav files", ) parser.add_argument( "--test-lst", required=True, type=str, help=f"path to test file lst", ) parser.add_argument( "--log-file", required=False, type=str, default=None, help=f"path to test file lst", ) parser.add_argument( "--remove-punct", default=False, action="store_true", help=f"remove punct from GT and hypo texts", ) parser.add_argument( "--norm-text", default=False, action="store_true", help=f"normalized GT and hypo texts", ) parser.add_argument( "--eval-gt", default=False, action="store_true", help=f"remove punct from GT and hypo texts", ) args = parser.parse_args() args.norm_text = False
main(args)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
import argparsefrom tqdm import tqdmimport loggingimport osfrom verification import init_model, MODEL_LISTimport soundfile as sfimport torchimport numpy as npimport torch.nn.functional as Ffrom torchaudio.transforms import Resampleimport torch.multiprocessing as mp
console_format = logging.Formatter( "[%(asctime)s][%(filename)s:%(levelname)s][%(process)d:%(threadName)s]%(message)s")console_handler = logging.StreamHandler()console_handler.setFormatter(console_format)console_handler.setLevel(logging.INFO)if len(logging.root.handlers) > 0: for handler in logging.root.handlers: logging.root.removeHandler(handler)logging.root.addHandler(console_handler)logging.root.setLevel(logging.INFO)
MODEL_NAME = "wavlm_large"S3PRL_PATH = os.environ.get("S3PRL_PATH")if S3PRL_PATH is not None: import patch_unispeech logging.info("Applying Patches for unispeech!!!") patch_unispeech.patch_for_npu()
def get_ref_and_gen_files( test_lst, test_folder, task_queue): with open(test_lst, "r") as fp: for line in fp: fields = line.strip().split("|") gen_name = fields[2].split("/")[-1] gen_name = gen_name.split(".")[0] gen_file = f"{test_folder}/{gen_name}_gen.wav" ref_name = fields[0].split("/")[-1] ref_name = ref_name.split(".")[0] ref_file = f"{test_folder}/{ref_name}_ref.wav"
task_queue.put((ref_file, gen_file))
return
def eval_speaker_similarity(model, wav1, wav2, rank): wav1, sr1 = sf.read(wav1) wav2, sr2 = sf.read(wav2)
wav1 = torch.from_numpy(wav1).unsqueeze(0).float() wav2 = torch.from_numpy(wav2).unsqueeze(0).float() resample1 = Resample(orig_freq=sr1, new_freq=16000) resample2 = Resample(orig_freq=sr2, new_freq=16000) wav1 = resample1(wav1) wav2 = resample2(wav2)
wav1 = wav1.cuda(f"cuda:{rank}") wav2 = wav2.cuda(f"cuda:{rank}")
model.eval() with torch.no_grad(): emb1 = model(wav1) emb2 = model(wav2)
sim = F.cosine_similarity(emb1, emb2) logging.info("The similarity score between two audios is %.4f (-1.0, 1.0)." % (sim[0].item())) return sim[0].item()
def eval_proc(model_path, task_queue, rank, sim_list): model = None assert MODEL_NAME in MODEL_LIST, 'The model_name should be in {}'.format(MODEL_LIST) model = init_model(MODEL_NAME, model_path) if model is None else model model.to(f"cuda:{rank}") # sim_list = [] # for ref, gen in tqdm(ref_gen_list): while True: try: new_record = task_queue.get() if new_record is None: logging.info("FINISH processing all inputs") break
ref = new_record[0] gen = new_record[1] logging.info(f"eval SIM: {ref} v.s. {gen}")
if not os.path.exists(ref) or not os.path.exists(gen): logging.info(f"MISSING: {ref} v.s. {gen}") continue
sim = eval_speaker_similarity(model, ref, gen, rank) sim_list.append((sim, ref, gen)) except: logging.info(f"FAIL to eval SIM: {ref} v.s. {gen}")
def main(args): handler = logging.FileHandler(filename=args.log_file, mode="w") logging.root.addHandler(handler)
device_list = [0] if "CUDA_VISIBLE_DEVICES" in os.environ: device_list = [int(x.strip()) for x in os.environ["CUDA_VISIBLE_DEVICES"].split(",")]
logging.info(f"Using devices: {device_list}") n_procs = len(device_list) ctx = mp.get_context('spawn') with ctx.Manager() as manager: sim_list = manager.list() task_queue = manager.Queue() get_ref_and_gen_files(args.test_lst, args.test_path, task_queue)
processes = [] for idx in range(n_procs): task_queue.put(None) rank = idx # device_list[idx] p = ctx.Process(target=eval_proc, args=(args.model_path, task_queue, rank, sim_list)) processes.append(p)
for proc in processes: proc.start() for proc in processes: proc.join() sim_scores = [] for sim, ref, gen in sim_list: logging.info(f"{ref} vs {gen} : {sim}") sim_scores.append(sim) avg_sim = round(np.mean(np.array(list(sim_scores))), 3) logging.info("total evaluated wav pairs: %d" % (len(sim_list))) logging.info("The average similarity score of %s is %.4f (-1.0, 1.0)." % (args.test_path, avg_sim)) return avg_sim
if __name__ == "__main__":
parser = argparse.ArgumentParser() parser.add_argument( "--test-path", required=True, type=str, help=f"folder of wav files", ) parser.add_argument( "--test-lst", required=True, type=str, help=f"path to test file lst", ) parser.add_argument( "--log-file", required=False, type=str, default=None, help=f"path to test file lst", ) parser.add_argument( "--model-path", type=str, default="./wavlm-sv", help=f"path to sv model", )
args = parser.parse_args() main(args)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
from patch_utils import MindSpeedPatchesManager as aspmimport osimport torchimport torch.nn as nnimport loggingimport torchaudio.transforms as transfrom s3prl.upstream.wavlm.expert import UpstreamExpert as s3prl_UpstreamExpertfrom models.ecapa_tdnn import Conv1dReluBn, SE_Res2Block, AttentiveStatsPool from models.ecapa_tdnn import ECAPA_TDNN_SMALL, ECAPA_TDNN
def init_model_patched(model_name, checkpoint=None): S3PRL_PATH = os.environ.get("S3PRL_PATH") if model_name == 'unispeech_sat': config_path = 'config/unispeech_sat.th' model = ECAPA_TDNN_SMALL(feat_dim=1024, feat_type='unispeech_sat', config_path=config_path) elif model_name == 'wavlm_base_plus': config_path = None model = ECAPA_TDNN_SMALL(feat_dim=768, feat_type='wavlm_base_plus', config_path=config_path) elif model_name == 'wavlm_large': config_path = S3PRL_PATH model = ECAPA_TDNN_SMALL(feat_dim=1024, feat_type='wavlm_large', config_path=config_path) elif model_name == 'hubert_large': config_path = None model = ECAPA_TDNN_SMALL(feat_dim=1024, feat_type='hubert_large_ll60k', config_path=config_path) elif model_name == 'wav2vec2_xlsr': config_path = None model = ECAPA_TDNN_SMALL(feat_dim=1024, feat_type='wav2vec2_xlsr', config_path=config_path) else: model = ECAPA_TDNN_SMALL(feat_dim=40, feat_type='fbank')
if checkpoint is not None: state_dict = torch.load(checkpoint, map_location=lambda storage, loc: storage) model.load_state_dict(state_dict['model'], strict=False) return model
class patched_ECAPA_TDNN(ECAPA_TDNN): def __init__(self, feat_dim=80, channels=512, emb_dim=192, global_context_att=False, feat_type='fbank', sr=16000, feature_selection="hidden_states", update_extract=False, config_path=None): super(ECAPA_TDNN, self).__init__()
self.feat_type = feat_type self.feature_selection = feature_selection self.update_extract = update_extract self.sr = sr
if feat_type == "fbank" or feat_type == "mfcc": self.update_extract = False
win_len = int(sr * 0.025) hop_len = int(sr * 0.01)
if feat_type == 'fbank': self.feature_extract = trans.MelSpectrogram(sample_rate=sr, n_fft=512, win_length=win_len, hop_length=hop_len, f_min=0.0, f_max=sr // 2, pad=0, n_mels=feat_dim) elif feat_type == 'mfcc': melkwargs = { 'n_fft': 512, 'win_length': win_len, 'hop_length': hop_len, 'f_min': 0.0, 'f_max': sr // 2, 'pad': 0 } self.feature_extract = trans.MFCC(sample_rate=sr, n_mfcc=feat_dim, log_mels=False, melkwargs=melkwargs) else: if config_path is None: self.feature_extract = torch.hub.load('s3prl/s3prl', feat_type) else: self.feature_extract = s3prl_UpstreamExpert(config_path) if len(self.feature_extract.model.encoder.layers) == 24 and hasattr(self.feature_extract.model.encoder.layers[23].self_attn, "fp32_attention"): self.feature_extract.model.encoder.layers[23].self_attn.fp32_attention = False if len(self.feature_extract.model.encoder.layers) == 24 and hasattr(self.feature_extract.model.encoder.layers[11].self_attn, "fp32_attention"): self.feature_extract.model.encoder.layers[11].self_attn.fp32_attention = False
self.feat_num = self.get_feat_num() self.feature_weight = nn.Parameter(torch.zeros(self.feat_num))
if feat_type != 'fbank' and feat_type != 'mfcc': freeze_list = ['final_proj', 'label_embs_concat', 'mask_emb', 'project_q', 'quantizer'] for name, param in self.feature_extract.named_parameters(): for freeze_val in freeze_list: if freeze_val in name: param.requires_grad = False break
if not self.update_extract: for param in self.feature_extract.parameters(): param.requires_grad = False
self.instance_norm = nn.InstanceNorm1d(feat_dim) # self.channels = [channels] * 4 + [channels * 3] self.channels = [channels] * 4 + [1536]
self.layer1 = Conv1dReluBn(feat_dim, self.channels[0], kernel_size=5, padding=2) self.layer2 = SE_Res2Block(self.channels[0], self.channels[1], kernel_size=3, stride=1, padding=2, dilation=2, scale=8, se_bottleneck_dim=128) self.layer3 = SE_Res2Block(self.channels[1], self.channels[2], kernel_size=3, stride=1, padding=3, dilation=3, scale=8, se_bottleneck_dim=128) self.layer4 = SE_Res2Block(self.channels[2], self.channels[3], kernel_size=3, stride=1, padding=4, dilation=4, scale=8, se_bottleneck_dim=128)
# self.conv = nn.Conv1d(self.channels[-1], self.channels[-1], kernel_size=1) cat_channels = channels * 3 self.conv = nn.Conv1d(cat_channels, self.channels[-1], kernel_size=1) self.pooling = AttentiveStatsPool(self.channels[-1], attention_channels=128, global_context_att=global_context_att) self.bn = nn.BatchNorm1d(self.channels[-1] * 2) self.linear = nn.Linear(self.channels[-1] * 2, emb_dim)
def patched_ECAPA_TDNN_SMALL(feat_dim, emb_dim=256, feat_type='fbank', sr=16000, feature_selection="hidden_states", update_extract=False, config_path=None): return patched_ECAPA_TDNN(feat_dim=feat_dim, channels=512, emb_dim=emb_dim, feat_type=feat_type, sr=sr, feature_selection=feature_selection, update_extract=update_extract, config_path=config_path)
def patch_for_npu(): aspm.register_patch('models.ecapa_tdnn.ECAPA_TDNN_SMALL', patched_ECAPA_TDNN_SMALL) aspm.register_patch('verification.init_model', init_model_patched) aspm.apply_patches()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122# copied from https://gitee.com/ascend/MindSpeed/blob/master/mindspeed/patch_utils.py
import importlibimport sysimport types
def get_func_name(func): if isinstance(func, str): return func return '.'.join((func.__module__, func.__qualname__))
def dummy_function_wrapper(func_name): def dummy_function(*args, **kwargs): raise RuntimeError('function {} no exist'.format(func_name))
return dummy_function
class Patch: def __init__(self, orig_func_name, new_func, create_dummy): split_name = orig_func_name.rsplit('.', 1) if len(split_name) == 1: self.orig_module_name, self.orig_func_name = orig_func_name, None else: self.orig_module_name, self.orig_func_name = split_name self.orig_module = None self.orig_func = None
self.patch_func = None self.wrappers = [] if new_func is None: new_func = dummy_function_wrapper(orig_func_name) self.set_patch_func(new_func) self.is_applied = False self.create_dummy = create_dummy
@property def orig_func_id(self): return id(self.orig_func)
@property def patch_func_id(self): return id(self.patch_func)
def set_patch_func(self, new_func, force_patch=False): if hasattr(new_func, '__name__') and new_func.__name__.endswith(('wrapper', 'decorator')): self.wrappers.append(new_func) else: if self.patch_func and not force_patch: raise RuntimeError('the patch of {} exist !'.format(self.orig_func_name)) self.patch_func = new_func self.is_applied = False
def apply_patch(self): if self.is_applied: return
self.orig_module, self.orig_func = Patch.parse_path(self.orig_module_name, self.orig_func_name, self.create_dummy)
final_patch_func = self.orig_func if self.patch_func is not None: final_patch_func = self.patch_func
for wrapper in self.wrappers: final_patch_func = wrapper(final_patch_func)
if self.orig_func_name is not None: setattr(self.orig_module, self.orig_func_name, final_patch_func) for key, value in sys.modules.copy().items(): if self.orig_func_name is not None and hasattr(value, self.orig_func_name) \ and id(getattr(value, self.orig_func_name)) == self.orig_func_id: setattr(value, self.orig_func_name, final_patch_func) self.is_applied = True
@staticmethod def parse_path(module_path, function_name, create_dummy): from importlib.machinery import ModuleSpec modules = module_path.split('.') for i in range(1, len(modules) + 1): parent = '.'.join(modules[:i - 1]) path = '.'.join(modules[:i]) try: importlib.import_module(path) except ModuleNotFoundError as e: if not parent or not hasattr(importlib.import_module(parent), modules[i - 1]): if not create_dummy: raise ModuleNotFoundError(e) from e sys.modules[path] = types.ModuleType(path) sys.modules[path].__file__ = 'mindspeed.dummy_module.py' sys.modules[path].__spec__ = ModuleSpec(path, None) if parent: setattr(importlib.import_module(parent), modules[i - 1], sys.modules[path]) else: module = getattr(importlib.import_module(parent), modules[i - 1]) if hasattr(module, function_name): return module, getattr(module, function_name) elif create_dummy: return module, dummy_function_wrapper(function_name) else: raise RuntimeError('no exist {} of {}'.format(function_name, module))
if function_name is not None and not hasattr(sys.modules[module_path], function_name): setattr(sys.modules[module_path], function_name, None) return sys.modules[module_path], getattr(sys.modules[module_path], function_name) if function_name is not None else None
class MindSpeedPatchesManager: patches_info = {}
@staticmethod def register_patch(orig_func_name, new_func=None, force_patch=False, create_dummy=False): if orig_func_name not in MindSpeedPatchesManager.patches_info: MindSpeedPatchesManager.patches_info[orig_func_name] = Patch(orig_func_name, new_func, create_dummy) else: MindSpeedPatchesManager.patches_info.get(orig_func_name).set_patch_func(new_func, force_patch)
@staticmethod def apply_patches(): for patch in MindSpeedPatchesManager.patches_info.values(): patch.apply_patch()1234567fireomegaconf==2.0.6s3prl==0.4.1numpy==1.21fairseq==0.12.2torch==2.1.0torchaudio==2.1.0123456789101112#fire#s3prl==0.4.1#hydra-core==1.0.7#fairseq==0.12.2transformersfunasr==1.2.7zhconvzhonwhisper_normalizertorch==2.1.0torchaudio==2.1.0lingvo12345# to resolve deps conflicts of fairseq and f5-ttspip install pip==23.1.2pip install setuptools==65.5.1pip install f5-tts==0.3.4pip install -r requirements_npu.txt123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
import argparseimport librosaimport loggingimport soundfile as sfimport sysfrom pathlib import Path
sub_modules = ["", "semantic_tokenizer/f40ms", "semantic_detokenizer"]for sub in sub_modules: sys.path.append(str((Path(__file__).parent / sub).absolute()))
from semantic_tokenizer.f40ms.simple_tokenizer_infer import SpeechTokenizer, TOKENIZER_CFG_NAMEfrom semantic_detokenizer.chunk_infer import SpeechDetokenizer
class ReconstructionPipeline: def __init__( self, detok_vocoder: str, tokenizer_cfg_name: str = TOKENIZER_CFG_NAME, tokenizer_cfg_path: str = str( (Path(__file__).parent / "semantic_tokenizer/f40ms/config").absolute() ), tokenizer_ckpt: str = str( ( Path(__file__).parent / "semantic_tokenizer/f40ms/ckpt/model.pt" ).absolute() ), detok_model_cfg: str = str( (Path(__file__).parent / "semantic_detokenizer/ckpt/model.yaml").absolute() ), detok_ckpt: str = str( (Path(__file__).parent / "semantic_detokenizer/ckpt/model.pt").absolute() ), detok_vocab: str = str( ( Path(__file__).parent / "semantic_detokenizer/ckpt/vocab_4096.txt" ).absolute() ), ): self.tokenizer_cfg_name = tokenizer_cfg_name self.tokenizer = SpeechTokenizer( ckpt_path=tokenizer_ckpt, cfg_path=tokenizer_cfg_path, cfg_name=self.tokenizer_cfg_name, )
self.device = "cuda:0" self.detoker = SpeechDetokenizer( vocoder_path=detok_vocoder, model_cfg=detok_model_cfg, ckpt_file=detok_ckpt, vocab_file=detok_vocab, device=self.device, )
self.token_chunk_len = 75 self.chunk_cond_proportion = 0.3 self.chunk_look_ahead = 10 self.max_ref_duration = 4.5 self.ref_audio_cut_from_head = False
def reconstruct(self, ref_wav, input_wav): ref_wavs_list = [] raw_ref_wav, sr = librosa.load(ref_wav, sr=16000) ref_wavs_list.append(raw_ref_wav)
raw_input_wav, sr = librosa.load(input_wav, sr=16000) ref_wavs_list.append(raw_input_wav)
token_list, token_info_list = self.tokenizer.extract( ref_wavs_list ) ref_tokens = token_info_list[0]["reduced_unit_sequence"] input_tokens = token_info_list[1]["reduced_unit_sequence"] logging.info("tokens for ref wav: %s are [%s]" % (ref_wav, ref_tokens)) logging.info("tokens for input wav: %s are [%s]" % (input_wav, input_tokens))
generated_wave, target_sample_rate = self.detoker.chunk_generate( ref_wav, ref_tokens.split(), input_tokens.split(), self.token_chunk_len, self.chunk_cond_proportion, self.chunk_look_ahead, self.max_ref_duration, self.ref_audio_cut_from_head, )
if generated_wave is None: logging.info("generation FAILED") return None, None return generated_wave, target_sample_rate
def main(args): # initialize reconsturctor = ReconstructionPipeline( detok_vocoder=args.detok_vocoder, )
generated_wave, target_sample_rate = reconsturctor.reconstruct(args.ref_wav, args.input_wav) with open(args.output_wav, "wb") as f: sf.write(f.name, generated_wave, target_sample_rate) logging.info(f"write output to: {f.name}")
logging.info("Finished") return
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--tokenizer-ckpt", required=False, help="path to ckpt", ) parser.add_argument( "--tokenizer-cfg-path", required=False, default="semantic_tokenizer/f40ms/config", help="path to config", ) parser.add_argument( "--detok-ckpt", required=False, help="path to ckpt", ) parser.add_argument( "--detok-model-cfg", required=False, help="path to model_cfg", ) parser.add_argument( "--detok-vocab", required=False, help="path to vocab", ) parser.add_argument( "--detok-vocoder", required=True, help="path to vocoder", ) parser.add_argument( "--ref-wav", required=True, help="path to ref wav", ) parser.add_argument( "--output-wav", required=True, help="path to output reconstructed wav", ) parser.add_argument( "--input-wav", required=True, help="input wav to reconstruction", )
args = parser.parse_args()
main(args)123456789101112131415161718librosa==0.9.2torch==2.5.1torch-npu==2.5.1torchaudio==2.5.1torchvision==0.20.1omegaconf==2.0.6fairseq==0.12.2Cythonnumpy==1.23.4g2p_enjieba_fastjiebaLangSegment>=0.2.0wordsegmentpypinyincn2ang2pMWeTextProcessing123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Dehua Tao,# Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
import argparseimport osfrom datetime import datetimefrom importlib.resources import filesfrom pathlib import Pathimport tqdm
import soundfile as sfimport time
from omegaconf import OmegaConfimport torchaudioimport torch.multiprocessing as mp
from f5_tts.infer.utils_infer import ( load_model, load_vocoder, remove_silence_for_generated_wav,)from utils_infer import ( mel_spec_type, target_rms, nfe_step, cfg_strength, sway_sampling_coef, speed, fix_duration, chunk_infer_batch_process)from model.cadit import CADiT
import loggingconsole_format = logging.Formatter( "[%(asctime)s][%(filename)s:%(levelname)s][%(process)d:%(threadName)s]%(message)s")console_handler = logging.StreamHandler()console_handler.setFormatter(console_format)console_handler.setLevel(logging.INFO)if len(logging.root.handlers) > 0: for handler in logging.root.handlers: logging.root.removeHandler(handler)logging.root.addHandler(console_handler)logging.root.setLevel(logging.INFO)
TOKENIZE_ON_NPU = os.environ.get("TOKENIZE_ON_NPU")if TOKENIZE_ON_NPU is not None and TOKENIZE_ON_NPU == "1": import torch_npu import f5tts_npu_patch from torch_npu.contrib import transfer_to_npu
logging.info("Applying Patches for NPU!!!") f5tts_npu_patch.patch_for_npu()
class SpeechDetokenizer: def __init__(self, vocoder_path:str, model_cfg:str = str((Path(__file__).parent / "ckpt/model.yaml").absolute()), ckpt_file:str = str((Path(__file__).parent / "ckpt/model.pt").absolute()), vocab_file:str = str((Path(__file__).parent / "ckpt/vocab_4096.txt").absolute()), device="cuda:0"): self.model_cfg = model_cfg self.ckpt_file = ckpt_file self.vocab_file = vocab_file self.vocoder_path = vocoder_path self.device = device
self.cross_fade_duration = 0 self.initialize()
def initialize(self): self.model = "CADiT" # "F5TTS" load_vocoder_from_local = True
self.vocoder_name = mel_spec_type # Vocoder vocoder_local_path = self.vocoder_path # "/home/ma-user/work/chenxiao/workspace/model/vocos_mel_24khz/"
# TTS model model_cls = CADiT model_cfg = OmegaConf.load(self.model_cfg).model.arch logging.info(f"Using {self.model}...")
# Load vocoder self.vocoder = load_vocoder( vocoder_name=self.vocoder_name, is_local=load_vocoder_from_local, local_path=vocoder_local_path, device=self.device, )
# Load TTS model self.ema_model = load_model( model_cls, model_cfg, self.ckpt_file, mel_spec_type=self.vocoder_name, vocab_file=self.vocab_file, device=self.device, )
# def chunk_text(self, text_list, chunk_len=135, merge_short_last=False): # """ # Splits the input text into chunks, each with a maximum number of characters.
# Args: # text (str): The text to be split. # max_chars (int): The maximum number of characters per chunk.
# Returns: # List[str]: A list of text chunks. # """ # chunks = []
# # if isinstance(text, list): # for i in range(0, len(text_list), chunk_len): # chunks.append(text_list[i : i + chunk_len])
# if merge_short_last and len(chunks) >= 2 and len(chunks[-1]) < chunk_len: # # Merge the last two chunks # last = chunks.pop() # second_last = chunks.pop() # chunks.append(second_last + last)
# return chunks
def chunk_text_with_look_ahead( self, text_list, chunk_look_ahead_len, chunk_len=135, merge_short_last=False ): chunks = []
stride = chunk_len - chunk_look_ahead_len for i in range(0, len(text_list), stride): chk = text_list[i : i + chunk_len] chunks.append(chk) if i + chunk_len >= len(text_list): break
if ( merge_short_last and len(chunks) >= 2 and len(chunks[-1]) < stride # chunk_len * 4 / 5 ): # Merge the last two chunks last = chunks.pop() second_last = chunks.pop() if chunk_look_ahead_len <= 0: chunks.append(second_last + last) else: chunks.append(second_last[:-chunk_look_ahead_len] + last)
actual_chunks = [] for idx in range(len(chunks)): chk = chunks[idx] if chunk_look_ahead_len <= 0: actual_chunks.extend(chk) else: if idx < len(chunks) - 1: actual_chunks.extend(chk[:-chunk_look_ahead_len]) else: actual_chunks.extend(chk)
assert(len(actual_chunks) == len(text_list)) assert(actual_chunks == text_list) return chunks
def chunk_generate( self, ref_audio, ref_text_list, gen_text_list, token_chunk_len, chunk_cond_proportion, chunk_look_ahead_len=0, max_ref_duration=4.5, ref_head_cut=False, ):
gen_text_batches = self.chunk_text_with_look_ahead( gen_text_list, chunk_look_ahead_len, chunk_len=token_chunk_len, merge_short_last=True, )
if len(gen_text_batches) == 0: return None, None
for i, gen_text in enumerate(gen_text_batches): logging.info(f"gen_text {i} with {len(gen_text)} tokens : {gen_text}")
audio, sr = torchaudio.load(ref_audio) logging.info(f"Generating audio in {len(gen_text_batches)} batches...")
target_wave, target_sample_rate, combined_spectrogram = chunk_infer_batch_process( (audio, sr), ref_text_list, gen_text_batches, self.ema_model, self.vocoder, mel_spec_type=mel_spec_type, progress=tqdm, target_rms=target_rms, cross_fade_duration=self.cross_fade_duration, nfe_step=nfe_step, cfg_strength=cfg_strength, sway_sampling_coef=sway_sampling_coef, speed=speed, fix_duration=fix_duration, device=self.device, chunk_cond_proportion=chunk_cond_proportion, chunk_look_ahead=chunk_look_ahead_len, max_ref_duration=max_ref_duration, ref_head_cut=ref_head_cut, ) return target_wave, target_sample_rate
def get_audio_duration(audio_path): audio, sample_rate = torchaudio.load(audio_path) return audio.shape[1] / sample_rate
def get_test_list(testset_path): testset_file_path = testset_path testset_list = [] # list of [ref_text, ref_audio, gen_text, gen_audio(optional)]
with open(testset_file_path, "r") as f: for line in f: content = line.strip().split("|") if len(content) == 2 or len(content) == 3: testset_list.append([content[1], content[0], content[1]]) elif len(content) == 4 or len(content) == 5: testset_list.append([content[1], content[0], content[3], content[2]]) return testset_list
def infer(args, task_queue, rank=0): device_spec = f"cuda:{rank}"
if args.model_cfg is None or args.ckpt is None or args.vocab is None: detoker = SpeechDetokenizer( vocoder_path=args.vocoder, device=device_spec, ) else: detoker = SpeechDetokenizer( vocoder_path=args.vocoder, model_cfg=args.model_cfg, ckpt_file=args.ckpt, vocab_file=args.vocab, device=device_spec, )
token_chunk_len = args.chunk_token chunk_cond_proportion = args.chunk_cond_portion if chunk_cond_proportion > 1 or chunk_cond_proportion <= 0: chunk_cond_proportion = 0.5 # set default
chunk_look_ahead = args.chunk_look_ahead if chunk_look_ahead >= token_chunk_len: chunk_look_ahead = 0
remove_silence = False
output_dir = args.output if not os.path.exists(Path(output_dir)): os.makedirs(Path(output_dir))
# logging.info(f"Using {model}...") logging.info(f"infer with chunk of {token_chunk_len} tokens") logging.info(f"the last {chunk_cond_proportion} of each chunk added into condition") logging.info(f"Using the last {chunk_look_ahead} tokens as look ahead")
gen_nums = 0 while True: try: _tst = task_queue.get() if _tst is None: logging.info("FINISH processing all inputs") break
ref_text_list = _tst[0].split() ref_audio = _tst[1] gen_text_list = _tst[2].split()
if len(_tst) == 4: gen_audio = _tst[3] else: gen_audio = None
ref_wave_path = ( Path(output_dir) / f"{ref_audio.split('/')[-1].split('.')[0]}_ref.wav" ) if gen_audio is None: gen_wave_path = ( Path(output_dir) / f"{ref_audio.split('/')[-1].split('.')[0]}_gen.wav" ) orig_wave_path = None else: gen_wave_path = ( Path(output_dir) / f"{gen_audio.split('/')[-1].split('.')[0]}_gen.wav" ) orig_wave_path = ( Path(output_dir) / f"{gen_audio.split('/')[-1].split('.')[0]}_orig.wav" )
if os.path.exists(gen_wave_path): logging.info(f"{gen_wave_path} already exist, skip") continue
if not os.path.exists(ref_wave_path): os.system(f"cp {ref_audio} {ref_wave_path}")
if gen_audio is not None and os.path.exists(gen_audio) and orig_wave_path: os.system(f"cp {gen_audio} {orig_wave_path}")
generated_wave, target_sample_rate = detoker.chunk_generate( ref_audio, ref_text_list, gen_text_list, token_chunk_len, chunk_cond_proportion, chunk_look_ahead, args.max_ref_duration, args.ref_audio_cut_from_head, )
if generated_wave is None: continue
with open(gen_wave_path, "wb") as f: sf.write(f.name, generated_wave, target_sample_rate) # Remove silence if remove_silence: remove_silence_for_generated_wav(f.name) logging.info(f"write output to: {f.name}")
gen_nums += 1 # if gen_nums >= 10: # break except: logging.info(f"Fail to get new task")
def run_infer_mp(args):
device_list = [0] if "CUDA_VISIBLE_DEVICES" in os.environ: device_list = [int(x.strip()) for x in os.environ["CUDA_VISIBLE_DEVICES"].split(",")] elif "ASCEND_RT_VISIBLE_DEVICES" in os.environ: device_list = [int(x.strip()) for x in os.environ["ASCEND_RT_VISIBLE_DEVICES"].split(",")]
logging.info(f"Using devices: {device_list}") n_procs = len(device_list)
# load testset testset_list = get_test_list(args.testset_path)
ctx = mp.get_context("spawn") with ctx.Manager() as manager: task_queue = manager.Queue() for task in testset_list: task_queue.put(task)
processes = [] for idx in range(n_procs): task_queue.put(None) rank = idx # device_list[idx] p = mp.Process(target=infer, args=(args, task_queue, rank)) p.start() processes.append(p)
for p in processes: p.join()
os.system(f"cp {args.testset_path} {args.output}") logging.info(f"Finish processing of {n_procs}")
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", required=False, help="path to ckpt", ) parser.add_argument( "--model-cfg", required=False, help="path to model_cfg", ) parser.add_argument( "--vocab", required=False, help="path to vocab", ) parser.add_argument( "--vocoder", required=True, help="path to vocoder", ) parser.add_argument( "--testset", dest="testset_path", required=True, help="path of testset file", ) parser.add_argument( "--output", required=True, help="path to output generated audio", ) parser.add_argument( "--chunk-token", required=True, type=int, default=25, help="max number of tokens in a chunk", ) parser.add_argument( "--chunk-look-ahead", required=False, type=int, default=0, help="number of tokens in a chunk as look ahead", ) parser.add_argument( "--chunk-cond-portion", required=True, type=float, default=25, help="the portion at the tail of the prev chunk as condition", ) parser.add_argument( "--max-ref-duration", required=False, type=float, default=4.5, help="the max duration of ref audio in seconds", ) parser.add_argument( "--ref-audio-cut-from-head", default=False, action="store_true", help="cut ref audio from head, if not set, from tail by default", )
args = parser.parse_args()
start_time = time.perf_counter()
run_infer_mp(args)
end_time = time.perf_counter() logging.info("processig time: %f sec\n" % (end_time - start_time)) logging.info(f"Finished! output to : {args.output}")123version https://git-lfs.github.com/spec/v1oid sha256:9f99c218589e92c399190175273fa179d3e0ce6661469e6c19cce1fd4cab6abcsize 650756468517c64bfb2fefb99ac48e7d6bfd72732e3 model.pt123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051hydra: run: # _${datasets.name}/ dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}/${now:%Y-%m-%d}/${now:%H-%M-%S} datasets: name: LibriTTS_960_WenetSpeech4TTS_Premium_Standard_TTSDatawithMultiStyleEmotion_Datatang_Haitianruisheng_Qingshu_XiaoyiF143_Bani # dataset name path: /home/ma-user/work/dehua/unit2speech/u2s_training_data/40ms_imedia_45wh_hubert_large_FSQ_8888_CTC_sampled_EN_CH_4000h_wulan_H20_mt_1280k_lr_3e-4_d2v_phase_nomask_20241018_8p_fromDaxin/LibriTTS_WenetSpeech4TTS_TTSDatawithMultiStyleEmotion_XiaoyiF143_Bani/train-960_Premium_Standard_datatang_haitianruisheng_qingshu_freetalk_style1_all-three batch_size_per_gpu: 2000 # 38400 # 8 GPUs, 8 * 38400 = 307200 batch_size_type: frame # "frame" or "sample" max_samples: 4 # 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models num_workers: 2
optim: epochs: 1000 # 15 learning_rate: 7.5e-5 num_warmup_updates: 20000 # warmup steps grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps max_grad_norm: 1.0 # gradient clipping bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
model: name: CADiT_Base_train_40ms_imedia_45wh_HuBERT_large_FSQ_8888_CTC_sampled_EN_CH_4000h_CTC_LibriTTS_960_WenetSpeech4TTS_Premium_Standard_TTSDatawithMultiStyleEmotion_Datatang_Haitianruisheng_Qingshu_XiaoyiF143_Bani_Shanghai_V100_5n8g_20250414 # model name tokenizer: custom # pinyin; tokenizer type # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt) tokenizer_path: /home/ma-user/work/dehua/unit2speech/u2s_training_data/40ms_imedia_45wh_hubert_large_FSQ_8888_CTC_sampled_EN_CH_4000h_wulan_H20_mt_1280k_lr_3e-4_d2v_phase_nomask_20241018_8p_fromDaxin/LibriTTS_WenetSpeech4TTS_TTSDatawithMultiStyleEmotion_XiaoyiF143_Bani/train-960_Premium_Standard_datatang_haitianruisheng_qingshu_freetalk_style1_all-three/vocab.txt arch: dim: 1024 depth: 22 heads: 16 ff_mult: 2 text_dim: 512 should_extend_text: True conv_layers: 4 checkpoint_activations: False # recompute activations and save memory for extra compute mel_spec: target_sample_rate: 24000 n_mel_channels: 100 hop_length: 256 win_length: 1024 n_fft: 1024 mel_spec_type: vocos # 'vocos' or 'bigvgan' vocoder: is_local: True # use local offline ckpt or not local_path: /home/ma-user/work/dehua/unit2speech/CA-F5-TTS/pretrained_vocoder/charactr/vocos-mel-24khz # local vocoder path
ckpts: logger: tensorboard # wandb | tensorboard | None save_per_updates: 50000 # save checkpoint per steps last_per_steps: 2000 # 5000 # save last checkpoint per steps save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer} # _${datasets.name}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540960110100100010011002100310041005100610071008100910110101011101210131014101510161017101810191021020102110221023102410251026102710281029103103010311032103310341035103610371038103910410401041104210431044104510461047104810491051050105110521053105410551056105710581059106106010611062106310641065106610671068106910710701071107210731074107510761077107810791081080108110821083108410851086108710881089109109010911092109310941095109610971098109911110110011011102110311041105110611071108110911111101111111211131114111511161117111811191121120112111221123112411251126112711281129113113011311132113311341135113611371138113911411401141114211431144114511461147114811491151150115111521153115411551156115711581159116116011611162116311641165116611671168116911711701171117211731174117511761177117811791181180118111821183118411851186118711881189119119011911192119311941195119611971198119912120120012011202120312041205120612071208120912112101211121212131214121512161217121812191221220122112221223122412251226122712281229123123012311232123312341235123612371238123912412401241124212431244124512461247124812491251250125112521253125412551256125712581259126126012611262126312641265126612671268126912712701271127212731274127512761277127812791281280128112821283128412851286128712881289129129012911292129312941295129612971298129913130130013011302130313041305130613071308130913113101311131213131314131513161317131813191321320132113221323132413251326132713281329133133013311332133313341335133613371338133913413401341134213431344134513461347134813491351350135113521353135413551356135713581359136136013611362136313641365136613671368136913713701371137213731374137513761377137813791381380138113821383138413851386138713881389139139013911392139313941395139613971398139914140140014011402140314041405140614071408140914114101411141214131414141514161417141814191421420142114221423142414251426142714281429143143014311432143314341435143614371438143914414401441144214431444144514461447144814491451450145114521453145414551456145714581459146146014611462146314641465146614671468146914714701471147214731474147514761477147814791481480148114821483148414851486148714881489149149014911492149314941495149614971498149915150150015011502150315041505150615071508150915115101511151215131514151515161517151815191521520152115221523152415251526152715281529153153015311532153315341535153615371538153915415401541154215431544154515461547154815491551550155115521553155415551556155715581559156156015611562156315641565156615671568156915715701571157215731574157515761577157815791581580158115821583158415851586158715881589159159015911592159315941595159615971598159916160160016011602160316041605160616071608160916116101611161216131614161516161617161816191621620162116221623162416251626162716281629163163016311632163316341635163616371638163916416401641164216431644164516461647164816491651650165116521653165416551656165716581659166166016611662166316641665166616671668166916716701671167216731674167516761677167816791681680168116821683168416851686168716881689169169016911692169316941695169616971698169917170170017011702170317041705170617071708170917117101711171217131714171517161717171817191721720172117221723172417251726172717281729173173017311732173317341735173617371738173917417401741174217431744174517461747174817491751750175117521753175417551756175717581759176176017611762176317641765176617671768176917717701771177217731774177517761777177817791781780178117821783178417851786178717881789179179017911792179317941795179617971798179918180180018011802180318041805180618071808180918118101811181218131814181518161817181818191821820182118221823182418251826182718281829183183018311832183318341835183618371838183918418401841184218431844184518461847184818491851850185118521853185418551856185718581859186186018611862186318641865186618671868186918718701871187218731874187518761877187818791881880188118821883188418851886188718881889189189018911892189318941895189618971898189919190190019011902190319041905190619071908190919119101911191219131914191519161917191819191921920192119221923192419251926192719281929193193019311932193319341935193619371938193919419401941194219431944194519461947194819491951950195119521953195419551956195719581959196196019611962196319641965196619671968196919719701971197219731974197519761977197819791981980198119821983198419851986198719881989199199019911992199319941995199619971998199922020020002001200220032004200520062007200820092012010201120122013201420152016201720182019202202020212022202320242025202620272028202920320302031203220332034203520362037203820392042040204120422043204420452046204720482049205205020512052205320542055205620572058205920620602061206220632064206520662067206820692072070207120722073207420752076207720782079208208020812082208320842085208620872088208920920902091209220932094209520962097209820992121021002101210221032104210521062107210821092112110211121122113211421152116211721182119212212021212122212321242125212621272128212921321302131213221332134213521362137213821392142140214121422143214421452146214721482149215215021512152215321542155215621572158215921621602161216221632164216521662167216821692172170217121722173217421752176217721782179218218021812182218321842185218621872188218921921902191219221932194219521962197219821992222022002201220222032204220522062207220822092212210221122122213221422152216221722182219222222022212222222322242225222622272228222922322302231223222332234223522362237223822392242240224122422243224422452246224722482249225225022512252225322542255225622572258225922622602261226222632264226522662267226822692272270227122722273227422752276227722782279228228022812282228322842285228622872288228922922902291229222932294229522962297229822992323023002301230223032304230523062307230823092312310231123122313231423152316231723182319232232023212322232323242325232623272328232923323302331233223332334233523362337233823392342340234123422343234423452346234723482349235235023512352235323542355235623572358235923623602361236223632364236523662367236823692372370237123722373237423752376237723782379238238023812382238323842385238623872388238923923902391239223932394239523962397239823992424024002401240224032404240524062407240824092412410241124122413241424152416241724182419242242024212422242324242425242624272428242924324302431243224332434243524362437243824392442440244124422443244424452446244724482449245245024512452245324542455245624572458245924624602461246224632464246524662467246824692472470247124722473247424752476247724782479248248024812482248324842485248624872488248924924902491249224932494249524962497249824992525025002501250225032504250525062507250825092512510251125122513251425152516251725182519252252025212522252325242525252625272528252925325302531253225332534253525362537253825392542540254125422543254425452546254725482549255255025512552255325542555255625572558255925625602561256225632564256525662567256825692572570257125722573257425752576257725782579258258025812582258325842585258625872588258925925902591259225932594259525962597259825992626026002601260226032604260526062607260826092612610261126122613261426152616261726182619262262026212622262326242625262626272628262926326302631263226332634263526362637263826392642640264126422643264426452646264726482649265265026512652265326542655265626572658265926626602661266226632664266526662667266826692672670267126722673267426752676267726782679268268026812682268326842685268626872688268926926902691269226932694269526962697269826992727027002701270227032704270527062707270827092712710271127122713271427152716271727182719272272027212722272327242725272627272728272927327302731273227332734273527362737273827392742740274127422743274427452746274727482749275275027512752275327542755275627572758275927627602761276227632764276527662767276827692772770277127722773277427752776277727782779278278027812782278327842785278627872788278927927902791279227932794279527962797279827992828028002801280228032804280528062807280828092812810281128122813281428152816281728182819282282028212822282328242825282628272828282928328302831283228332834283528362837283828392842840284128422843284428452846284728482849285285028512852285328542855285628572858285928628602861286228632864286528662867286828692872870287128722873287428752876287728782879288288028812882288328842885288628872888288928928902891289228932894289528962897289828992929029002901290229032904290529062907290829092912910291129122913291429152916291729182919292292029212922292329242925292629272928292929329302931293229332934293529362937293829392942940294129422943294429452946294729482949295295029512952295329542955295629572958295929629602961296229632964296529662967296829692972970297129722973297429752976297729782979298298029812982298329842985298629872988298929929902991299229932994299529962997299829993303003000300130023003300430053006300730083009301301030113012301330143015301630173018301930230203021302230233024302530263027302830293033030303130323033303430353036303730383039304304030413042304330443045304630473048304930530503051305230533054305530563057305830593063060306130623063306430653066306730683069307307030713072307330743075307630773078307930830803081308230833084308530863087308830893093090309130923093309430953096309730983099313103100310131023103310431053106310731083109311311031113112311331143115311631173118311931231203121312231233124312531263127312831293133130313131323133313431353136313731383139314314031413142314331443145314631473148314931531503151315231533154315531563157315831593163160316131623163316431653166316731683169317317031713172317331743175317631773178317931831803181318231833184318531863187318831893193190319131923193319431953196319731983199323203200320132023203320432053206320732083209321321032113212321332143215321632173218321932232203221322232233224322532263227322832293233230323132323233323432353236323732383239324324032413242324332443245324632473248324932532503251325232533254325532563257325832593263260326132623263326432653266326732683269327327032713272327332743275327632773278327932832803281328232833284328532863287328832893293290329132923293329432953296329732983299333303300330133023303330433053306330733083309331331033113312331333143315331633173318331933233203321332233233324332533263327332833293333330333133323333333433353336333733383339334334033413342334333443345334633473348334933533503351335233533354335533563357335833593363360336133623363336433653366336733683369337337033713372337333743375337633773378337933833803381338233833384338533863387338833893393390339133923393339433953396339733983399343403400340134023403340434053406340734083409341341034113412341334143415341634173418341934234203421342234233424342534263427342834293433430343134323433343434353436343734383439344344034413442344334443445344634473448344934534503451345234533454345534563457345834593463460346134623463346434653466346734683469347347034713472347334743475347634773478347934834803481348234833484348534863487348834893493490349134923493349434953496349734983499353503500350135023503350435053506350735083509351351035113512351335143515351635173518351935235203521352235233524352535263527352835293533530353135323533353435353536353735383539354354035413542354335443545354635473548354935535503551355235533554355535563557355835593563560356135623563356435653566356735683569357357035713572357335743575357635773578357935835803581358235833584358535863587358835893593590359135923593359435953596359735983599363603600360136023603360436053606360736083609361361036113612361336143615361636173618361936236203621362236233624362536263627362836293633630363136323633363436353636363736383639364364036413642364336443645364636473648364936536503651365236533654365536563657365836593663660366136623663366436653666366736683669367367036713672367336743675367636773678367936836803681368236833684368536863687368836893693690369136923693369436953696369736983699373703700370137023703370437053706370737083709371371037113712371337143715371637173718371937237203721372237233724372537263727372837293733730373137323733373437353736373737383739374374037413742374337443745374637473748374937537503751375237533754375537563757375837593763760376137623763376437653766376737683769377377037713772377337743775377637773778377937837803781378237833784378537863787378837893793790379137923793379437953796379737983799383803800380138023803380438053806380738083809381381038113812381338143815381638173818381938238203821382238233824382538263827382838293833830383138323833383438353836383738383839384384038413842384338443845384638473848384938538503851385238533854385538563857385838593863860386138623863386438653866386738683869387387038713872387338743875387638773878387938838803881388238833884388538863887388838893893890389138923893389438953896389738983899393903900390139023903390439053906390739083909391391039113912391339143915391639173918391939239203921392239233924392539263927392839293933930393139323933393439353936393739383939394394039413942394339443945394639473948394939539503951395239533954395539563957395839593963960396139623963396439653966396739683969397397039713972397339743975397639773978397939839803981398239833984398539863987398839893993990399139923993399439953996399739983999440400400040014002400340044005400640074008400940140104011401240134014401540164017401840194024020402140224023402440254026402740284029403403040314032403340344035403640374038403940440404041404240434044404540464047404840494054050405140524053405440554056405740584059406406040614062406340644065406640674068406940740704071407240734074407540764077407840794084080408140824083408440854086408740884089409409040914092409340944095414104114124134144154164174184194242042142242342442542642742842943430431432433434435436437438439444404414424434444454464474484494545045145245345445545645745845946460461462463464465466467468469474704714724734744754764774784794848048148248348448548648748848949490491492493494495496497498499550500501502503504505506507508509515105115125135145155165175185195252052152252352452552652752852953530531532533534535536537538539545405415425435445455465475485495555055155255355455555655755855956560561562563564565566567568569575705715725735745755765775785795858058158258358458558658758858959590591592593594595596597598599660600601602603604605606607608609616106116126136146156166176186196262062162262362462562662762862963630631632633634635636637638639646406416426436446456466476486496565065165265365465565665765865966660661662663664665666667668669676706716726736746756766776786796868068168268368468568668768868969690691692693694695696697698699770700701702703704705706707708709717107117127137147157167177187197272072172272372472572672772872973730731732733734735736737738739747407417427437447457467477487497575075175275375475575675775875976760761762763764765766767768769777707717727737747757767777787797878078178278378478578678778878979790791792793794795796797798799880800801802803804805806807808809818108118128138148158168178188198282082182282382482582682782882983830831832833834835836837838839848408418428438448458468478488498585085185285385485585685785885986860861862863864865866867868869878708718728738748758768778788798888088188288388488588688788888989890891892893894895896897898899990900901902903904905906907908909919109119129139149159169179189199292092192292392492592692792892993930931932933934935936937938939949409419429439449459469479489499595095195295395495595695795895996960961962963964965966967968969979709719729739749759769779789799898098198298398498598698798898999990991992993994995996997998999123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
from patch_utils import MindSpeedPatchesManager as aspmimport torchaudioimport torchimport logging
def get_vocos_mel_spectrogram_cpu( waveform, n_fft=1024, n_mel_channels=100, target_sample_rate=24000, hop_length=256, win_length=1024,): wave_device = waveform.device waveform = waveform.cpu() mel_stft = torchaudio.transforms.MelSpectrogram( sample_rate=target_sample_rate, n_fft=n_fft, win_length=win_length, hop_length=hop_length, n_mels=n_mel_channels, power=1, center=True, normalized=False, norm=None, ).to(waveform.device) if len(waveform.shape) == 3: waveform = waveform.squeeze(1) # 'b 1 nw -> b nw'
assert len(waveform.shape) == 2
mel = mel_stft(waveform) mel = mel.clamp(min=1e-5).log() waveform = waveform.to(wave_device) mel = mel.to(wave_device) return mel
def load_checkpoint_npu(model, ckpt_path, device: str, dtype=None, use_ema=True): logging.info(f"Load checkpoint {ckpt_path}") if dtype is None: dtype = ( torch.float16 if "cuda" in device or "npu" in device and torch.cuda.get_device_properties(device).major >= 6 and not torch.cuda.get_device_name().endswith("[ZLUDA]") else torch.float32 ) model = model.to(dtype)
ckpt_type = ckpt_path.split(".")[-1] if ckpt_type == "safetensors": from safetensors.torch import load_file
checkpoint = load_file(ckpt_path, device=device) else: checkpoint = torch.load(ckpt_path, map_location=device, weights_only=True)
if use_ema: if ckpt_type == "safetensors": checkpoint = {"ema_model_state_dict": checkpoint} checkpoint["model_state_dict"] = { k.replace("ema_model.", ""): v for k, v in checkpoint["ema_model_state_dict"].items() if k not in ["initted", "step"] }
# patch for backward compatibility, 305e3ea for key in [ "mel_spec.mel_stft.mel_scale.fb", "mel_spec.mel_stft.spectrogram.window", ]: if key in checkpoint["model_state_dict"]: del checkpoint["model_state_dict"][key]
model.load_state_dict(checkpoint["model_state_dict"]) else: if ckpt_type == "safetensors": checkpoint = {"model_state_dict": checkpoint} model.load_state_dict(checkpoint["model_state_dict"])
del checkpoint torch.cuda.empty_cache()
return model.to(device)
def patch_for_npu(): # replace torch.cuda.get_device_capability with implementation from MindSpeed aspm.register_patch('f5_tts.infer.utils_infer.load_checkpoint', load_checkpoint_npu) aspm.register_patch('f5_tts.model.modules.get_vocos_mel_spectrogram', get_vocos_mel_spectrogram_cpu) aspm.apply_patches()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Dehua Tao)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
"""ein notation:b - batchn - sequencent - text sequencenw - raw wave lengthd - dimension"""
from __future__ import annotations
import torchfrom torch import nnimport torch.nn.functional as Ffrom torchaudio.models import Conformer
from x_transformers.x_transformers import RotaryEmbedding
from f5_tts.model.modules import ( TimestepEmbedding, ConvNeXtV2Block, ConvPositionEmbedding, AdaLayerNormZero_Final, precompute_freqs_cis, get_pos_embed_indices,)
from model.modules import CADiTBlock
import logging
# Text embeddingclass TextEmbedding(nn.Module): def __init__( self, text_num_embeds, text_dim, should_extend_text=True, conv_layers=0, conv_mult=2, ): super().__init__() self.text_embed = nn.Embedding( text_num_embeds + 1, text_dim ) # use 0 as filler token
self.should_extend_text = should_extend_text logging.info(f"should_extend_text={should_extend_text}")
if conv_layers > 0: self.extra_modeling = True self.precompute_max_pos = 4096 # ~44s of 24khz audio self.register_buffer( "freqs_cis", precompute_freqs_cis(text_dim, self.precompute_max_pos), persistent=False, ) self.text_blocks = nn.Sequential( *[ ConvNeXtV2Block(text_dim, text_dim * conv_mult) for _ in range(conv_layers) ] ) # # Can be deleted # self.text_blocks = Conformer( # input_dim=text_dim, # num_heads=8, # Not sure it is good # ffn_dim=text_dim * conv_mult, # num_layers=conv_layers, # depthwise_conv_kernel_size=7, # See ConvNeXtV2Block # ) else: self.extra_modeling = False
def forward(self, text: int["b nt"], seq_len, drop_text=False): # noqa: F722 text = ( text + 1 ) # use 0 as filler token. preprocess of batch pad -1, see list_str_to_idx() text = text[ :, :seq_len ] # curtail if character tokens are more than the mel spec tokens batch, text_len = text.shape[0], text.shape[1]
if self.should_extend_text: text = F.pad(text, (0, seq_len - text_len), value=0) else: seq_len = text_len
if drop_text: # cfg for text text = torch.zeros_like(text)
text = self.text_embed(text) # b n -> b n d
# possible extra modeling if self.extra_modeling: # sinus pos emb batch_start = torch.zeros((batch,), dtype=torch.long) pos_idx = get_pos_embed_indices( batch_start, seq_len, max_pos=self.precompute_max_pos ) text_pos_embed = self.freqs_cis[pos_idx] text = text + text_pos_embed
# convnextv2 blocks text = self.text_blocks(text)
# # Can be deleted # # conformer blocks # lengths = torch.Tensor([text.size(1)] * text.size(0)).to(text.device) # text, _ = self.text_blocks(text, lengths)
return text
# noised input audio embedding
class InputAudioEmbedding(nn.Module): def __init__(self, mel_dim, out_dim): super().__init__() self.proj = nn.Linear(mel_dim * 2, out_dim) self.conv_pos_embed = ConvPositionEmbedding(dim=out_dim)
def forward( self, x: float["b n d"], cond: float["b n d"], drop_audio_cond=False, ): # noqa: F722 if drop_audio_cond: # cfg for cond audio cond = torch.zeros_like(cond)
x = self.proj(torch.cat((x, cond), dim=-1)) x = self.conv_pos_embed(x) + x return x
# Transformer backbone using cross-attention DiT blocks
class CADiT(nn.Module): def __init__( self, *, dim, depth=8, heads=8, dim_head=64, dropout=0.1, ff_mult=4, mel_dim=100, text_num_embeds=256, text_dim=None, should_extend_text=True, conv_layers=0, long_skip_connection=False, checkpoint_activations=False, ): super().__init__()
self.time_embed = TimestepEmbedding(dim) if text_dim is None: text_dim = mel_dim self.text_embed = TextEmbedding( text_num_embeds, text_dim, should_extend_text=should_extend_text, conv_layers=conv_layers, )
# Modification: only concatenate noisy and masked speech self.input_embed = InputAudioEmbedding(mel_dim, dim)
self.rotary_embed = RotaryEmbedding(dim_head)
self.dim = dim self.depth = depth
# Modification: use cross-attention DiT block self.transformer_blocks = nn.ModuleList( [ CADiTBlock( dim=dim, text_dim=text_dim, heads=heads, dim_head=dim_head, ff_mult=ff_mult, dropout=dropout, ) for _ in range(depth) ] ) self.long_skip_connection = ( nn.Linear(dim * 2, dim, bias=False) if long_skip_connection else None )
self.norm_out = AdaLayerNormZero_Final(dim) # final modulation self.proj_out = nn.Linear(dim, mel_dim)
self.checkpoint_activations = checkpoint_activations
def ckpt_wrapper(self, module): # https://github.com/chuanyangjin/fast-DiT/blob/main/models.py def ckpt_forward(*inputs): outputs = module(*inputs) return outputs
return ckpt_forward
def forward( self, x: float["b n d"], # nosied input audio # noqa: F722 cond: float["b n d"], # masked cond audio # noqa: F722 text: int["b nt"], # text # noqa: F722 time: float["b"] | float[""], # time step # noqa: F821 F722 drop_audio_cond, # cfg for cond audio drop_text, # cfg for text mask: bool["b n"] | None = None, # noqa: F722 ): batch, seq_len = x.shape[0], x.shape[1] if time.ndim == 0: time = time.repeat(batch)
# t: conditioning time, x: noised input audio t = self.time_embed(time) text_embed = self.text_embed(text, seq_len, drop_text=drop_text) x = self.input_embed(x, cond, drop_audio_cond=drop_audio_cond)
rope = self.rotary_embed.forward_from_seq_len(seq_len)
if self.long_skip_connection is not None: residual = x
for block in self.transformer_blocks: if self.checkpoint_activations: x = torch.utils.checkpoint.checkpoint( self.ckpt_wrapper(block), x, text_embed, t, mask, rope ) else: x = block(x, text_embed, t, mask=mask, rope=rope)
if self.long_skip_connection is not None: x = self.long_skip_connection(torch.cat((x, residual), dim=-1))
x = self.norm_out(x, t) output = self.proj_out(x)
return output123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Dehua Tao)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
"""ein notation:b - batchn - sequencent - text sequencenw - raw wave lengthd - dimension"""
from __future__ import annotations
# import math# from typing import Optional
import torchimport torch.nn.functional as F# import torchaudiofrom librosa.filters import mel as librosa_mel_fnfrom torch import nnfrom x_transformers.x_transformers import apply_rotary_pos_emb
mel_basis_cache = {}hann_window_cache = {}
from f5_tts.model.modules import AdaLayerNormZero, Attention, AttnProcessor, FeedForward
# Cross-attention with audio as query and text as key/value
class CrossAttention(nn.Module): def __init__( self, processor: CrossAttnProcessor, dim: int, dim_to_k: int, heads: int = 8, dim_head: int = 64, dropout: float = 0.0, ): super().__init__()
if not hasattr(F, "scaled_dot_product_attention"): raise ImportError( "Attention equires PyTorch 2.0, to use it, please upgrade PyTorch to 2.0." )
self.processor = processor
self.dim = dim self.heads = heads self.inner_dim = dim_head * heads self.dropout = dropout
self.to_q = nn.Linear(dim, self.inner_dim) self.to_k = nn.Linear(dim_to_k, self.inner_dim) self.to_v = nn.Linear(dim_to_k, self.inner_dim)
self.to_out = nn.ModuleList([]) self.to_out.append(nn.Linear(self.inner_dim, dim)) self.to_out.append(nn.Dropout(dropout))
def forward( self, x_for_q: float["b n d"], # (noisy + masked) audio input, x_for_q # noqa: F722 x_for_k: float["b n d"] = None, # text input, x_for_k # noqa: F722 mask: bool["b n"] | None = None, # noqa: F722 rope=None, # rotary position embedding for x ) -> torch.Tensor: return self.processor( self, x_for_q, x_for_k, mask=mask, rope=rope, )
# Cross-attention processor
class CrossAttnProcessor: def __init__(self): pass
def __call__( self, attn: CrossAttention, x_for_q: float["b n d"], # (noisy + masked) audio input, x_for_q # noqa: F722 x_for_k: float["b n d"], # text input, x_for_k # noqa: F722 mask: bool["b n"] | None = None, # noqa: F722 rope=None, # rotary position embedding ) -> torch.FloatTensor: batch_size = x_for_q.shape[0]
# `sample` projections. query = attn.to_q(x_for_q) key = attn.to_k(x_for_k) value = attn.to_v(x_for_k)
# apply rotary position embedding if rope is not None: freqs, xpos_scale = rope q_xpos_scale, k_xpos_scale = ( (xpos_scale, xpos_scale**-1.0) if xpos_scale is not None else (1.0, 1.0) )
query = apply_rotary_pos_emb(query, freqs, q_xpos_scale) key = apply_rotary_pos_emb(key, freqs, k_xpos_scale)
# attention inner_dim = key.shape[-1] head_dim = inner_dim // attn.heads query = query.view(batch_size, -1, attn.heads, head_dim).transpose(1, 2) key = key.view(batch_size, -1, attn.heads, head_dim).transpose(1, 2) value = value.view(batch_size, -1, attn.heads, head_dim).transpose(1, 2)
# mask. e.g. inference got a batch with different target durations, mask out the padding if mask is not None: attn_mask = mask attn_mask = attn_mask.unsqueeze(1).unsqueeze(1) # 'b n -> b 1 1 n' attn_mask = attn_mask.expand( batch_size, attn.heads, query.shape[-2], key.shape[-2] ) else: attn_mask = None
x = F.scaled_dot_product_attention( query, key, value, attn_mask=attn_mask, dropout_p=0.0, is_causal=False ) x = x.transpose(1, 2).reshape(batch_size, -1, attn.heads * head_dim) x = x.to(query.dtype)
# linear proj x = attn.to_out[0](x) # dropout x = attn.to_out[1](x)
if mask is not None: mask = mask.unsqueeze(-1) x = x.masked_fill(~mask, 0.0)
return x
# Cross-attention DiT Block
class CADiTBlock(nn.Module): def __init__(self, dim, text_dim, heads, dim_head, ff_mult=4, dropout=0.1): super().__init__()
self.attn_norm = AdaLayerNormZero(dim) self.attn = Attention( processor=AttnProcessor(), dim=dim, heads=heads, dim_head=dim_head, dropout=dropout, )
self.cross_attn_norm = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6) self.cross_attn = CrossAttention( processor=CrossAttnProcessor(), dim=dim, dim_to_k=text_dim, heads=heads, dim_head=dim_head, dropout=dropout, )
self.ff_norm = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6) self.ff = FeedForward( dim=dim, mult=ff_mult, dropout=dropout, approximate="tanh" )
def forward( self, x, y, t, mask=None, rope=None, ): # x: audio input, y: text input, t: time embedding
## for self-attention
# pre-norm & modulation for attention input norm, gate_msa, shift_mlp, scale_mlp, gate_mlp = self.attn_norm(x, emb=t)
# attention attn_output = self.attn(x=norm, mask=mask, rope=rope)
# process attention output for input x x = x + gate_msa.unsqueeze(1) * attn_output
## for cross-attention ca_norm = self.cross_attn_norm(x) cross_attn_output = self.cross_attn(ca_norm, y, mask=mask, rope=rope) x = x + cross_attn_output
norm = self.ff_norm(x) * (1 + scale_mlp[:, None]) + shift_mlp[:, None] ff_output = self.ff(norm) x = x + gate_mlp.unsqueeze(1) * ff_output
return x
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122# copied from https://gitee.com/ascend/MindSpeed/blob/master/mindspeed/patch_utils.py
import importlibimport sysimport types
def get_func_name(func): if isinstance(func, str): return func return '.'.join((func.__module__, func.__qualname__))
def dummy_function_wrapper(func_name): def dummy_function(*args, **kwargs): raise RuntimeError('function {} no exist'.format(func_name))
return dummy_function
class Patch: def __init__(self, orig_func_name, new_func, create_dummy): split_name = orig_func_name.rsplit('.', 1) if len(split_name) == 1: self.orig_module_name, self.orig_func_name = orig_func_name, None else: self.orig_module_name, self.orig_func_name = split_name self.orig_module = None self.orig_func = None
self.patch_func = None self.wrappers = [] if new_func is None: new_func = dummy_function_wrapper(orig_func_name) self.set_patch_func(new_func) self.is_applied = False self.create_dummy = create_dummy
@property def orig_func_id(self): return id(self.orig_func)
@property def patch_func_id(self): return id(self.patch_func)
def set_patch_func(self, new_func, force_patch=False): if hasattr(new_func, '__name__') and new_func.__name__.endswith(('wrapper', 'decorator')): self.wrappers.append(new_func) else: if self.patch_func and not force_patch: raise RuntimeError('the patch of {} exist !'.format(self.orig_func_name)) self.patch_func = new_func self.is_applied = False
def apply_patch(self): if self.is_applied: return
self.orig_module, self.orig_func = Patch.parse_path(self.orig_module_name, self.orig_func_name, self.create_dummy)
final_patch_func = self.orig_func if self.patch_func is not None: final_patch_func = self.patch_func
for wrapper in self.wrappers: final_patch_func = wrapper(final_patch_func)
if self.orig_func_name is not None: setattr(self.orig_module, self.orig_func_name, final_patch_func) for key, value in sys.modules.copy().items(): if self.orig_func_name is not None and hasattr(value, self.orig_func_name) \ and id(getattr(value, self.orig_func_name)) == self.orig_func_id: setattr(value, self.orig_func_name, final_patch_func) self.is_applied = True
@staticmethod def parse_path(module_path, function_name, create_dummy): from importlib.machinery import ModuleSpec modules = module_path.split('.') for i in range(1, len(modules) + 1): parent = '.'.join(modules[:i - 1]) path = '.'.join(modules[:i]) try: importlib.import_module(path) except ModuleNotFoundError as e: if not parent or not hasattr(importlib.import_module(parent), modules[i - 1]): if not create_dummy: raise ModuleNotFoundError(e) from e sys.modules[path] = types.ModuleType(path) sys.modules[path].__file__ = 'mindspeed.dummy_module.py' sys.modules[path].__spec__ = ModuleSpec(path, None) if parent: setattr(importlib.import_module(parent), modules[i - 1], sys.modules[path]) else: module = getattr(importlib.import_module(parent), modules[i - 1]) if hasattr(module, function_name): return module, getattr(module, function_name) elif create_dummy: return module, dummy_function_wrapper(function_name) else: raise RuntimeError('no exist {} of {}'.format(function_name, module))
if function_name is not None and not hasattr(sys.modules[module_path], function_name): setattr(sys.modules[module_path], function_name, None) return sys.modules[module_path], getattr(sys.modules[module_path], function_name) if function_name is not None else None
class MindSpeedPatchesManager: patches_info = {}
@staticmethod def register_patch(orig_func_name, new_func=None, force_patch=False, create_dummy=False): if orig_func_name not in MindSpeedPatchesManager.patches_info: MindSpeedPatchesManager.patches_info[orig_func_name] = Patch(orig_func_name, new_func, create_dummy) else: MindSpeedPatchesManager.patches_info.get(orig_func_name).set_patch_func(new_func, force_patch)
@staticmethod def apply_patches(): for patch in MindSpeedPatchesManager.patches_info.values(): patch.apply_patch()12345678910111213Cythonnumpy==1.23.4g2p_enjieba_fastjiebaLangSegment>=0.2.0wordsegmentpypinyincn2ang2pM#torch==2.1.0WeTextProcessingf5-tts==0.3.4123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Dehua Tao,# Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
import osimport sys
os.environ["PYTOCH_ENABLE_MPS_FALLBACK"] = "1" # for MPS device compatibilityfrom importlib.resources import filesimport matplotlib
matplotlib.use("Agg")
import numpy as npimport torchimport torchaudioimport tqdmimport logging# torch.set_printoptions(profile="full")# from f5_tts.model import CFMfrom f5_tts.model.utils import ( get_tokenizer, convert_char_to_pinyin,)from f5_tts.model.modules import MelSpec
device = ( "cuda" if torch.cuda.is_available() else ( "xpu" if torch.xpu.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" ))
# -----------------------------------------
target_sample_rate = 24000n_mel_channels = 100hop_length = 256win_length = 1024n_fft = 1024mel_spec_type = "vocos"target_rms = 0.1cross_fade_duration = 0.15ode_method = "euler"nfe_step = 32 # 16, 32cfg_strength = 2.0sway_sampling_coef = -1.0speed = 1.0fix_duration = Noneseed = 3214
# -----------------------------------------def chunk_infer_batch_process( ref_audio, ref_text, gen_text_batches, model_obj, vocoder, mel_spec_type="vocos", progress=tqdm, target_rms=0.1, cross_fade_duration=0.15, nfe_step=32, cfg_strength=2.0, sway_sampling_coef=-1.0, speed=1.0, fix_duration=None, device=None, chunk_cond_proportion=0.5, chunk_look_ahead=0, max_ref_duration=4.5, ref_head_cut=False,): audio, sr = ref_audio if audio.shape[0] > 1: audio = torch.mean(audio, dim=0, keepdim=True)
rms = torch.sqrt(torch.mean(torch.square(audio))) if rms < target_rms: audio = audio * target_rms / rms if sr != target_sample_rate: resampler = torchaudio.transforms.Resample(sr, target_sample_rate) audio = resampler(audio)
logging.info( "audio shape:" + str(audio.shape) + "; ref_text shape:" + str(len(ref_text)) ) ref_duration = audio.shape[1] / target_sample_rate if ref_duration > max_ref_duration: reserved_ref_audio_len = round(max_ref_duration * target_sample_rate) if ref_head_cut: logging.info(f"Using the first {max_ref_duration} seconds as ref audio") audio = audio[:, :reserved_ref_audio_len] ref_text = ref_text[ : round(max_ref_duration * len(ref_text) / ref_duration) ] else: logging.info(f"Using the last {max_ref_duration} seconds as ref audio") audio = audio[:, -reserved_ref_audio_len:] ref_text = ref_text[ -round(max_ref_duration * len(ref_text) / ref_duration) : ] logging.info( "audio shape:" + str(audio.shape) + "; ref_text shape:" + str(len(ref_text)) ) audio = audio.to(device)
generated_waves = [] spectrograms = []
# fixed_ref_audio_len = audio.shape[-1] // hop_length mel_spec_module = MelSpec(mel_spec_type=mel_spec_type) fixed_ref_audio_mel_spec = mel_spec_module(audio) # The last dim should be num_channels fixed_ref_audio_mel_cond = fixed_ref_audio_mel_spec.permute(0, 2, 1) fixed_ref_audio_len = fixed_ref_audio_mel_cond.shape[1]
assert isinstance(ref_text, list) is True fixed_ref_text = ref_text[:] fixed_ref_text_len = len(fixed_ref_text)
mel_cond = fixed_ref_audio_mel_cond.clone()
prev_chunk_audio_len = 0
for i, gen_text in enumerate(progress.tqdm(gen_text_batches)): # Prepare the text final_text_list = [ref_text + gen_text] logging.info(f"final_text_list: {final_text_list}")
if fix_duration is not None: duration = int(fix_duration * target_sample_rate / hop_length) else: # Calculate duration assert isinstance(gen_text, list) is True gen_text_len = len(gen_text) duration = ( fixed_ref_audio_len + prev_chunk_audio_len + int(fixed_ref_audio_len / fixed_ref_text_len * gen_text_len / speed) ) logging.info(f"Duration: {duration}")
# inference with torch.inference_mode(): logging.info(f"generate with nfe_step:{nfe_step}, cfg_strength:{cfg_strength}, sway_sampling_coef:{sway_sampling_coef}") # logging.info("mel_cond: " + str(mel_cond)) generated, _ = model_obj.sample( cond=mel_cond, text=final_text_list, duration=duration, steps=nfe_step, cfg_strength=cfg_strength, sway_sampling_coef=sway_sampling_coef, seed=seed, ) generated = generated.to(torch.float32) logging.info("gen mel shape: " + str(generated.shape))
# try to remove condition mel stripped_generated = generated[ :, (fixed_ref_audio_len + prev_chunk_audio_len) :, : ]
# remove chunk_look_ahead from the tail of each generated mel look_ahead_mel_len = round( (duration - fixed_ref_audio_len - prev_chunk_audio_len) * chunk_look_ahead / len(gen_text) ) if look_ahead_mel_len > 0 and i < len(gen_text_batches) - 1: stripped_generated_without_look_ahead = stripped_generated[ :, :(-look_ahead_mel_len), :, ] # try to remove the chunk_look_ahead from the tail of gen_text gen_text = gen_text[:-chunk_look_ahead] else: stripped_generated_without_look_ahead = stripped_generated logging.info("gen mel shape: %s, gen text len: %d" % (str(stripped_generated_without_look_ahead.shape), len(gen_text))) # logging.info("generated mel: " + str(generated))
# prev chunk audio len is the length without fixed condition and chunk look ahead prev_chunk_audio_len = stripped_generated_without_look_ahead.shape[1] # prev_chunk_audio_len_with_look_ahead = stripped_generated.shape[1]
# generate wav with look ahead generated_mel_spec = stripped_generated_without_look_ahead.permute(0, 2, 1) # generated_mel_spec = stripped_generated.permute(0, 2, 1)
if mel_spec_type == "vocos": generated_wave = vocoder.decode(generated_mel_spec) elif mel_spec_type == "bigvgan": generated_wave = vocoder(generated_mel_spec)
# strip look ahead wav from generated wav # if look_ahead_mel_len > 0 and i < len(gen_text_batches) - 1: # look_ahead_wav_len = round( # look_ahead_mel_len # * generated_wave.shape[1] # / prev_chunk_audio_len_with_look_ahead # ) # generated_wave = generated_wave[:, :-look_ahead_wav_len]
if rms < target_rms: generated_wave = generated_wave * rms / target_rms
logging.info("gen wav shape: " + str(generated_wave.shape)) # logging.info("generated wav: " + str(generated_wave))
# wav -> numpy generated_wave = generated_wave.squeeze().cpu().numpy()
generated_waves.append(generated_wave) spectrograms.append(generated_mel_spec[0].cpu().numpy())
prev_chunk_cond_audio_len = round(chunk_cond_proportion * prev_chunk_audio_len) if prev_chunk_audio_len > prev_chunk_cond_audio_len: gen_text_cond = gen_text[-round(chunk_cond_proportion * len(gen_text)):] prev_chunk_audio_len = prev_chunk_cond_audio_len generated_cond = stripped_generated_without_look_ahead[:, (-prev_chunk_audio_len):, :] else: generated_cond = stripped_generated_without_look_ahead gen_text_cond = gen_text
logging.info("gen text cond len: %d, gen mel cond len: %d" % (len(gen_text_cond), len(generated_cond)))
ref_text = fixed_ref_text + gen_text_cond mel_cond = torch.cat([fixed_ref_audio_mel_cond, generated_cond], dim=1)
# Combine all generated waves with cross-fading if cross_fade_duration <= 0: # Simply concatenate logging.info("simply concatenate") final_wave = np.concatenate(generated_waves) else: final_wave = generated_waves[0] for i in range(1, len(generated_waves)): prev_wave = final_wave next_wave = generated_waves[i]
# Calculate cross-fade samples, ensuring it does not exceed wave lengths cross_fade_samples = int(cross_fade_duration * target_sample_rate) cross_fade_samples = min(cross_fade_samples, len(prev_wave), len(next_wave))
if cross_fade_samples <= 0: # No overlap possible, concatenate final_wave = np.concatenate([prev_wave, next_wave]) continue
# Overlapping parts prev_overlap = prev_wave[-cross_fade_samples:] next_overlap = next_wave[:cross_fade_samples]
# Fade out and fade in # fade_out = np.linspace(1, 0, cross_fade_samples) # fade_in = np.linspace(0, 1, cross_fade_samples)
wave_window = np.hamming(2 * cross_fade_samples) fade_out = wave_window[cross_fade_samples:] fade_in = wave_window[:cross_fade_samples]
# Cross-faded overlap cross_faded_overlap = prev_overlap * fade_out + next_overlap * fade_in
# Combine new_wave = np.concatenate( [ prev_wave[:-cross_fade_samples], cross_faded_overlap, next_wave[cross_fade_samples:], ] )
final_wave = new_wave
# Create a combined spectrogram combined_spectrogram = np.concatenate(spectrograms, axis=1)
return final_wave, target_sample_rate, combined_spectrogram1234567# SpeechTokenizerInference
# 25Hz(80ms) speech semantic tokenizer based on fairseq
pip install -r requirements_npu.txt
123version https://git-lfs.github.com/spec/v1oid sha256:c65b209e916297d6b1b2692c04ebc765da894e71beab290da7131b7892d9262dsize 38669805541960e4618b84d277d646c22e5f6e9754d model.pt12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910000 11 12 13 14 15 16 17 18 19 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344_name: nullcommon: _name: null no_progress_bar: false log_interval: 100 log_format: json log_file: null aim_repo: null aim_run_hash: null tensorboard_logdir: tblog wandb_project: null azureml_logging: false seed: 1337 cpu: false tpu: false bf16: false memory_efficient_bf16: false fp16: true memory_efficient_fp16: true fp16_no_flatten_grads: false fp16_init_scale: 128 fp16_scale_window: null fp16_scale_tolerance: 0.0 on_cpu_convert_precision: false min_loss_scale: 0.0001 threshold_loss_scale: null amp: false amp_batch_retries: 2 amp_init_scale: 128 amp_scale_window: null user_dir: null empty_cache_freq: 0 all_gather_list_size: 16384 model_parallel_size: 1 quantization_config_path: null profile: false reset_logging: false suppress_crashes: false use_plasma_view: false plasma_path: /tmp/plasmacommon_eval: _name: null path: null post_process: null quiet: false model_overrides: '{}' results_path: nulldistributed_training: _name: null distributed_world_size: 64 distributed_num_procs: 8 distributed_rank: 0 distributed_backend: nccl distributed_init_method: tcp://modelarts-job-4e3029c5-de6d-4973-85ce-9be855ccbfcf:6000 distributed_port: -1 device_id: 0 distributed_no_spawn: false ddp_backend: no_c10d ddp_comm_hook: none bucket_cap_mb: 25 fix_batches_to_gpus: false find_unused_parameters: true gradient_as_bucket_view: false fast_stat_sync: false heartbeat_timeout: -1 broadcast_buffers: false slowmo_momentum: null slowmo_base_algorithm: localsgd localsgd_frequency: 3 nprocs_per_node: 8 pipeline_model_parallel: false pipeline_balance: null pipeline_devices: null pipeline_chunks: 0 pipeline_encoder_balance: null pipeline_encoder_devices: null pipeline_decoder_balance: null pipeline_decoder_devices: null pipeline_checkpoint: never zero_sharding: none fp16: true memory_efficient_fp16: true tpu: false no_reshard_after_forward: false fp32_reduce_scatter: false cpu_offload: false use_sharded_state: false not_fsdp_flatten_parameters: falsedataset: _name: null num_workers: 1 skip_invalid_size_inputs_valid_test: true max_tokens: 450000 batch_size: null required_batch_size_multiple: 8 required_seq_len_multiple: 1 dataset_impl: null data_buffer_size: 10 train_subset: train valid_subset: valid combine_valid_subsets: null ignore_unused_valid_subsets: false validate_interval: 1 validate_interval_updates: 1000000 validate_after_updates: 0 fixed_validation_seed: null disable_validation: false max_tokens_valid: 450000 batch_size_valid: null max_valid_steps: null curriculum: 0 gen_subset: test num_shards: 1 shard_id: 0 grouped_shuffling: false update_epoch_batch_itr: false update_ordered_indices_seed: falseoptimization: _name: null max_epoch: 0 max_update: 700000 stop_time_hours: 0.0 clip_norm: 1.0 sentence_avg: false update_freq: - 4 lr: - 0.0015 stop_min_lr: -1.0 use_bmuf: false skip_remainder_batch: falsecheckpoint: _name: null save_dir: checkpoints restore_file: checkpoint_last.pt continue_once: null finetune_from_model: null reset_dataloader: false reset_lr_scheduler: false reset_meters: false reset_optimizer: false optimizer_overrides: '{}' save_interval: 1 save_interval_updates: 1000000 keep_interval_updates: 100 keep_interval_updates_pattern: -1 keep_last_epochs: -1 keep_best_checkpoints: -1 no_save: false no_epoch_checkpoints: false no_last_checkpoints: false no_save_optimizer_state: false best_checkpoint_metric: loss maximize_best_checkpoint_metric: false patience: -1 checkpoint_suffix: '' checkpoint_shard_count: 1 load_checkpoint_on_all_dp_ranks: false write_checkpoints_asynchronously: false model_parallel_size: 1bmuf: _name: null block_lr: 1.0 block_momentum: 0.875 global_sync_iter: 50 warmup_iterations: 500 use_nbm: false average_sync: false distributed_world_size: 64generation: _name: null beam: 5 nbest: 1 max_len_a: 0.0 max_len_b: 200 min_len: 1 match_source_len: false unnormalized: false no_early_stop: false no_beamable_mm: false lenpen: 1.0 unkpen: 0.0 replace_unk: null sacrebleu: false score_reference: false prefix_size: 0 no_repeat_ngram_size: 0 sampling: false sampling_topk: -1 sampling_topp: -1.0 constraints: null temperature: 1.0 diverse_beam_groups: -1 diverse_beam_strength: 0.5 diversity_rate: -1.0 print_alignment: null print_step: false lm_path: null lm_weight: 0.0 iter_decode_eos_penalty: 0.0 iter_decode_max_iter: 10 iter_decode_force_max_iter: false iter_decode_with_beam: 1 iter_decode_with_external_reranker: false retain_iter_history: false retain_dropout: false retain_dropout_modules: null decoding_format: null no_seed_provided: false eos_token: nulleval_lm: _name: null output_word_probs: false output_word_stats: false context_window: 0 softmax_batch: 9223372036854775807interactive: _name: null buffer_size: 0 input: '-'model: _name: hubert label_rate: 50.0 extractor_mode: layer_norm encoder_layers: 24 encoder_embed_dim: 1024 encoder_ffn_embed_dim: 4096 encoder_attention_heads: 16 activation_fn: gelu layer_type: transformer dropout: 0.0 attention_dropout: 0.0 activation_dropout: 0.0 encoder_layerdrop: 0.0 dropout_input: 0.0 dropout_features: 0.0 final_dim: 768 untie_final_proj: true layer_norm_first: true conv_feature_layers: '[(512,10,5)] + [(512,3,2)] * 4 + [(512,2,2)] * 2' conv_bias: false logit_temp: 0.1 target_glu: false feature_grad_mult: 1.0 mask_length: 10 mask_prob: 0.8 mask_selection: static mask_other: 0.0 no_mask_overlap: false mask_min_space: 1 mask_channel_length: 10 mask_channel_prob: 0.0 mask_channel_selection: static mask_channel_other: 0.0 no_mask_channel_overlap: false mask_channel_min_space: 1 conv_pos: 128 conv_pos_groups: 16 latent_temp: - 2.0 - 0.5 - 0.999995 skip_masked: false skip_nomask: false checkpoint_activations: false required_seq_len_multiple: 2 depthwise_conv_kernel_size: 31 attn_type: '' pos_enc_type: abs fp16: falsetask: _name: hubert_pretraining data: data fine_tuning: false labels: - km label_dir: config label_rate: 50.0 sample_rate: 16000 normalize: true enable_padding: false max_keep_size: 320000 max_sample_size: 320000 min_sample_size: 16000 single_target: false random_crop: true pad_audio: falsecriterion: _name: hubert pred_masked_weight: 1.0 pred_nomask_weight: 0.0 loss_weights: - 10.0 log_keys: []optimizer: _name: adam adam_betas: (0.9,0.98) adam_eps: 1.0e-06 weight_decay: 0.01 use_old_adam: false fp16_adam_stats: false tpu: false lr: - 0.0015lr_scheduler: _name: polynomial_decay warmup_updates: 32000 force_anneal: null end_learning_rate: 0.0 power: 1.0 total_num_update: 700000.0 lr: - 0.0015scoring: nullbpe: nulltokenizer: nullema: _name: null store_ema: false ema_decay: 0.9999 ema_start_update: 0 ema_seed_model: null ema_update_freq: 1 ema_fp32: falsejob_logging_cfg: version: 1 formatters: simple: format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' handlers: console: class: logging.StreamHandler formatter: simple stream: ext://sys.stdout file: class: logging.FileHandler formatter: simple filename: hydra_train.log root: level: INFO handlers: - console - file disable_existing_loggers: false12345678910111213141516171819202122232425262728293031323334# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
from patch_utils import MindSpeedPatchesManager as aspmimport torch_npu
def cnn_feature_forward_npu(self, x):
# BxT -> BxCxT x = x.unsqueeze(1)
for conv in self.conv_layers: # x = conv(x) x_tmp = conv[:-1](x) x = torch_npu.npu_gelu(x_tmp)
return x
def patch_for_npu(): # replace torch.cuda.get_device_capability with implementation from MindSpeed aspm.register_patch('fairseq.models.wav2vec.wav2vec2.ConvFeatureExtractionModel.forward', cnn_feature_forward_npu) aspm.apply_patches()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140# Copyright (C) 2025. Huawei Technologies Co., Ltd. All Rights Reserved. (authors: Daxin Tan,# Xiao Chen)
# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
from simple_tokenizer_infer import SpeechTokenizerimport argparseimport librosaimport loggingfrom pathlib import Path
def main(args): ref_wav_file_list = [] line_info_list = [] reconstruct_wav_file_list = []
logging.info(f"loading eval file list") base_path = Path(args.input_list).parent with open(args.input_list, "r") as input_file: for line in input_file: fields = line.strip().split("|") if args.input_type == "tts": ref_wav_file_list.append(fields[2]) else: reconstruct_wav_file_list.append(fields[4]) ref_wav_file_list.append(fields[2]) line_info_list.append([fields[2], fields[0], fields[3]]) # ref wav path, gen wav id, text
logging.info(f"loading ref audio") raw_ref_wavs_list = [] # 用librosa 加载后的raw wave 波形数据 for file_path in ref_wav_file_list: # 加载波形数据 raw_wav, sr = librosa.load( (base_path / file_path), sr=16000 ) # sr=None 保留原始采样率 raw_ref_wavs_list.append(raw_wav)
logging.info(f"extracting token for ref audio") if args.ckpt is not None: tokenizer = SpeechTokenizer( ckpt_path=args.ckpt, cfg_path=args.cfg_path, cfg_name=args.cfg_name ) else: tokenizer = SpeechTokenizer() ref_token_list, ref_token_info_list = tokenizer.extract(raw_ref_wavs_list)
if args.input_type == "reconstruct": logging.info(f"loading reconstruct audio") raw_reconstruct_wav_list = [] # 用librosa 加载后的raw wave 波形数据 for file_path in reconstruct_wav_file_list: # 加载波形数据 raw_wav, sr = librosa.load( (base_path / file_path), sr=16000 ) # sr=None 保留原始采样率 raw_reconstruct_wav_list.append(raw_wav)
logging.info(f"extracting token for reconstruct audio") recon_token_list, recon_token_info_list = tokenizer.extract(raw_reconstruct_wav_list) assert(len(ref_token_info_list) == len(recon_token_info_list))
assert(len(ref_token_info_list) == len(line_info_list)) with open(args.output_file, "w") as output_file: logging.info(f"writing output file") if args.input_type == "tts": for ref, line_info in zip(ref_token_info_list, line_info_list): ref_units = ref["reduced_unit_sequence"] # logging.info(ref_units) ref_path = str((base_path / line_info[0])) output_file.write(f"{ref_path}|{ref_units}|{line_info[1]}|{line_info[2]}\n") else: for ref, recon, line_info in zip(ref_token_info_list, recon_token_info_list, line_info_list): ref_units = ref["reduced_unit_sequence"] recon_units = recon["reduced_unit_sequence"] # logging.info(ref_units) ref_path = str((base_path / line_info[0])) output_file.write(f"{ref_path}|{ref_units}|{line_info[1]}|{recon_units}|{line_info[2]}\n") output_file.close() logging.info("Finished") return
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", dest="ckpt", required=False, help="path to ckpt", ) parser.add_argument( "--cfg-path", dest="cfg_path", required=False, default="config", help="path to config", ) parser.add_argument( "--cfg-name", dest="cfg_name", required=False, default="hubert_config", help="name of config", ) parser.add_argument( "--input-list", dest="input_list", required=True, help="list of input wavform", ) parser.add_argument( "--output-file", dest="output_file", required=True, help="file to output speech tokens", ) parser.add_argument( "--input-type", default="tts", type=str, required=True, help=f"test fil list type: tts or reconstruct, seedtts format", ) args = parser.parse_args()
if args.input_type not in {"tts", "reconstruct"}: logging.info(f"Input type must be tts or reconstruct") exit() main(args).gitattributes+14
.gitignoreAdded+138
00004557-00000030.wavAdded+3
004892.wavAdded+3
LICENSEAdded+202
README.md+45-3
README_CN.mdAdded+48
Third_Party_Open_Source_Software_NoticeAdded+1289
evaluation/README.mdAdded+9
evaluation/eval_detok_en.pyAdded+269
evaluation/eval_detok_zh.pyAdded+144
evaluation/eval_sim.pyAdded+188
evaluation/patch_unispeech.pyAdded+131
evaluation/patch_utils.pyAdded+122
evaluation/requirements_sim.txtAdded+7
evaluation/requirements_wer.txtAdded+12
figs/CADiT.jpgAdded

Large File Pointer Details
- SHA256: 74a3f775e98a3e0311e5c38edef0581741df2c1958b5aa18c20c5a46fa0e3c46
- Pointer size: 131 Bytes
- Size of remote file: 932 kB
figs/F5-streaming.jpgAdded

Large File Pointer Details
- SHA256: 195418c57f1beb37a7d22319fa975c0901001eb1b88ecb37711c748cf0810a57
- Pointer size: 132 Bytes
- Size of remote file: 1.04 MB
figs/TTS.jpgAdded

Large File Pointer Details
- SHA256: e7c7e75fe30be5721405eb2dfd42699fed899362507fd189ba3d782febd721f7
- Pointer size: 131 Bytes
- Size of remote file: 457 kB
figs/eval1.jpgAdded

Large File Pointer Details
- SHA256: 3cb81b905bc96483adb6dc9b2c21f482eb771545fb3abe5894005cc831c80e90
- Pointer size: 131 Bytes
- Size of remote file: 462 kB
figs/eval2.jpgAdded

Large File Pointer Details
- SHA256: f5c289c2bdd33ac197885a4672b90655d8f540facefbce1dd8360bce9314eaa1
- Pointer size: 131 Bytes
- Size of remote file: 247 kB
figs/eval3.jpgAdded

Large File Pointer Details
- SHA256: fbfae531059839cc3041e99a397e7385461f7c96cd7eea8b382d54cf63e9e717
- Pointer size: 131 Bytes
- Size of remote file: 306 kB
figs/reconstruction.jpgAdded

Large File Pointer Details
- SHA256: 86c29bc3149aed61ae83adadde239a4d1a8ee7507bf8d4254e38bdef0092fa14
- Pointer size: 131 Bytes
- Size of remote file: 372 kB
figs/tokenizer.jpgAdded

Large File Pointer Details
- SHA256: e1b9250b80bcb8662ccfc1c988632e6ad60d8c8622fb07281d1869392318eba9
- Pointer size: 131 Bytes
- Size of remote file: 579 kB
install_requirements.shAdded+5
reconstuction_example.pyAdded+178
requirements_npu.txtAdded+18
semantic_detokenizer/__init__.pyAdded
semantic_detokenizer/chunk_infer.pyAdded+478
semantic_detokenizer/ckpt/model.ptAdded+3
semantic_detokenizer/ckpt/model.pt.md5Added+1
semantic_detokenizer/ckpt/model.yamlAdded+51
semantic_detokenizer/ckpt/vocab_4096.txtAdded+4096
semantic_detokenizer/f5tts_npu_patch.pyAdded+106
semantic_detokenizer/model/__init__.pyAdded
semantic_detokenizer/model/cadit.pyAdded+263
semantic_detokenizer/model/modules.pyAdded+223
semantic_detokenizer/patch_utils.pyAdded+122
semantic_detokenizer/requirements.txtAdded+13
semantic_detokenizer/utils_infer.pyAdded+298
semantic_tokenizer/__init__.pyAdded
semantic_tokenizer/f40ms/README.mdAdded+7
semantic_tokenizer/f40ms/__init__.pyAdded
semantic_tokenizer/f40ms/ckpt/model.ptAdded+3
semantic_tokenizer/f40ms/ckpt/model.pt.md5Added+1
semantic_tokenizer/f40ms/config/dict.km.txtAdded+1000
semantic_tokenizer/f40ms/config/hubert_config.yamlAdded+344
semantic_tokenizer/f40ms/fairseq_npu_patch.pyAdded+34
semantic_tokenizer/f40ms/infer_for_eval.pyAdded+140
semantic_tokenizer/f40ms/models/__init__.pyAdded