joytou commited on
Commit
882ea5e
1 Parent(s): 5c84f37

init project

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +7 -0
  2. .github/ISSUE_TEMPLATE/bug_report.yml +50 -0
  3. .github/ISSUE_TEMPLATE/config.yml +5 -0
  4. .github/ISSUE_TEMPLATE/feature_request.yml +40 -0
  5. .github/pull_request_template.md +7 -0
  6. .github/workflows/build-docker-image.yml +70 -0
  7. .github/workflows/docs.yml +33 -0
  8. .github/workflows/stale.yml +25 -0
  9. .gitignore +31 -0
  10. .pre-commit-config.yaml +25 -0
  11. .project-root +0 -0
  12. .readthedocs.yaml +19 -0
  13. API_FLAGS.txt +6 -0
  14. Dockerfile +44 -0
  15. LICENSE +437 -0
  16. docker-compose.dev.yml +16 -0
  17. dockerfile.dev +33 -0
  18. docs/CNAME +1 -0
  19. docs/assets/figs/VS_1.jpg +0 -0
  20. docs/assets/figs/VS_1_pt-BR.png +0 -0
  21. docs/assets/figs/diagram.png +0 -0
  22. docs/assets/figs/diagrama.png +0 -0
  23. docs/en/finetune.md +125 -0
  24. docs/en/index.md +133 -0
  25. docs/en/inference.md +124 -0
  26. docs/en/samples.md +223 -0
  27. docs/ja/finetune.md +125 -0
  28. docs/ja/index.md +128 -0
  29. docs/ja/inference.md +157 -0
  30. docs/ja/samples.md +223 -0
  31. docs/pt/finetune.md +125 -0
  32. docs/pt/index.md +131 -0
  33. docs/pt/inference.md +153 -0
  34. docs/pt/samples.md +223 -0
  35. docs/requirements.txt +3 -0
  36. docs/stylesheets/extra.css +3 -0
  37. docs/zh/finetune.md +136 -0
  38. docs/zh/index.md +191 -0
  39. docs/zh/inference.md +134 -0
  40. docs/zh/samples.md +223 -0
  41. entrypoint.sh +10 -0
  42. fish_speech/callbacks/__init__.py +3 -0
  43. fish_speech/callbacks/grad_norm.py +113 -0
  44. fish_speech/configs/base.yaml +87 -0
  45. fish_speech/configs/firefly_gan_vq.yaml +33 -0
  46. fish_speech/configs/lora/r_8_alpha_16.yaml +4 -0
  47. fish_speech/configs/text2semantic_finetune.yaml +83 -0
  48. fish_speech/conversation.py +2 -0
  49. fish_speech/datasets/concat_repeat.py +53 -0
  50. fish_speech/datasets/protos/text-data.proto +24 -0
.dockerignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ .git
2
+ .github
3
+ results
4
+ data
5
+ *.filelist
6
+ /data_server/target
7
+ checkpoints
.github/ISSUE_TEMPLATE/bug_report.yml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "🕷️ Bug report"
2
+ description: Report errors or unexpected behavior
3
+ labels:
4
+ - bug
5
+ body:
6
+ - type: checkboxes
7
+ attributes:
8
+ label: Self Checks
9
+ description: "To make sure we get to you in time, please check the following :)"
10
+ options:
11
+ - label: This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/fishaudio/fish-speech/discussions).
12
+ required: true
13
+ - label: I have searched for existing issues [search for existing issues](https://github.com/fishaudio/fish-speech/issues), including closed ones.
14
+ required: true
15
+ - label: I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/fishaudio/fish-speech/issues/515)).
16
+ required: true
17
+ - label: "[FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)"
18
+ required: true
19
+ - label: "Please do not modify this template :) and fill in all the required fields."
20
+ required: true
21
+ - type: dropdown
22
+ attributes:
23
+ label: Cloud or Self Hosted
24
+ multiple: true
25
+ options:
26
+ - Cloud
27
+ - Self Hosted (Docker)
28
+ - Self Hosted (Source)
29
+ validations:
30
+ required: true
31
+ - type: textarea
32
+ attributes:
33
+ label: Steps to reproduce
34
+ description: We highly suggest including screenshots and a bug report log. Please use the right markdown syntax for code blocks.
35
+ placeholder: Having detailed steps helps us reproduce the bug.
36
+ validations:
37
+ required: true
38
+ - type: textarea
39
+ attributes:
40
+ label: ✔️ Expected Behavior
41
+ placeholder: What were you expecting?
42
+ validations:
43
+ required: false
44
+
45
+ - type: textarea
46
+ attributes:
47
+ label: ❌ Actual Behavior
48
+ placeholder: What happened instead?
49
+ validations:
50
+ required: false
.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: "\U0001F4E7 Discussions"
4
+ url: https://github.com/fishaudio/fish-speech/discussions
5
+ about: General discussions and request help from the community
.github/ISSUE_TEMPLATE/feature_request.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "⭐ Feature or enhancement request"
2
+ description: Propose something new.
3
+ labels:
4
+ - enhancement
5
+ body:
6
+ - type: checkboxes
7
+ attributes:
8
+ label: Self Checks
9
+ description: "To make sure we get to you in time, please check the following :)"
10
+ options:
11
+ - label: I have searched for existing issues [search for existing issues]([https://github.com/langgenius/dify/issues](https://github.com/fishaudio/fish-speech/issues)), including closed ones.
12
+ required: true
13
+ - label: I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/fishaudio/fish-speech/issues/515)).
14
+ required: true
15
+ - label: "[FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)"
16
+ required: true
17
+ - label: "Please do not modify this template :) and fill in all the required fields."
18
+ required: true
19
+ - type: textarea
20
+ attributes:
21
+ label: 1. Is this request related to a challenge you're experiencing? Tell me about your story.
22
+ placeholder: Please describe the specific scenario or problem you're facing as clearly as possible. For instance "I was trying to use [feature] for [specific task], and [what happened]... It was frustrating because...."
23
+ validations:
24
+ required: true
25
+ - type: textarea
26
+ attributes:
27
+ label: 2. Additional context or comments
28
+ placeholder: (Any other information, comments, documentations, links, or screenshots that would provide more clarity. This is the place to add anything else not covered above.)
29
+ validations:
30
+ required: false
31
+ - type: checkboxes
32
+ attributes:
33
+ label: 3. Can you help us with this feature?
34
+ description: Let us know! This is not a commitment, but a starting point for collaboration.
35
+ options:
36
+ - label: I am interested in contributing to this feature.
37
+ required: false
38
+ - type: markdown
39
+ attributes:
40
+ value: Please limit one request per issue.
.github/pull_request_template.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ **Is this PR adding new feature or fix a BUG?**
2
+
3
+ Add feature / Fix BUG.
4
+
5
+ **Is this pull request related to any issue? If yes, please link the issue.**
6
+
7
+ #xxx
.github/workflows/build-docker-image.yml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build Image
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ tags:
8
+ - 'v*'
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest-16c64g
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - name: Set up Docker Buildx
16
+ uses: docker/setup-buildx-action@v3
17
+ - name: Get Version
18
+ run: |
19
+ if [[ $GITHUB_REF == refs/tags/v* ]]; then
20
+ version=$(basename ${GITHUB_REF})
21
+ else
22
+ version=nightly
23
+ fi
24
+
25
+ echo "version=${version}" >> $GITHUB_ENV
26
+ echo "Current version: ${version}"
27
+
28
+ - name: Login to Docker Hub
29
+ uses: docker/login-action@v3
30
+ with:
31
+ username: ${{ secrets.DOCKER_USER }}
32
+ password: ${{ secrets.DOCKER_PAT }}
33
+
34
+ - name: Build and Push Image
35
+ uses: docker/build-push-action@v6
36
+ with:
37
+ context: .
38
+ file: dockerfile
39
+ platforms: linux/amd64
40
+ push: true
41
+ tags: |
42
+ fishaudio/fish-speech:${{ env.version }}
43
+ fishaudio/fish-speech:latest
44
+ outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
45
+ cache-from: type=registry,ref=fishaudio/fish-speech:latest
46
+ cache-to: type=inline
47
+
48
+ - name: Build and Push Dev Image
49
+ uses: docker/build-push-action@v6
50
+ with:
51
+ context: .
52
+ file: dockerfile.dev
53
+ platforms: linux/amd64
54
+ push: true
55
+ build-args: |
56
+ VERSION=${{ env.version }}
57
+ BASE_IMAGE=fishaudio/fish-speech:${{ env.version }}
58
+ tags: |
59
+ fishaudio/fish-speech:${{ env.version }}-dev
60
+ fishaudio/fish-speech:latest-dev
61
+ outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
62
+ cache-from: type=registry,ref=fishaudio/fish-speech:latest-dev
63
+ cache-to: type=inline
64
+
65
+ - name: Push README to Dockerhub
66
+ uses: peter-evans/dockerhub-description@v4
67
+ with:
68
+ username: ${{ secrets.DOCKER_USER }}
69
+ password: ${{ secrets.DOCKER_PAT }}
70
+ repository: fishaudio/fish-speech
.github/workflows/docs.yml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: docs
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ paths:
7
+ - 'docs/**'
8
+ - 'mkdocs.yml'
9
+
10
+ permissions:
11
+ contents: write
12
+
13
+ jobs:
14
+ deploy:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Configure Git Credentials
19
+ run: |
20
+ git config user.name github-actions[bot]
21
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: 3.x
25
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
26
+ - uses: actions/cache@v4
27
+ with:
28
+ key: mkdocs-material-${{ env.cache_id }}
29
+ path: .cache
30
+ restore-keys: |
31
+ mkdocs-material-
32
+ - run: pip install -r docs/requirements.txt
33
+ - run: mkdocs gh-deploy --force
.github/workflows/stale.yml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Close inactive issues
2
+ on:
3
+ schedule:
4
+ - cron: "0 0 * * *"
5
+
6
+ jobs:
7
+ close-issues:
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ issues: write
11
+ pull-requests: write
12
+ steps:
13
+ - uses: actions/stale@v9
14
+ with:
15
+ days-before-issue-stale: 30
16
+ days-before-issue-close: 14
17
+ stale-issue-label: "stale"
18
+ stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
19
+ close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
20
+ days-before-pr-stale: 30
21
+ days-before-pr-close: 30
22
+ stale-pr-label: "stale"
23
+ stale-pr-message: "This PR is stale because it has been open for 30 days with no activity."
24
+ close-pr-message: "This PR was closed because it has been inactive for 30 days since being marked as stale."
25
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
.gitignore ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .DS_Store
2
+ .pgx.*
3
+ .pdm-python
4
+ /fish_speech.egg-info
5
+ __pycache__
6
+ /results
7
+ /data
8
+ /*.test.sh
9
+ *.filelist
10
+ filelists
11
+ /fish_speech/text/cmudict_cache.pickle
12
+ /checkpoints
13
+ /.vscode
14
+ /data_server/target
15
+ /*.npy
16
+ /*.wav
17
+ /*.mp3
18
+ /*.lab
19
+ /results
20
+ /data
21
+ /.idea
22
+ ffmpeg.exe
23
+ ffprobe.exe
24
+ asr-label*
25
+ /.cache
26
+ /fishenv
27
+ /.locale
28
+ /demo-audios
29
+ /references
30
+ /example
31
+ /faster_whisper
.pre-commit-config.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ci:
2
+ autoupdate_schedule: monthly
3
+
4
+ repos:
5
+ - repo: https://github.com/pycqa/isort
6
+ rev: 5.13.2
7
+ hooks:
8
+ - id: isort
9
+ args: [--profile=black]
10
+
11
+ - repo: https://github.com/psf/black
12
+ rev: 24.8.0
13
+ hooks:
14
+ - id: black
15
+
16
+ - repo: https://github.com/pre-commit/pre-commit-hooks
17
+ rev: v4.6.0
18
+ hooks:
19
+ - id: end-of-file-fixer
20
+ - id: check-yaml
21
+ - id: check-json
22
+ - id: mixed-line-ending
23
+ args: ['--fix=lf']
24
+ - id: check-added-large-files
25
+ args: ['--maxkb=5000']
.project-root ADDED
File without changes
.readthedocs.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Read the Docs configuration file for MkDocs projects
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the version of Python and other tools you might need
8
+ build:
9
+ os: ubuntu-22.04
10
+ tools:
11
+ python: "3.12"
12
+
13
+ mkdocs:
14
+ configuration: mkdocs.yml
15
+
16
+ # Optionally declare the Python requirements required to build your docs
17
+ python:
18
+ install:
19
+ - requirements: docs/requirements.txt
API_FLAGS.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # --infer
2
+ # --api
3
+ --listen 0.0.0.0:8080 \
4
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
5
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
6
+ --decoder-config-name firefly_gan_vq
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim-bookworm AS stage-1
2
+ ARG TARGETARCH
3
+
4
+ ARG HUGGINGFACE_MODEL=fish-speech-1.4
5
+ ARG HF_ENDPOINT=https://huggingface.co
6
+
7
+ WORKDIR /opt/fish-speech
8
+
9
+ RUN set -ex \
10
+ && pip install huggingface_hub \
11
+ && HF_ENDPOINT=${HF_ENDPOINT} huggingface-cli download --resume-download fishaudio/${HUGGINGFACE_MODEL} --local-dir checkpoints/${HUGGINGFACE_MODEL}
12
+
13
+ FROM python:3.12-slim-bookworm
14
+ ARG TARGETARCH
15
+
16
+ ARG DEPENDENCIES=" \
17
+ ca-certificates \
18
+ libsox-dev \
19
+ ffmpeg"
20
+
21
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
22
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
23
+ set -ex \
24
+ && rm -f /etc/apt/apt.conf.d/docker-clean \
25
+ && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache \
26
+ && apt-get update \
27
+ && apt-get -y install --no-install-recommends ${DEPENDENCIES} \
28
+ && echo "no" | dpkg-reconfigure dash
29
+
30
+ WORKDIR /opt/fish-speech
31
+
32
+ COPY . .
33
+
34
+ RUN --mount=type=cache,target=/root/.cache,sharing=locked \
35
+ set -ex \
36
+ && pip install -e .[stable]
37
+
38
+ COPY --from=stage-1 /opt/fish-speech/checkpoints /opt/fish-speech/checkpoints
39
+
40
+ ENV GRADIO_SERVER_NAME="0.0.0.0"
41
+
42
+ EXPOSE 7860
43
+
44
+ CMD ["./entrypoint.sh"]
LICENSE ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution-NonCommercial-ShareAlike 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
58
+ Public License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial-ShareAlike 4.0 International Public License
63
+ ("Public License"). To the extent this Public License may be
64
+ interpreted as a contract, You are granted the Licensed Rights in
65
+ consideration of Your acceptance of these terms and conditions, and the
66
+ Licensor grants You such rights in consideration of benefits the
67
+ Licensor receives from making the Licensed Material available under
68
+ these terms and conditions.
69
+
70
+
71
+ Section 1 -- Definitions.
72
+
73
+ a. Adapted Material means material subject to Copyright and Similar
74
+ Rights that is derived from or based upon the Licensed Material
75
+ and in which the Licensed Material is translated, altered,
76
+ arranged, transformed, or otherwise modified in a manner requiring
77
+ permission under the Copyright and Similar Rights held by the
78
+ Licensor. For purposes of this Public License, where the Licensed
79
+ Material is a musical work, performance, or sound recording,
80
+ Adapted Material is always produced where the Licensed Material is
81
+ synched in timed relation with a moving image.
82
+
83
+ b. Adapter's License means the license You apply to Your Copyright
84
+ and Similar Rights in Your contributions to Adapted Material in
85
+ accordance with the terms and conditions of this Public License.
86
+
87
+ c. BY-NC-SA Compatible License means a license listed at
88
+ creativecommons.org/compatiblelicenses, approved by Creative
89
+ Commons as essentially the equivalent of this Public License.
90
+
91
+ d. Copyright and Similar Rights means copyright and/or similar rights
92
+ closely related to copyright including, without limitation,
93
+ performance, broadcast, sound recording, and Sui Generis Database
94
+ Rights, without regard to how the rights are labeled or
95
+ categorized. For purposes of this Public License, the rights
96
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
97
+ Rights.
98
+
99
+ e. Effective Technological Measures means those measures that, in the
100
+ absence of proper authority, may not be circumvented under laws
101
+ fulfilling obligations under Article 11 of the WIPO Copyright
102
+ Treaty adopted on December 20, 1996, and/or similar international
103
+ agreements.
104
+
105
+ f. Exceptions and Limitations means fair use, fair dealing, and/or
106
+ any other exception or limitation to Copyright and Similar Rights
107
+ that applies to Your use of the Licensed Material.
108
+
109
+ g. License Elements means the license attributes listed in the name
110
+ of a Creative Commons Public License. The License Elements of this
111
+ Public License are Attribution, NonCommercial, and ShareAlike.
112
+
113
+ h. Licensed Material means the artistic or literary work, database,
114
+ or other material to which the Licensor applied this Public
115
+ License.
116
+
117
+ i. Licensed Rights means the rights granted to You subject to the
118
+ terms and conditions of this Public License, which are limited to
119
+ all Copyright and Similar Rights that apply to Your use of the
120
+ Licensed Material and that the Licensor has authority to license.
121
+
122
+ j. Licensor means the individual(s) or entity(ies) granting rights
123
+ under this Public License.
124
+
125
+ k. NonCommercial means not primarily intended for or directed towards
126
+ commercial advantage or monetary compensation. For purposes of
127
+ this Public License, the exchange of the Licensed Material for
128
+ other material subject to Copyright and Similar Rights by digital
129
+ file-sharing or similar means is NonCommercial provided there is
130
+ no payment of monetary compensation in connection with the
131
+ exchange.
132
+
133
+ l. Share means to provide material to the public by any means or
134
+ process that requires permission under the Licensed Rights, such
135
+ as reproduction, public display, public performance, distribution,
136
+ dissemination, communication, or importation, and to make material
137
+ available to the public including in ways that members of the
138
+ public may access the material from a place and at a time
139
+ individually chosen by them.
140
+
141
+ m. Sui Generis Database Rights means rights other than copyright
142
+ resulting from Directive 96/9/EC of the European Parliament and of
143
+ the Council of 11 March 1996 on the legal protection of databases,
144
+ as amended and/or succeeded, as well as other essentially
145
+ equivalent rights anywhere in the world.
146
+
147
+ n. You means the individual or entity exercising the Licensed Rights
148
+ under this Public License. Your has a corresponding meaning.
149
+
150
+
151
+ Section 2 -- Scope.
152
+
153
+ a. License grant.
154
+
155
+ 1. Subject to the terms and conditions of this Public License,
156
+ the Licensor hereby grants You a worldwide, royalty-free,
157
+ non-sublicensable, non-exclusive, irrevocable license to
158
+ exercise the Licensed Rights in the Licensed Material to:
159
+
160
+ a. reproduce and Share the Licensed Material, in whole or
161
+ in part, for NonCommercial purposes only; and
162
+
163
+ b. produce, reproduce, and Share Adapted Material for
164
+ NonCommercial purposes only.
165
+
166
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
167
+ Exceptions and Limitations apply to Your use, this Public
168
+ License does not apply, and You do not need to comply with
169
+ its terms and conditions.
170
+
171
+ 3. Term. The term of this Public License is specified in Section
172
+ 6(a).
173
+
174
+ 4. Media and formats; technical modifications allowed. The
175
+ Licensor authorizes You to exercise the Licensed Rights in
176
+ all media and formats whether now known or hereafter created,
177
+ and to make technical modifications necessary to do so. The
178
+ Licensor waives and/or agrees not to assert any right or
179
+ authority to forbid You from making technical modifications
180
+ necessary to exercise the Licensed Rights, including
181
+ technical modifications necessary to circumvent Effective
182
+ Technological Measures. For purposes of this Public License,
183
+ simply making modifications authorized by this Section 2(a)
184
+ (4) never produces Adapted Material.
185
+
186
+ 5. Downstream recipients.
187
+
188
+ a. Offer from the Licensor -- Licensed Material. Every
189
+ recipient of the Licensed Material automatically
190
+ receives an offer from the Licensor to exercise the
191
+ Licensed Rights under the terms and conditions of this
192
+ Public License.
193
+
194
+ b. Additional offer from the Licensor -- Adapted Material.
195
+ Every recipient of Adapted Material from You
196
+ automatically receives an offer from the Licensor to
197
+ exercise the Licensed Rights in the Adapted Material
198
+ under the conditions of the Adapter's License You apply.
199
+
200
+ c. No downstream restrictions. You may not offer or impose
201
+ any additional or different terms or conditions on, or
202
+ apply any Effective Technological Measures to, the
203
+ Licensed Material if doing so restricts exercise of the
204
+ Licensed Rights by any recipient of the Licensed
205
+ Material.
206
+
207
+ 6. No endorsement. Nothing in this Public License constitutes or
208
+ may be construed as permission to assert or imply that You
209
+ are, or that Your use of the Licensed Material is, connected
210
+ with, or sponsored, endorsed, or granted official status by,
211
+ the Licensor or others designated to receive attribution as
212
+ provided in Section 3(a)(1)(A)(i).
213
+
214
+ b. Other rights.
215
+
216
+ 1. Moral rights, such as the right of integrity, are not
217
+ licensed under this Public License, nor are publicity,
218
+ privacy, and/or other similar personality rights; however, to
219
+ the extent possible, the Licensor waives and/or agrees not to
220
+ assert any such rights held by the Licensor to the limited
221
+ extent necessary to allow You to exercise the Licensed
222
+ Rights, but not otherwise.
223
+
224
+ 2. Patent and trademark rights are not licensed under this
225
+ Public License.
226
+
227
+ 3. To the extent possible, the Licensor waives any right to
228
+ collect royalties from You for the exercise of the Licensed
229
+ Rights, whether directly or through a collecting society
230
+ under any voluntary or waivable statutory or compulsory
231
+ licensing scheme. In all other cases the Licensor expressly
232
+ reserves any right to collect such royalties, including when
233
+ the Licensed Material is used other than for NonCommercial
234
+ purposes.
235
+
236
+
237
+ Section 3 -- License Conditions.
238
+
239
+ Your exercise of the Licensed Rights is expressly made subject to the
240
+ following conditions.
241
+
242
+ a. Attribution.
243
+
244
+ 1. If You Share the Licensed Material (including in modified
245
+ form), You must:
246
+
247
+ a. retain the following if it is supplied by the Licensor
248
+ with the Licensed Material:
249
+
250
+ i. identification of the creator(s) of the Licensed
251
+ Material and any others designated to receive
252
+ attribution, in any reasonable manner requested by
253
+ the Licensor (including by pseudonym if
254
+ designated);
255
+
256
+ ii. a copyright notice;
257
+
258
+ iii. a notice that refers to this Public License;
259
+
260
+ iv. a notice that refers to the disclaimer of
261
+ warranties;
262
+
263
+ v. a URI or hyperlink to the Licensed Material to the
264
+ extent reasonably practicable;
265
+
266
+ b. indicate if You modified the Licensed Material and
267
+ retain an indication of any previous modifications; and
268
+
269
+ c. indicate the Licensed Material is licensed under this
270
+ Public License, and include the text of, or the URI or
271
+ hyperlink to, this Public License.
272
+
273
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
274
+ reasonable manner based on the medium, means, and context in
275
+ which You Share the Licensed Material. For example, it may be
276
+ reasonable to satisfy the conditions by providing a URI or
277
+ hyperlink to a resource that includes the required
278
+ information.
279
+ 3. If requested by the Licensor, You must remove any of the
280
+ information required by Section 3(a)(1)(A) to the extent
281
+ reasonably practicable.
282
+
283
+ b. ShareAlike.
284
+
285
+ In addition to the conditions in Section 3(a), if You Share
286
+ Adapted Material You produce, the following conditions also apply.
287
+
288
+ 1. The Adapter's License You apply must be a Creative Commons
289
+ license with the same License Elements, this version or
290
+ later, or a BY-NC-SA Compatible License.
291
+
292
+ 2. You must include the text of, or the URI or hyperlink to, the
293
+ Adapter's License You apply. You may satisfy this condition
294
+ in any reasonable manner based on the medium, means, and
295
+ context in which You Share Adapted Material.
296
+
297
+ 3. You may not offer or impose any additional or different terms
298
+ or conditions on, or apply any Effective Technological
299
+ Measures to, Adapted Material that restrict exercise of the
300
+ rights granted under the Adapter's License You apply.
301
+
302
+
303
+ Section 4 -- Sui Generis Database Rights.
304
+
305
+ Where the Licensed Rights include Sui Generis Database Rights that
306
+ apply to Your use of the Licensed Material:
307
+
308
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
309
+ to extract, reuse, reproduce, and Share all or a substantial
310
+ portion of the contents of the database for NonCommercial purposes
311
+ only;
312
+
313
+ b. if You include all or a substantial portion of the database
314
+ contents in a database in which You have Sui Generis Database
315
+ Rights, then the database in which You have Sui Generis Database
316
+ Rights (but not its individual contents) is Adapted Material,
317
+ including for purposes of Section 3(b); and
318
+
319
+ c. You must comply with the conditions in Section 3(a) if You Share
320
+ all or a substantial portion of the contents of the database.
321
+
322
+ For the avoidance of doubt, this Section 4 supplements and does not
323
+ replace Your obligations under this Public License where the Licensed
324
+ Rights include other Copyright and Similar Rights.
325
+
326
+
327
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
328
+
329
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
330
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
331
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
332
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
333
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
334
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
335
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
336
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
337
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
338
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
339
+
340
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
341
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
342
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
343
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
344
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
345
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
346
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
347
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
348
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
349
+
350
+ c. The disclaimer of warranties and limitation of liability provided
351
+ above shall be interpreted in a manner that, to the extent
352
+ possible, most closely approximates an absolute disclaimer and
353
+ waiver of all liability.
354
+
355
+
356
+ Section 6 -- Term and Termination.
357
+
358
+ a. This Public License applies for the term of the Copyright and
359
+ Similar Rights licensed here. However, if You fail to comply with
360
+ this Public License, then Your rights under this Public License
361
+ terminate automatically.
362
+
363
+ b. Where Your right to use the Licensed Material has terminated under
364
+ Section 6(a), it reinstates:
365
+
366
+ 1. automatically as of the date the violation is cured, provided
367
+ it is cured within 30 days of Your discovery of the
368
+ violation; or
369
+
370
+ 2. upon express reinstatement by the Licensor.
371
+
372
+ For the avoidance of doubt, this Section 6(b) does not affect any
373
+ right the Licensor may have to seek remedies for Your violations
374
+ of this Public License.
375
+
376
+ c. For the avoidance of doubt, the Licensor may also offer the
377
+ Licensed Material under separate terms or conditions or stop
378
+ distributing the Licensed Material at any time; however, doing so
379
+ will not terminate this Public License.
380
+
381
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
382
+ License.
383
+
384
+
385
+ Section 7 -- Other Terms and Conditions.
386
+
387
+ a. The Licensor shall not be bound by any additional or different
388
+ terms or conditions communicated by You unless expressly agreed.
389
+
390
+ b. Any arrangements, understandings, or agreements regarding the
391
+ Licensed Material not stated herein are separate from and
392
+ independent of the terms and conditions of this Public License.
393
+
394
+
395
+ Section 8 -- Interpretation.
396
+
397
+ a. For the avoidance of doubt, this Public License does not, and
398
+ shall not be interpreted to, reduce, limit, restrict, or impose
399
+ conditions on any use of the Licensed Material that could lawfully
400
+ be made without permission under this Public License.
401
+
402
+ b. To the extent possible, if any provision of this Public License is
403
+ deemed unenforceable, it shall be automatically reformed to the
404
+ minimum extent necessary to make it enforceable. If the provision
405
+ cannot be reformed, it shall be severed from this Public License
406
+ without affecting the enforceability of the remaining terms and
407
+ conditions.
408
+
409
+ c. No term or condition of this Public License will be waived and no
410
+ failure to comply consented to unless expressly agreed to by the
411
+ Licensor.
412
+
413
+ d. Nothing in this Public License constitutes or may be interpreted
414
+ as a limitation upon, or waiver of, any privileges and immunities
415
+ that apply to the Licensor or You, including from the legal
416
+ processes of any jurisdiction or authority.
417
+
418
+ =======================================================================
419
+
420
+ Creative Commons is not a party to its public
421
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
422
+ its public licenses to material it publishes and in those instances
423
+ will be considered the “Licensor.” The text of the Creative Commons
424
+ public licenses is dedicated to the public domain under the CC0 Public
425
+ Domain Dedication. Except for the limited purpose of indicating that
426
+ material is shared under a Creative Commons public license or as
427
+ otherwise permitted by the Creative Commons policies published at
428
+ creativecommons.org/policies, Creative Commons does not authorize the
429
+ use of the trademark "Creative Commons" or any other trademark or logo
430
+ of Creative Commons without its prior written consent including,
431
+ without limitation, in connection with any unauthorized modifications
432
+ to any of its public licenses or any other arrangements,
433
+ understandings, or agreements concerning use of licensed material. For
434
+ the avoidance of doubt, this paragraph does not form part of the
435
+ public licenses.
436
+
437
+ Creative Commons may be contacted at creativecommons.org.
docker-compose.dev.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ fish-speech:
5
+ build: .
6
+ container_name: fish-speech
7
+ volumes:
8
+ - ./:/exp
9
+ deploy:
10
+ resources:
11
+ reservations:
12
+ devices:
13
+ - driver: nvidia
14
+ count: all
15
+ capabilities: [gpu]
16
+ command: tail -f /dev/null
dockerfile.dev ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ARG VERSION=dev
2
+ ARG BASE_IMAGE=ghcr.io/fishaudio/fish-speech:${VERSION}
3
+
4
+ FROM ${BASE_IMAGE}
5
+
6
+ ARG TOOLS=" \
7
+ git \
8
+ curl \
9
+ build-essential \
10
+ ffmpeg \
11
+ libsm6 \
12
+ libxext6 \
13
+ libjpeg-dev \
14
+ zlib1g-dev \
15
+ aria2 \
16
+ zsh \
17
+ openssh-server \
18
+ sudo \
19
+ protobuf-compiler \
20
+ cmake"
21
+
22
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
23
+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
24
+ set -ex \
25
+ && apt-get update \
26
+ && apt-get -y install --no-install-recommends ${TOOLS}
27
+
28
+ # Install oh-my-zsh so your terminal looks nice
29
+ RUN sh -c "$(curl https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended
30
+
31
+ # Set zsh as default shell
32
+ RUN chsh -s /usr/bin/zsh
33
+ ENV SHELL=/usr/bin/zsh
docs/CNAME ADDED
@@ -0,0 +1 @@
 
 
1
+ speech.fish.audio
docs/assets/figs/VS_1.jpg ADDED
docs/assets/figs/VS_1_pt-BR.png ADDED
docs/assets/figs/diagram.png ADDED
docs/assets/figs/diagrama.png ADDED
docs/en/finetune.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fine-tuning
2
+
3
+ Obviously, when you opened this page, you were not satisfied with the performance of the few-shot pre-trained model. You want to fine-tune a model to improve its performance on your dataset.
4
+
5
+ In current version, you only need to finetune the 'LLAMA' part.
6
+
7
+ ## Fine-tuning LLAMA
8
+ ### 1. Prepare the dataset
9
+
10
+ ```
11
+ .
12
+ ├── SPK1
13
+ │ ├── 21.15-26.44.lab
14
+ │ ├── 21.15-26.44.mp3
15
+ │ ├── 27.51-29.98.lab
16
+ │ ├── 27.51-29.98.mp3
17
+ │ ├── 30.1-32.71.lab
18
+ │ └── 30.1-32.71.mp3
19
+ └── SPK2
20
+ ├── 38.79-40.85.lab
21
+ └── 38.79-40.85.mp3
22
+ ```
23
+
24
+ You need to convert your dataset into the above format and place it under `data`. The audio file can have the extensions `.mp3`, `.wav`, or `.flac`, and the annotation file should have the extensions `.lab`.
25
+
26
+ !!! warning
27
+ It's recommended to apply loudness normalization to the dataset. You can use [fish-audio-preprocess](https://github.com/fishaudio/audio-preprocess) to do this.
28
+
29
+ ```bash
30
+ fap loudness-norm data-raw data --clean
31
+ ```
32
+
33
+
34
+ ### 2. Batch extraction of semantic tokens
35
+
36
+ Make sure you have downloaded the VQGAN weights. If not, run the following command:
37
+
38
+ ```bash
39
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
40
+ ```
41
+
42
+ You can then run the following command to extract semantic tokens:
43
+
44
+ ```bash
45
+ python tools/vqgan/extract_vq.py data \
46
+ --num-workers 1 --batch-size 16 \
47
+ --config-name "firefly_gan_vq" \
48
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
49
+ ```
50
+
51
+ !!! note
52
+ You can adjust `--num-workers` and `--batch-size` to increase extraction speed, but please make sure not to exceed your GPU memory limit.
53
+ For the VITS format, you can specify a file list using `--filelist xxx.list`.
54
+
55
+ This command will create `.npy` files in the `data` directory, as shown below:
56
+
57
+ ```
58
+ .
59
+ ├── SPK1
60
+ │ ├── 21.15-26.44.lab
61
+ │ ├── 21.15-26.44.mp3
62
+ │ ├── 21.15-26.44.npy
63
+ │ ├── 27.51-29.98.lab
64
+ │ ├── 27.51-29.98.mp3
65
+ │ ├── 27.51-29.98.npy
66
+ │ ├── 30.1-32.71.lab
67
+ │ ├── 30.1-32.71.mp3
68
+ │ └── 30.1-32.71.npy
69
+ └── SPK2
70
+ ├── 38.79-40.85.lab
71
+ ├── 38.79-40.85.mp3
72
+ └── 38.79-40.85.npy
73
+ ```
74
+
75
+ ### 3. Pack the dataset into protobuf
76
+
77
+ ```bash
78
+ python tools/llama/build_dataset.py \
79
+ --input "data" \
80
+ --output "data/protos" \
81
+ --text-extension .lab \
82
+ --num-workers 16
83
+ ```
84
+
85
+ After the command finishes executing, you should see the `quantized-dataset-ft.protos` file in the `data` directory.
86
+
87
+ ### 4. Finally, fine-tuning with LoRA
88
+
89
+ Similarly, make sure you have downloaded the `LLAMA` weights. If not, run the following command:
90
+
91
+ ```bash
92
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
93
+ ```
94
+
95
+ Finally, you can start the fine-tuning by running the following command:
96
+
97
+ ```bash
98
+ python fish_speech/train.py --config-name text2semantic_finetune \
99
+ project=$project \
100
+ +lora@model.model.lora_config=r_8_alpha_16
101
+ ```
102
+
103
+ !!! note
104
+ You can modify the training parameters such as `batch_size`, `gradient_accumulation_steps`, etc. to fit your GPU memory by modifying `fish_speech/configs/text2semantic_finetune.yaml`.
105
+
106
+ !!! note
107
+ For Windows users, you can use `trainer.strategy.process_group_backend=gloo` to avoid `nccl` issues.
108
+
109
+ After training is complete, you can refer to the [inference](inference.md) section, and use `--speaker SPK1` to generate speech.
110
+
111
+ !!! info
112
+ By default, the model will only learn the speaker's speech patterns and not the timbre. You still need to use prompts to ensure timbre stability.
113
+ If you want to learn the timbre, you can increase the number of training steps, but this may lead to overfitting.
114
+
115
+ After training, you need to convert the LoRA weights to regular weights before performing inference.
116
+
117
+ ```bash
118
+ python tools/llama/merge_lora.py \
119
+ --lora-config r_8_alpha_16 \
120
+ --base-weight checkpoints/fish-speech-1.4 \
121
+ --lora-weight results/$project/checkpoints/step_000000010.ckpt \
122
+ --output checkpoints/fish-speech-1.4-yth-lora/
123
+ ```
124
+ !!! note
125
+ You may also try other checkpoints. We suggest using the earliest checkpoint that meets your requirements, as they often perform better on out-of-distribution (OOD) data.
docs/en/index.md ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Introduction
2
+
3
+ <div>
4
+ <a target="_blank" href="https://discord.gg/Es5qTB9BcN">
5
+ <img alt="Discord" src="https://img.shields.io/discord/1214047546020728892?color=%23738ADB&label=Discord&logo=discord&logoColor=white&style=flat-square"/>
6
+ </a>
7
+ <a target="_blank" href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=jCKlUP7QgSm9kh95UlBoYv6s1I-Apl1M&authKey=xI5ttVAp3do68IpEYEalwXSYZFdfxZSkah%2BctF5FIMyN2NqAa003vFtLqJyAVRfF&noverify=0&group_code=593946093">
8
+ <img alt="QQ" src="https://img.shields.io/badge/QQ Group-%2312B7F5?logo=tencent-qq&logoColor=white&style=flat-square"/>
9
+ </a>
10
+ <a target="_blank" href="https://hub.docker.com/r/fishaudio/fish-speech">
11
+ <img alt="Docker" src="https://img.shields.io/docker/pulls/fishaudio/fish-speech?style=flat-square&logo=docker"/>
12
+ </a>
13
+ </div>
14
+
15
+ !!! warning
16
+ We assume no responsibility for any illegal use of the codebase. Please refer to the local laws regarding DMCA (Digital Millennium Copyright Act) and other relevant laws in your area. <br/>
17
+ This codebase and all models are released under the CC-BY-NC-SA-4.0 license.
18
+
19
+ <p align="center">
20
+ <img src="../assets/figs/diagram.png" width="75%">
21
+ </p>
22
+
23
+ ## Requirements
24
+
25
+ - GPU Memory: 4GB (for inference), 8GB (for fine-tuning)
26
+ - System: Linux, Windows
27
+
28
+ ## Windows Setup
29
+
30
+ Professional Windows users may consider using WSL2 or Docker to run the codebase.
31
+
32
+ ```bash
33
+ # Create a python 3.10 virtual environment, you can also use virtualenv
34
+ conda create -n fish-speech python=3.10
35
+ conda activate fish-speech
36
+
37
+ # Install pytorch
38
+ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
39
+
40
+ # Install fish-speech
41
+ pip3 install -e .
42
+
43
+ # (Enable acceleration) Install triton-windows
44
+ pip install https://github.com/AnyaCoder/fish-speech/releases/download/v0.1.0/triton_windows-0.1.0-py3-none-any.whl
45
+ ```
46
+
47
+ Non-professional Windows users can consider the following basic methods to run the project without a Linux environment (with model compilation capabilities, i.e., `torch.compile`):
48
+
49
+ 1. Extract the project package.
50
+ 2. Click `install_env.bat` to install the environment.
51
+ 3. If you want to enable compilation acceleration, follow this step:
52
+ 1. Download the LLVM compiler from the following links:
53
+ - [LLVM-17.0.6 (Official Site Download)](https://huggingface.co/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true)
54
+ - [LLVM-17.0.6 (Mirror Site Download)](https://hf-mirror.com/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true)
55
+ - After downloading `LLVM-17.0.6-win64.exe`, double-click to install, select an appropriate installation location, and most importantly, check the `Add Path to Current User` option to add the environment variable.
56
+ - Confirm that the installation is complete.
57
+ 2. Download and install the Microsoft Visual C++ Redistributable to solve potential .dll missing issues:
58
+ - [MSVC++ 14.40.33810.0 Download](https://aka.ms/vs/17/release/vc_redist.x64.exe)
59
+ 3. Download and install Visual Studio Community Edition to get MSVC++ build tools and resolve LLVM's header file dependencies:
60
+ - [Visual Studio Download](https://visualstudio.microsoft.com/zh-hans/downloads/)
61
+ - After installing Visual Studio Installer, download Visual Studio Community 2022.
62
+ - As shown below, click the `Modify` button and find the `Desktop development with C++` option to select and download.
63
+ 4. Download and install [CUDA Toolkit 12.x](https://developer.nvidia.com/cuda-12-1-0-download-archive?target_os=Windows&target_arch=x86_64)
64
+ 4. Double-click `start.bat` to open the training inference WebUI management interface. If needed, you can modify the `API_FLAGS` as prompted below.
65
+
66
+ !!! info "Optional"
67
+
68
+ Want to start the inference WebUI?
69
+
70
+ Edit the `API_FLAGS.txt` file in the project root directory and modify the first three lines as follows:
71
+ ```
72
+ --infer
73
+ # --api
74
+ # --listen ...
75
+ ...
76
+ ```
77
+
78
+ !!! info "Optional"
79
+
80
+ Want to start the API server?
81
+
82
+ Edit the `API_FLAGS.txt` file in the project root directory and modify the first three lines as follows:
83
+
84
+ ```
85
+ # --infer
86
+ --api
87
+ --listen ...
88
+ ...
89
+ ```
90
+
91
+ !!! info "Optional"
92
+
93
+ Double-click `run_cmd.bat` to enter the conda/python command line environment of this project.
94
+
95
+ ## Linux Setup
96
+
97
+ ```bash
98
+ # Create a python 3.10 virtual environment, you can also use virtualenv
99
+ conda create -n fish-speech python=3.10
100
+ conda activate fish-speech
101
+
102
+ # Install pytorch
103
+ pip3 install torch torchvision torchaudio
104
+
105
+ # Install fish-speech
106
+ pip3 install -e .[stable]
107
+
108
+ # (Ubuntu / Debian User) Install sox
109
+ apt install libsox-dev
110
+ ```
111
+
112
+ ## Changelog
113
+
114
+ - 2024/09/10: Updated Fish-Speech to 1.4 version, with an increase in dataset size and a change in the quantizer's n_groups from 4 to 8.
115
+ - 2024/07/02: Updated Fish-Speech to 1.2 version, remove VITS Decoder, and greatly enhanced zero-shot ability.
116
+ - 2024/05/10: Updated Fish-Speech to 1.1 version, implement VITS decoder to reduce WER and improve timbre similarity.
117
+ - 2024/04/22: Finished Fish-Speech 1.0 version, significantly modified VQGAN and LLAMA models.
118
+ - 2023/12/28: Added `lora` fine-tuning support.
119
+ - 2023/12/27: Add `gradient checkpointing`, `causual sampling`, and `flash-attn` support.
120
+ - 2023/12/19: Updated webui and HTTP API.
121
+ - 2023/12/18: Updated fine-tuning documentation and related examples.
122
+ - 2023/12/17: Updated `text2semantic` model, supporting phoneme-free mode.
123
+ - 2023/12/13: Beta version released, includes VQGAN model and a language model based on LLAMA (phoneme support only).
124
+
125
+ ## Acknowledgements
126
+
127
+ - [VITS2 (daniilrobnikov)](https://github.com/daniilrobnikov/vits2)
128
+ - [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)
129
+ - [GPT VITS](https://github.com/innnky/gpt-vits)
130
+ - [MQTTS](https://github.com/b04901014/MQTTS)
131
+ - [GPT Fast](https://github.com/pytorch-labs/gpt-fast)
132
+ - [Transformers](https://github.com/huggingface/transformers)
133
+ - [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS)
docs/en/inference.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference
2
+
3
+ Inference support command line, HTTP API and web UI.
4
+
5
+ !!! note
6
+ Overall, reasoning consists of several parts:
7
+
8
+ 1. Encode a given ~10 seconds of voice using VQGAN.
9
+ 2. Input the encoded semantic tokens and the corresponding text into the language model as an example.
10
+ 3. Given a new piece of text, let the model generate the corresponding semantic tokens.
11
+ 4. Input the generated semantic tokens into VITS / VQGAN to decode and generate the corresponding voice.
12
+
13
+ ## Command Line Inference
14
+
15
+ Download the required `vqgan` and `llama` models from our Hugging Face repository.
16
+
17
+ ```bash
18
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
19
+ ```
20
+
21
+ ### 1. Generate prompt from voice:
22
+
23
+ !!! note
24
+ If you plan to let the model randomly choose a voice timbre, you can skip this step.
25
+
26
+ ```bash
27
+ python tools/vqgan/inference.py \
28
+ -i "paimon.wav" \
29
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
30
+ ```
31
+
32
+ You should get a `fake.npy` file.
33
+
34
+ ### 2. Generate semantic tokens from text:
35
+
36
+ ```bash
37
+ python tools/llama/generate.py \
38
+ --text "The text you want to convert" \
39
+ --prompt-text "Your reference text" \
40
+ --prompt-tokens "fake.npy" \
41
+ --checkpoint-path "checkpoints/fish-speech-1.4" \
42
+ --num-samples 2 \
43
+ --compile
44
+ ```
45
+
46
+ This command will create a `codes_N` file in the working directory, where N is an integer starting from 0.
47
+
48
+ !!! note
49
+ You may want to use `--compile` to fuse CUDA kernels for faster inference (~30 tokens/second -> ~500 tokens/second).
50
+ Correspondingly, if you do not plan to use acceleration, you can comment out the `--compile` parameter.
51
+
52
+ !!! info
53
+ For GPUs that do not support bf16, you may need to use the `--half` parameter.
54
+
55
+ ### 3. Generate vocals from semantic tokens:
56
+
57
+ #### VQGAN Decoder
58
+
59
+ ```bash
60
+ python tools/vqgan/inference.py \
61
+ -i "codes_0.npy" \
62
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
63
+ ```
64
+
65
+ ## HTTP API Inference
66
+
67
+ We provide a HTTP API for inference. You can use the following command to start the server:
68
+
69
+ ```bash
70
+ python -m tools.api \
71
+ --listen 0.0.0.0:8080 \
72
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
73
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
74
+ --decoder-config-name firefly_gan_vq
75
+ ```
76
+
77
+ If you want to speed up inference, you can add the --compile parameter.
78
+
79
+ After that, you can view and test the API at http://127.0.0.1:8080/.
80
+
81
+ Below is an example of sending a request using `tools/post_api.py`.
82
+
83
+ ```bash
84
+ python -m tools.post_api \
85
+ --text "Text to be input" \
86
+ --reference_audio "Path to reference audio" \
87
+ --reference_text "Text content of the reference audio" \
88
+ --streaming True
89
+ ```
90
+
91
+ The above command indicates synthesizing the desired audio according to the reference audio information and returning it in a streaming manner.
92
+
93
+ The following example demonstrates that you can use **multiple** reference audio paths and reference audio texts at once. Separate them with spaces in the command.
94
+
95
+ ```bash
96
+ python -m tools.post_api \
97
+ --text "Text to input" \
98
+ --reference_audio "reference audio path1" "reference audio path2" \
99
+ --reference_text "reference audio text1" "reference audio text2"\
100
+ --streaming False \
101
+ --output "generated" \
102
+ --format "mp3"
103
+ ```
104
+
105
+ The above command synthesizes the desired `MP3` format audio based on the information from multiple reference audios and saves it as `generated.mp3` in the current directory.
106
+
107
+ ## GUI Inference
108
+ [Download client](https://github.com/AnyaCoder/fish-speech-gui/releases/tag/v0.1.0)
109
+
110
+ ## WebUI Inference
111
+
112
+ You can start the WebUI using the following command:
113
+
114
+ ```bash
115
+ python -m tools.webui \
116
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
117
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
118
+ --decoder-config-name firefly_gan_vq
119
+ ```
120
+
121
+ !!! note
122
+ You can use Gradio environment variables, such as `GRADIO_SHARE`, `GRADIO_SERVER_PORT`, `GRADIO_SERVER_NAME` to configure WebUI.
123
+
124
+ Enjoy!
docs/en/samples.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Samples
2
+
3
+ v1.2 samples are available on [Bilibili](https://www.bilibili.com/video/BV1wz421B71D/).
4
+
5
+ The following samples are from the v1.1 model.
6
+
7
+ ## Chinese Sentence 1
8
+ ```
9
+ 人间灯火倒映湖中,她的渴望让静水泛起涟漪。若代价只是孤独,那就让这份愿望肆意流淌。
10
+ 流入她所注视的世间,也流入她如湖水般澄澈的目光。
11
+ ```
12
+
13
+ <table>
14
+ <thead>
15
+ <tr>
16
+ <th>Speaker</th>
17
+ <th>Input Audio</th>
18
+ <th>Synthesized Audio</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>Nahida (Genshin Impact)</td>
24
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
25
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_output.wav" /></td>
26
+ </tr>
27
+ <tr>
28
+ <td>Zhongli (Genshin Impact)</td>
29
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_input.wav" /></td>
30
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_output.wav" /></td>
31
+ </tr>
32
+ <tr>
33
+ <td>Furina (Genshin Impact)</td>
34
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_input.wav" /></td>
35
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_output.wav" /></td>
36
+ </tr>
37
+ <tr>
38
+ <td>Random Speaker 1</td>
39
+ <td> - </td>
40
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/4_output.wav" /></td>
41
+ </tr>
42
+ <tr>
43
+ <td>Random Speaker 2</td>
44
+ <td> - </td>
45
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/5_output.wav" /></td>
46
+ </tr>
47
+ </tbody>
48
+ </table>
49
+
50
+
51
+ ## Chinese Sentence 2
52
+ ```
53
+ 你们这个是什么群啊,你们这是害人不浅啊你们这个群!谁是群主,出来!真的太过分了。你们搞这个群干什么?
54
+ 我儿子每一科的成绩都不过那个平均分呐,他现在初二,你叫我儿子怎么办啊?他现在还不到高中啊?
55
+ 你们害死我儿子了!快点出来你这个群主!再这样我去报警了啊!我跟你们说你们这一帮人啊,一天到晚啊,
56
+ 搞这些什么游戏啊,动漫啊,会害死你们的,你们没有前途我跟你说。你们这九百多个人,好好学习不好吗?
57
+ 一天到晚在上网。有什么意思啊?麻烦你重视一下你们的生活的目标啊?有一点学习目标行不行?一天到晚上网是不是人啊?
58
+ ```
59
+
60
+ <table>
61
+ <thead>
62
+ <tr>
63
+ <th>Speaker</th>
64
+ <th>Input Audio</th>
65
+ <th>Synthesized Audio</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <tr>
70
+ <td>Nahida (Genshin Impact)</td>
71
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
72
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/6_output.wav" /></td>
73
+ </tr>
74
+ <tr>
75
+ <td>Random Speaker</td>
76
+ <td> - </td>
77
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/7_output.wav" /></td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+
82
+
83
+ ## Chinese Sentence 3
84
+ ```
85
+ 大家好,我是 Fish Audio 开发的开源文本转语音模型。经过十五万小时的数据训练,
86
+ 我已经能够熟练掌握中文、日语和英语,我的语言处理能力接近人类水平,声音表现形式丰富多变。
87
+ 作为一个仅有亿级参数的模型,我相信社区成员能够在个人设备上轻松运行和微调,让我成为您的私人语音助手。
88
+ ```
89
+
90
+
91
+ <table>
92
+ <thead>
93
+ <tr>
94
+ <th>Speaker</th>
95
+ <th>Input Audio</th>
96
+ <th>Synthesized Audio</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>
100
+ <tr>
101
+ <td>Random Speaker</td>
102
+ <td> - </td>
103
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/8_output.wav" /></td>
104
+ </tr>
105
+ </tbody>
106
+ </table>
107
+
108
+ ## English Sentence 1
109
+
110
+ ```
111
+ In the realm of advanced technology, the evolution of artificial intelligence stands as a
112
+ monumental achievement. This dynamic field, constantly pushing the boundaries of what
113
+ machines can do, has seen rapid growth and innovation. From deciphering complex data
114
+ patterns to driving cars autonomously, AI's applications are vast and diverse.
115
+ ```
116
+
117
+ <table>
118
+ <thead>
119
+ <tr>
120
+ <th>Speaker</th>
121
+ <th>Input Audio</th>
122
+ <th>Synthesized Audio</th>
123
+ </tr>
124
+ </thead>
125
+ <tbody>
126
+ <tr>
127
+ <td>Random Speaker 1</td>
128
+ <td> - </td>
129
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/0_output.wav" /></td>
130
+ </tr>
131
+ <tr>
132
+ <td>Random Speaker 2</td>
133
+ <td> - </td>
134
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/1_output.wav" /></td>
135
+ </tr>
136
+ </tbody>
137
+ </table>
138
+
139
+ ## English Sentence 2
140
+ ```
141
+ Hello everyone, I am an open-source text-to-speech model developed by
142
+ Fish Audio. After training with 150,000 hours of data, I have become proficient
143
+ in Chinese, Japanese, and English, and my language processing abilities
144
+ are close to human level. My voice is capable of a wide range of expressions.
145
+ As a model with only hundreds of millions of parameters, I believe community
146
+ members can easily run and fine-tune me on their personal devices, allowing
147
+ me to serve as your personal voice assistant.
148
+ ```
149
+
150
+ <table>
151
+ <thead>
152
+ <tr>
153
+ <th>Speaker</th>
154
+ <th>Input Audio</th>
155
+ <th>Synthesized Audio</th>
156
+ </tr>
157
+ </thead>
158
+ <tbody>
159
+ <tr>
160
+ <td>Random Speaker</td>
161
+ <td> - </td>
162
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/2_output.wav" /></td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+ ## Japanese Sentence 1
168
+
169
+ ```
170
+ 先進技術の領域において、人工知能の進化は画期的な成果として立っています。常に機械ができることの限界を
171
+ 押し広げているこのダイナミックな分野は、急速な成長と革新を見せています。複雑なデータパターンの解読か
172
+ ら自動運転車の操縦まで、AIの応用は広範囲に及びます。
173
+ ```
174
+
175
+
176
+ <table>
177
+ <thead>
178
+ <tr>
179
+ <th>Speaker</th>
180
+ <th>Input Audio</th>
181
+ <th>Synthesized Audio</th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr>
186
+ <td>Random Speaker 1</td>
187
+ <td> - </td>
188
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/0_output.wav" /></td>
189
+ </tr>
190
+ <tr>
191
+ <td>Random Speaker 2</td>
192
+ <td> - </td>
193
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/1_output.wav" /></td>
194
+ </tr>
195
+ </tbody>
196
+ </table>
197
+
198
+ ## Japanese Sentence 2
199
+ ```
200
+ 皆さん、こんにちは。私はフィッシュオーディオによって開発されたオープンソースのテ
201
+ キストから音声への変換モデルです。15万時間のデータトレーニングを経て、
202
+ 中国語、日本語、英語を熟知しており、言語処理能力は人間に近いレベルです。
203
+ 声の表現も多彩で豊かです。数億のパラメータを持つこのモデルは、コミュニティ
204
+ のメンバーが個人のデバイスで簡単に実行し、微調整することができると
205
+ 信じています。これにより、私を個人の音声アシスタントとして活用できます。
206
+ ```
207
+
208
+ <table>
209
+ <thead>
210
+ <tr>
211
+ <th>Speaker</th>
212
+ <th>Input Audio</th>
213
+ <th>Synthesized Audio</th>
214
+ </tr>
215
+ </thead>
216
+ <tbody>
217
+ <tr>
218
+ <td>Random Speaker</td>
219
+ <td> - </td>
220
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/2_output.wav" /></td>
221
+ </tr>
222
+ </tbody>
223
+ </table>
docs/ja/finetune.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 微調整
2
+
3
+ 明らかに、このページを開いたとき、few-shot 事前トレーニングモデルのパフォーマンスに満足していなかったことでしょう。データセット上でのパフォーマンスを向上させるためにモデルを微調整したいと考えています。
4
+
5
+ 現在のバージョンでは、「LLAMA」部分のみを微調整する必要があります。
6
+
7
+ ## LLAMAの微調整
8
+ ### 1. データセットの準備
9
+
10
+ ```
11
+ .
12
+ ├── SPK1
13
+ │ ├── 21.15-26.44.lab
14
+ │ ├── 21.15-26.44.mp3
15
+ │ ├── 27.51-29.98.lab
16
+ │ ├── 27.51-29.98.mp3
17
+ │ ├── 30.1-32.71.lab
18
+ │ └── 30.1-32.71.mp3
19
+ └── SPK2
20
+ ├── 38.79-40.85.lab
21
+ └── 38.79-40.85.mp3
22
+ ```
23
+
24
+ データセットを上記の形式に変換し、「data」ディレクトリに配置する必要があります。音声ファイルの拡張子は「.mp3」、「.wav」、または「.flac」にすることができ、注釈ファイルの拡張子は「.lab」にする必要があります。
25
+
26
+ !!! warning
27
+ データセットにラウドネス正規化を適用することをお勧めします。これを行うには、[fish-audio-preprocess](https://github.com/fishaudio/audio-preprocess) を使用できます。
28
+
29
+ ```bash
30
+ fap loudness-norm data-raw data --clean
31
+ ```
32
+
33
+
34
+ ### 2. セマンティックトークンのバッチ抽出
35
+
36
+ VQGANの重みをダウンロードしたことを確認してください。まだダウンロードしていない場合は、次のコマンドを実行してください。
37
+
38
+ ```bash
39
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
40
+ ```
41
+
42
+ 次に、次のコマンドを実行してセマンティックトークンを抽出できます。
43
+
44
+ ```bash
45
+ python tools/vqgan/extract_vq.py data \
46
+ --num-workers 1 --batch-size 16 \
47
+ --config-name "firefly_gan_vq" \
48
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
49
+ ```
50
+
51
+ !!! note
52
+ `--num-workers` と `--batch-size` を調整して抽出速度を上げることができますが、GPUメモリの制限を超えないようにしてください。
53
+ VITS形式の場合、`--filelist xxx.list` を使用してファイルリストを指定できます。
54
+
55
+ このコマンドは、`data`ディレクトリに`.npy`ファイルを作成します。以下のように表示されます。
56
+
57
+ ```
58
+ .
59
+ ├── SPK1
60
+ │ ├── 21.15-26.44.lab
61
+ │ ├── 21.15-26.44.mp3
62
+ │ ├── 21.15-26.44.npy
63
+ │ ├── 27.51-29.98.lab
64
+ │ ├── 27.51-29.98.mp3
65
+ │ ├── 27.51-29.98.npy
66
+ │ ├── 30.1-32.71.lab
67
+ │ ├── 30.1-32.71.mp3
68
+ │ └── 30.1-32.71.npy
69
+ └── SPK2
70
+ ├── 38.79-40.85.lab
71
+ ├── 38.79-40.85.mp3
72
+ └── 38.79-40.85.npy
73
+ ```
74
+
75
+ ### 3. データセットをprotobufにパックする
76
+
77
+ ```bash
78
+ python tools/llama/build_dataset.py \
79
+ --input "data" \
80
+ --output "data/protos" \
81
+ --text-extension .lab \
82
+ --num-workers 16
83
+ ```
84
+
85
+ コマンドの実行が完了すると、`data`ディレクトリに`quantized-dataset-ft.protos`ファイルが表示されます。
86
+
87
+ ### 4. 最後に、LoRAを使用して微調整する
88
+
89
+ 同様に、`LLAMA`の重みをダウンロードしたことを確認してください。まだダウンロードしていない場合は、次のコマンドを実行してください。
90
+
91
+ ```bash
92
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
93
+ ```
94
+
95
+ 最後に、次のコマンドを実行して微調整を開始できます。
96
+
97
+ ```bash
98
+ python fish_speech/train.py --config-name text2semantic_finetune \
99
+ project=$project \
100
+ +lora@model.model.lora_config=r_8_alpha_16
101
+ ```
102
+
103
+ !!! note
104
+ `fish_speech/configs/text2semantic_finetune.yaml` を変更して、`batch_size`、`gradient_accumulation_steps` などのトレーニングパラメータを変更し、GPUメモリに適合させることができます。
105
+
106
+ !!! note
107
+ Windowsユーザーの場合、`trainer.strategy.process_group_backend=gloo` を使用して `nccl` の問題を回避できます。
108
+
109
+ トレーニングが完了したら、[推論](inference.md)セクションを参照し、`--speaker SPK1` を使用して音声を生成します。
110
+
111
+ !!! info
112
+ デフォルトでは、モデルは話者の発話パターンのみを学習し、音色は学習しません。音色の安定性を確保するためにプロンプトを使用する必要があります。
113
+ 音色を学習したい場合は、トレーニングステップ数を増やすことができますが、これにより過学習が発生する可能性があります。
114
+
115
+ トレーニングが完了したら、推論を行う前にLoRAの重みを通常の重みに変換する必要があります。
116
+
117
+ ```bash
118
+ python tools/llama/merge_lora.py \
119
+ --lora-config r_8_alpha_16 \
120
+ --base-weight checkpoints/fish-speech-1.4 \
121
+ --lora-weight results/$project/checkpoints/step_000000010.ckpt \
122
+ --output checkpoints/fish-speech-1.4-yth-lora/
123
+ ```
124
+ !!! note
125
+ 他のチェックポイントを試すこともできます。要件を満たす最も早いチェックポイントを使用することをお勧めします。これらは通常、分布外(OOD)データでより良いパフォーマンスを発揮します。
docs/ja/index.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fish Speech の紹介
2
+
3
+ <div>
4
+ <a target="_blank" href="https://discord.gg/Es5qTB9BcN">
5
+ <img alt="Discord" src="https://img.shields.io/discord/1214047546020728892?color=%23738ADB&label=Discord&logo=discord&logoColor=white&style=flat-square"/>
6
+ </a>
7
+ <a target="_blank" href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=jCKlUP7QgSm9kh95UlBoYv6s1I-Apl1M&authKey=xI5ttVAp3do68IpEYEalwXSYZFdfxZSkah%2BctF5FIMyN2NqAa003vFtLqJyAVRfF&noverify=0&group_code=593946093">
8
+ <img alt="QQ" src="https://img.shields.io/badge/QQ Group-%2312B7F5?logo=tencent-qq&logoColor=white&style=flat-square"/>
9
+ </a>
10
+ <a target="_blank" href="https://hub.docker.com/r/fishaudio/fish-speech">
11
+ <img alt="Docker" src="https://img.shields.io/docker/pulls/fishaudio/fish-speech?style=flat-square&logo=docker"/>
12
+ </a>
13
+ </div>
14
+
15
+ !!! warning
16
+ 私たちは、コードベースの違法な使用について一切の責任を負いません。お住まいの地域の DMCA(デジタルミレニアム著作権法)およびその他の関連法を参照してください。 <br/>
17
+ このコードベースとモデルは、CC-BY-NC-SA-4.0 ライセンス下でリリースされています。
18
+
19
+ <p align="center">
20
+ <img src="../assets/figs/diagram.png" width="75%">
21
+ </p>
22
+
23
+ ## 要件
24
+
25
+ - GPU メモリ: 4GB(推論用)、8GB(ファインチューニング用)
26
+ - システム: Linux、Windows
27
+
28
+ ## Windows セットアップ
29
+
30
+ Window にて開発を行っている方へ: 本コードベースを実行するのに WSL2 または Docker を利用することができます。
31
+
32
+ あまり詳しくない人は、Linux 環境なしでコードベースを実行するために以下の手順に従ってください。(モデルコンパイル機能`torch.compile`を利用できます。):
33
+
34
+ <ol>
35
+ <li>プロジェクトの圧縮ファイルをダウンロードし、展開</li>
36
+ <li><code>install_env.bat</code>を開いて実行に必要な環境を整えます。
37
+ <ul>
38
+ <li><code>install_env.bat</code>の<code>USE_MIRROR</code>ミラーサイトを使用する場合、項目を編集してください。</li>
39
+ <li><code>USE_MIRROR=false</code>は、最新の安定版の<code>torch</code>をオリジナルサイトからダウンロードします。<code>USE_MIRROR=true</code>は、最新の<code>torch</code>をミラーサイトからダウンロードします。デフォルトは<code>true</code>です。</li>
40
+ <li><code>install_env.bat</code>の<code>INSTALL_TYPE</code>を編集して、コンパイル環境をダウンロードするかを設定できます。</li>
41
+ <li><code>INSTALL_TYPE=preview</code>は、コンパイル環境付きのプレビュー版をダウンロードします。<code>INSTALL_TYPE=stable</code>は、コンパイル環境なしの安定版をダウンロードします。</li>
42
+ </ul>
43
+ </li>
44
+ <li>ステップ2で<code>USE_MIRROR=preview</code>の場合、オプション、コンパイルモデル環境を有効にするたに以下のステップを実行してください。:
45
+ <ol>
46
+ <li>以下のリンクからLLVMコンパイラをダウンロードします:
47
+ <ul>
48
+ <li><a href="https://huggingface.co/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true">LLVM-17.0.6(オリジナルサイト)</a></li>
49
+ <li><a href="https://hf-mirror.com/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true">LLVM-17.0.6(ミラーサイト)</a></li>
50
+ <li><code>LLVM-17.0.6-win64.exe</code>をダウンロードした後、ダブルクリックしてインストールし、適当な場所にインストールしてください。必ず<code>Add Path to Current User</code>をチェックして環境変数に追加することです。</li>
51
+ <li>インストールが完了したことを確認してください。</li>
52
+ </ul>
53
+ </li>
54
+ <li>Microsoft Visual C++ 再頒布可能パッケージをダウンロードしてインストールし、dllの欠落問題を解決します。
55
+ <ul>
56
+ <li><a href="https://aka.ms/vs/17/release/vc_redist.x64.exe">MSVC++ 14.40.33810.0 ダウンロード</a></li>
57
+ </ul>
58
+ </li>
59
+ <li>Visual Studio Community Editionをダウンロードしてインストールし、MSVC++ビルドツールを取得し、LLVMのヘッダーファイル依存関係を解決します。
60
+ <ul>
61
+ <li><a href="https://visualstudio.microsoft.com/zh-hans/downloads/">Visual Studio ダウンロード</a></li>
62
+ <li>Visual Studio Installerをインストールした後、Visual Studio Community 2022をダウンロードします。</li>
63
+ <li>以下のスクリーンショットのように<code>Modify</code>ボタンをクリックし、<code>Desktop development with C++</code>オプションにチェックをつけてダウンロ���ドします。</li>
64
+ <p align="center">
65
+ <img src="../assets/figs/VS_1.jpg" width="75%">
66
+ </p>
67
+ </ul>
68
+ </li>
69
+ <li>インストール <a href="https://developer.nvidia.com/cuda-12-1-0-download-archive?target_os=Windows&target_arch=x86_64">CUDA Toolkit 12</a></li>
70
+ </ol>
71
+ </li>
72
+ <li><code>start.bat</code>を実行し、Fish-Speechのトレーニング/推論設定WebUIを開いてください。。
73
+ <ul>
74
+ <li>(オプション)直接推論ページに行きたい場合は、プロジェクトルートディレクトリの<code>API_FLAGS.txt</code>の最初の3行を次のように変更してください:
75
+ <pre><code>--infer
76
+ # --api
77
+ # --listen ...
78
+ ...</code></pre>
79
+ </li>
80
+ <li>(オプション)APIサーバーを起動したい場合は、プロジェクトルートディレクトリの<code>API_FLAGS.txt</code>の最初の3行を次のように変更してください:
81
+ <pre><code># --infer
82
+ --api
83
+ --listen ...
84
+ ...</code></pre>
85
+ </li>
86
+ </ul>
87
+ </li>
88
+ <li>(オプション)<code>run_cmd.bat</code>をダブルクリックして、このプロジェクトの仮想環境を有効化できます。</li>
89
+ </ol>
90
+
91
+ ## Linux セットアップ
92
+
93
+ ```bash
94
+ # python 3.10の仮想環境を作成します。virtualenvも使用できます。
95
+ conda create -n fish-speech python=3.10
96
+ conda activate fish-speech
97
+
98
+ # pytorchをインストールします。
99
+ pip3 install torch torchvision torchaudio
100
+
101
+ # fish-speechをインストールします。
102
+ pip3 install -e .[stable]
103
+
104
+ # (Ubuntu / Debianユーザー) soxをインストールします。
105
+ apt install libsox-dev
106
+ ```
107
+
108
+ ## 変更履歴
109
+
110
+ - 2024/07/02: Fish-Speech を Ver.1.2 に更新し、VITS デコーダーを削除し、ゼロショット能力を大幅に強化しました。
111
+ - 2024/05/10: Fish-Speech を Ver.1.1 に更新し、VITS デコーダーを実装して WER を減少させ、音色の類似性を向上させました。
112
+ - 2024/04/22: Fish-Speech Ver.1.0 を完成させ、VQGAN および LLAMA モデルを大幅に修正しました。
113
+ - 2023/12/28: `lora`微調整サポートを追加しました。
114
+ - 2023/12/27: `gradient checkpointing`、`causual sampling`、および`flash-attn`サポートを追加しました。
115
+ - 2023/12/19: webui および HTTP API を更新しました。
116
+ - 2023/12/18: 微調整ドキュメントおよび関連例を更新しました。
117
+ - 2023/12/17: `text2semantic`モデルを更新し、自由音素モードをサポートしました。
118
+ - 2023/12/13: ベータ版をリリースし、VQGAN モデルおよび LLAMA に基づく言語モデル(音素のみサポート)を含みます。
119
+
120
+ ## 謝辞
121
+
122
+ - [VITS2 (daniilrobnikov)](https://github.com/daniilrobnikov/vits2)
123
+ - [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)
124
+ - [GPT VITS](https://github.com/innnky/gpt-vits)
125
+ - [MQTTS](https://github.com/b04901014/MQTTS)
126
+ - [GPT Fast](https://github.com/pytorch-labs/gpt-fast)
127
+ - [Transformers](https://github.com/huggingface/transformers)
128
+ - [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS)
docs/ja/inference.md ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 推論
2
+
3
+ 推論は、コマンドライン、HTTP API、および Web UI をサポートしています。
4
+
5
+ !!! note
6
+ 全体として、推論は次のいくつかの部分で構成されています:
7
+
8
+ 1. VQGANを使用して、与えられた約10秒の音声をエンコードします。
9
+ 2. エンコードされたセマンティックトークンと対応するテキストを例として言語モデルに入力します。
10
+ 3. 新しいテキストが与えられた場合、モデルに対応するセマンティックトークンを生成させます。
11
+ 4. 生成されたセマンティックトークンをVITS / VQGANに入力してデコードし、対応する音声を生成します。
12
+
13
+ ## コマンドライン推論
14
+
15
+ 必要な`vqgan`および`llama`モデルを Hugging Face リポジトリからダウンロードします。
16
+
17
+ ```bash
18
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
19
+ ```
20
+
21
+ ### 1. 音声からプロンプトを生成する:
22
+
23
+ !!! note
24
+ モデルにランダムに音声の音色を選ばせる場合、このステップをスキップできます。
25
+
26
+ ```bash
27
+ python tools/vqgan/inference.py \
28
+ -i "paimon.wav" \
29
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
30
+ ```
31
+
32
+ `fake.npy`ファイルが生成されるはずです。
33
+
34
+ ### 2. テキストからセマンティックトークンを生成する:
35
+
36
+ ```bash
37
+ python tools/llama/generate.py \
38
+ --text "変換したいテキスト" \
39
+ --prompt-text "参照テキスト" \
40
+ --prompt-tokens "fake.npy" \
41
+ --checkpoint-path "checkpoints/fish-speech-1.4" \
42
+ --num-samples 2 \
43
+ --compile
44
+ ```
45
+
46
+ このコマンドは、作業ディレクトリに`codes_N`ファイルを作成します。ここで、N は 0 から始まる整数です。
47
+
48
+ !!! note
49
+ `--compile`を使用して CUDA カーネルを融合し、より高速な推論を実現することができます(約 30 トークン/秒 -> 約 500 トークン/秒)。
50
+ それに対応して、加速を使用しない場合は、`--compile`パラメータをコメントアウトできます。
51
+
52
+ !!! info
53
+ bf16 をサポートしていない GPU の場合、`--half`パラメータを使用する必要があるかもしれません。
54
+
55
+ ### 3. セマンティックトークンから音声を生成する:
56
+
57
+ #### VQGAN デコーダー
58
+
59
+ ```bash
60
+ python tools/vqgan/inference.py \
61
+ -i "codes_0.npy" \
62
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
63
+ ```
64
+
65
+ ## HTTP API 推論
66
+
67
+ 推論のための HTTP API を提供しています。次のコマンドを使用してサーバーを起動できます:
68
+
69
+ ```bash
70
+ python -m tools.api \
71
+ --listen 0.0.0.0:8080 \
72
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
73
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
74
+ --decoder-config-name firefly_gan_vq
75
+ ```
76
+
77
+ 推論を高速化したい場合は、--compile パラメータを追加できます。
78
+
79
+ その後、`http://127.0.0.1:8080/`で API を表示およびテストできます。
80
+
81
+ 以下は、`tools/post_api.py` を使用してリクエストを送信する例です。
82
+
83
+ ```bash
84
+ python -m tools.post_api \
85
+ --text "入力するテキスト" \
86
+ --reference_audio "参照音声へのパス" \
87
+ --reference_text "参照音声テキスト" \
88
+ --streaming True
89
+ ```
90
+
91
+ 上記のコマンドは、参照音声の情報に基づいて必要な音声を合成し、ストリーミング方式で返すことを示しています。
92
+
93
+ `{SPEAKER}`と`{EMOTION}`に基づいて参照音声をランダムに選択する必要がある場合は、以下の手順に従って設定します:
94
+
95
+ ### 1. プロジェクトのルートディレクトリに`ref_data`フォルダを作成します。
96
+
97
+ ### 2. `ref_data`フォルダ内に次のような構造のディレクトリを作成します。
98
+
99
+ ```
100
+ .
101
+ ├── SPEAKER1
102
+ │ ├──EMOTION1
103
+ │ │ ├── 21.15-26.44.lab
104
+ │ │ ├── 21.15-26.44.wav
105
+ │ │ ├── 27.51-29.98.lab
106
+ │ │ ├── 27.51-29.98.wav
107
+ │ │ ├── 30.1-32.71.lab
108
+ │ │ └── 30.1-32.71.flac
109
+ │ └──EMOTION2
110
+ │ ├── 30.1-32.71.lab
111
+ │ └── 30.1-32.71.mp3
112
+ └── SPEAKER2
113
+ └─── EMOTION3
114
+ ├── 30.1-32.71.lab
115
+ └── 30.1-32.71.mp3
116
+
117
+ ```
118
+
119
+ つまり、まず`ref_data`に`{SPEAKER}`フォルダを配置し、各スピーカーの下に`{EMOTION}`フォルダを配置し、各感情フォルダの下に任意の数の音声-テキストペアを配置します
120
+
121
+ ### 3. 仮想環境で以下のコマンドを入力します.
122
+
123
+ ```bash
124
+ python tools/gen_ref.py
125
+
126
+ ```
127
+
128
+ 参照ディレクトリを生成します。
129
+
130
+ ### 4. API を呼び出します。
131
+
132
+ ```bash
133
+ python -m tools.post_api \
134
+ --text "入力��るテキスト" \
135
+ --speaker "${SPEAKER1}" \
136
+ --emotion "${EMOTION1}" \
137
+ --streaming True
138
+
139
+ ```
140
+
141
+ 上記の例はテスト目的のみです。
142
+
143
+ ## WebUI 推論
144
+
145
+ 次のコマンドを使用して WebUI を起動できます:
146
+
147
+ ```bash
148
+ python -m tools.webui \
149
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
150
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
151
+ --decoder-config-name firefly_gan_vq
152
+ ```
153
+
154
+ !!! note
155
+ Gradio 環境変数(`GRADIO_SHARE`、`GRADIO_SERVER_PORT`、`GRADIO_SERVER_NAME`など)を使用して WebUI を構成できます。
156
+
157
+ お楽しみください!
docs/ja/samples.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # サンプル
2
+
3
+ v1.2のサンプルは[Bilibili](https://www.bilibili.com/video/BV1wz421B71D/)で利用可能です。
4
+
5
+ 以下のサンプルはv1.1モデルからのものです。
6
+
7
+ ## 中国語の文1
8
+ ```
9
+ 人間灯火倒映湖中,她的渴望让静水泛起涟漪。若代价只是孤独,那就让这份愿望肆意流淌。
10
+ 流入她所注视的世间,也流入她如湖水般澄澈的目光。
11
+ ```
12
+
13
+ <table>
14
+ <thead>
15
+ <tr>
16
+ <th>話者</th>
17
+ <th>入力音声</th>
18
+ <th>合成音声</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>ナヒーダ (原神)</td>
24
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
25
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_output.wav" /></td>
26
+ </tr>
27
+ <tr>
28
+ <td>鍾離 (原神)</td>
29
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_input.wav" /></td>
30
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_output.wav" /></td>
31
+ </tr>
32
+ <tr>
33
+ <td>フリナ (原神)</td>
34
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_input.wav" /></td>
35
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_output.wav" /></td>
36
+ </tr>
37
+ <tr>
38
+ <td>ランダム話者1</td>
39
+ <td> - </td>
40
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/4_output.wav" /></td>
41
+ </tr>
42
+ <tr>
43
+ <td>ランダム話者2</td>
44
+ <td> - </td>
45
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/5_output.wav" /></td>
46
+ </tr>
47
+ </tbody>
48
+ </table>
49
+
50
+
51
+ ## 中国語の文2
52
+ ```
53
+ 你们这个是什么群啊,你们这是害人不浅啊你们这个群!谁是群主,出来!真的太过分了。你们搞这个群干什么?
54
+ 我儿子每一科的成绩都不过那个平均分呐,他现在初二,你叫我儿子怎么办啊?他现在还不到高中啊?
55
+ 你们害死我儿子了!快点出来你这个群主!再这样我去报警了啊!我跟你们说你们这一帮人啊,一天到晚啊,
56
+ 搞这些什么游戏啊,动漫啊,会害死你们的,你们没有前途我跟你说。你们这九百多个人,好好学习不好吗?
57
+ 一天到晚在上网。有什么意思啊?麻烦你重视一下你们的生活的目标啊?有一点学习目标行不行?一天到晚上网是不是人啊?
58
+ ```
59
+
60
+ <table>
61
+ <thead>
62
+ <tr>
63
+ <th>話者</th>
64
+ <th>入力音声</th>
65
+ <th>合成音声</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <tr>
70
+ <td>ナヒーダ (原神)</td>
71
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
72
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/6_output.wav" /></td>
73
+ </tr>
74
+ <tr>
75
+ <td>ランダム話者</td>
76
+ <td> - </td>
77
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/7_output.wav" /></td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+
82
+
83
+ ## 中国語の文3
84
+ ```
85
+ 大家好,我是 Fish Audio 开发的开源文本转语音模型。经过十五万小时的数据训练,
86
+ 我已经能够熟练掌握中文、日语和英语,我的语言处理能力接近人类水平,声音表现形式丰富多变。
87
+ 作为一个仅有亿级参数的模型,我相信社区成员能够在个人设备上轻松运行和微调,让我成为您的私人语音助手。
88
+ ```
89
+
90
+
91
+ <table>
92
+ <thead>
93
+ <tr>
94
+ <th>話者</th>
95
+ <th>入力音声</th>
96
+ <th>合成音声</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>
100
+ <tr>
101
+ <td>ランダム話者</td>
102
+ <td> - </td>
103
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/8_output.wav" /></td>
104
+ </tr>
105
+ </tbody>
106
+ </table>
107
+
108
+ ## 英語の文1
109
+
110
+ ```
111
+ In the realm of advanced technology, the evolution of artificial intelligence stands as a
112
+ monumental achievement. This dynamic field, constantly pushing the boundaries of what
113
+ machines can do, has seen rapid growth and innovation. From deciphering complex data
114
+ patterns to driving cars autonomously, AI's applications are vast and diverse.
115
+ ```
116
+
117
+ <table>
118
+ <thead>
119
+ <tr>
120
+ <th>話者</th>
121
+ <th>入力音声</th>
122
+ <th>合成音声</th>
123
+ </tr>
124
+ </thead>
125
+ <tbody>
126
+ <tr>
127
+ <td>ランダム話者1</td>
128
+ <td> - </td>
129
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/0_output.wav" /></td>
130
+ </tr>
131
+ <tr>
132
+ <td>ランダム話者2</td>
133
+ <td> - </td>
134
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/1_output.wav" /></td>
135
+ </tr>
136
+ </tbody>
137
+ </table>
138
+
139
+ ## 英語の文2
140
+ ```
141
+ Hello everyone, I am an open-source text-to-speech model developed by
142
+ Fish Audio. After training with 150,000 hours of data, I have become proficient
143
+ in Chinese, Japanese, and English, and my language processing abilities
144
+ are close to human level. My voice is capable of a wide range of expressions.
145
+ As a model with only hundreds of millions of parameters, I believe community
146
+ members can easily run and fine-tune me on their personal devices, allowing
147
+ me to serve as your personal voice assistant.
148
+ ```
149
+
150
+ <table>
151
+ <thead>
152
+ <tr>
153
+ <th>話者</th>
154
+ <th>入力音声</th>
155
+ <th>合成音声</th>
156
+ </tr>
157
+ </thead>
158
+ <tbody>
159
+ <tr>
160
+ <td>ランダム話者</td>
161
+ <td> - </td>
162
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/2_output.wav" /></td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+ ## 日本語の文1
168
+
169
+ ```
170
+ 先進技術の領域において、人工知能の進化は画期的な成果として立っています。常に機械ができることの限界を
171
+ 押し広げているこのダイナミックな分野は、急速な成長と革新を見せています。複雑なデータパターンの解読か
172
+ ら自動運転車の操縦まで、AIの応用は広範囲に及びます。
173
+ ```
174
+
175
+
176
+ <table>
177
+ <thead>
178
+ <tr>
179
+ <th>話者</th>
180
+ <th>入力音声</th>
181
+ <th>合成音声</th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr>
186
+ <td>ランダム話者1</td>
187
+ <td> - </td>
188
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/0_output.wav" /></td>
189
+ </tr>
190
+ <tr>
191
+ <td>ランダム話者2</td>
192
+ <td> - </td>
193
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/1_output.wav" /></td>
194
+ </tr>
195
+ </tbody>
196
+ </table>
197
+
198
+ ## 日本語の文2
199
+ ```
200
+ 皆さん、こんにちは。私はフィッシュオーディオによって開発されたオープンソースのテ
201
+ キストから音声への変換モデルです。15万時間のデータトレーニングを経て、
202
+ 中国語、日本語、英語を熟知しており、言語処理能力は人間に近いレベルです。
203
+ 声の表現も多彩で豊かです。数億のパラメータを持つこのモデルは、コミュニティ
204
+ のメンバーが個人のデバイスで簡単に実行し、微調整することができると
205
+ 信じています。これにより、私を個人の音声アシスタントとして活用できます。
206
+ ```
207
+
208
+ <table>
209
+ <thead>
210
+ <tr>
211
+ <th>話者</th>
212
+ <th>入力音声</th>
213
+ <th>合成音声</th>
214
+ </tr>
215
+ </thead>
216
+ <tbody>
217
+ <tr>
218
+ <td>ランダム話者</td>
219
+ <td> - </td>
220
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/2_output.wav" /></td>
221
+ </tr>
222
+ </tbody>
223
+ </table>
docs/pt/finetune.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ajuste Fino
2
+
3
+ É óbvio que ao abrir esta página, você não deve estar muito satisfeito com o desempenho do modelo pré-treinado com poucos exemplos. Você pode querer ajustar o modelo para melhorar seu desempenho em seu conjunto de dados.
4
+
5
+ Na atual versão, a única coisa que você precisa ajustar é a parte do 'LLAMA'.
6
+
7
+ ## Ajuste Fino do LLAMA
8
+ ### 1. Preparando o conjunto de dados
9
+
10
+ ```
11
+ .
12
+ ├── SPK1
13
+ │ ├── 21.15-26.44.lab
14
+ │ ├── 21.15-26.44.mp3
15
+ │ ├── 27.51-29.98.lab
16
+ │ ├── 27.51-29.98.mp3
17
+ │ ├── 30.1-32.71.lab
18
+ │ └── 30.1-32.71.mp3
19
+ └── SPK2
20
+ ├── 38.79-40.85.lab
21
+ └── 38.79-40.85.mp3
22
+ ```
23
+
24
+ Você precisa converter seu conjunto de dados para o formato acima e colocá-lo em `data`. O arquivo de áudio pode ter as extensões `.mp3`, `.wav` ou `.flac`, e o arquivo de anotação deve ter a extensão `.lab`.
25
+
26
+ !!! warning
27
+ É recomendado aplicar normalização de volume ao conjunto de dados. Você pode usar o [fish-audio-preprocess](https://github.com/fishaudio/audio-preprocess) para fazer isso.
28
+
29
+ ```bash
30
+ fap loudness-norm data-raw data --clean
31
+ ```
32
+
33
+
34
+ ### 2. Extração em lote de tokens semânticos
35
+
36
+ Certifique-se de ter baixado os pesos do VQGAN. Se não, execute o seguinte comando:
37
+
38
+ ```bash
39
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
40
+ ```
41
+
42
+ Em seguida, você pode executar o seguinte comando para extrair os tokens semânticos:
43
+
44
+ ```bash
45
+ python tools/vqgan/extract_vq.py data \
46
+ --num-workers 1 --batch-size 16 \
47
+ --config-name "firefly_gan_vq" \
48
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
49
+ ```
50
+
51
+ !!! note
52
+ Você pode ajustar `--num-workers` e `--batch-size` para aumentar a velocidade de extração, mas certifique-se de não exceder o limite de memória da sua GPU.  
53
+ Para o formato VITS, você pode especificar uma lista de arquivos usando `--filelist xxx.list`.
54
+
55
+ Este comando criará arquivos `.npy` no diretório `data`, como mostrado abaixo:
56
+
57
+ ```
58
+ .
59
+ ├── SPK1
60
+ │ ├── 21.15-26.44.lab
61
+ │ ├── 21.15-26.44.mp3
62
+ │ ├── 21.15-26.44.npy
63
+ │ ├── 27.51-29.98.lab
64
+ │ ├── 27.51-29.98.mp3
65
+ │ ├── 27.51-29.98.npy
66
+ │ ├── 30.1-32.71.lab
67
+ │ ├── 30.1-32.71.mp3
68
+ │ └── 30.1-32.71.npy
69
+ └── SPK2
70
+ ├── 38.79-40.85.lab
71
+ ├── 38.79-40.85.mp3
72
+ └── 38.79-40.85.npy
73
+ ```
74
+
75
+ ### 3. Empacotar o conjunto de dados em protobuf
76
+
77
+ ```bash
78
+ python tools/llama/build_dataset.py \
79
+ --input "data" \
80
+ --output "data/protos" \
81
+ --text-extension .lab \
82
+ --num-workers 16
83
+ ```
84
+
85
+ Após executar o comando, você deverá ver o arquivo `quantized-dataset-ft.protos` no diretório `data`.
86
+
87
+ ### 4. E finalmente, chegamos ao ajuste fino com LoRA
88
+
89
+ Da mesma forma, certifique-se de ter baixado os pesos do `LLAMA`. Se não, execute o seguinte comando:
90
+
91
+ ```bash
92
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
93
+ ```
94
+
95
+ E então, execute o seguinte comando para iniciar o ajuste fino:
96
+
97
+ ```bash
98
+ python fish_speech/train.py --config-name text2semantic_finetune \
99
+ project=$project \
100
+ +lora@model.model.lora_config=r_8_alpha_16
101
+ ```
102
+
103
+ !!! note
104
+ Se quiser, você pode modificar os parâmetros de treinamento, como `batch_size`, `gradient_accumulation_steps`, etc., para se ajustar à memória da sua GPU, modificando `fish_speech/configs/text2semantic_finetune.yaml`.
105
+
106
+ !!! note
107
+ Para usuários do Windows, é recomendado usar `trainer.strategy.process_group_backend=gloo` para evitar problemas com `nccl`.
108
+
109
+ Após concluir o treinamento, consulte a seção [inferência](inference.md), e use `--speaker SPK1` para gerar fala.
110
+
111
+ !!! info
112
+ Por padrão, o modelo aprenderá apenas os padrões de fala do orador e não o timbre. Ainda pode ser preciso usar prompts para garantir a estabilidade do timbre.
113
+ Se quiser que ele aprenda o timbre, aumente o número de etapas de treinamento, mas isso pode levar ao overfitting (sobreajuste).
114
+
115
+ Após o treinamento, é preciso converter os pesos do LoRA em pesos regulares antes de realizar a inferência.
116
+
117
+ ```bash
118
+ python tools/llama/merge_lora.py \
119
+ --lora-config r_8_alpha_16 \
120
+ --base-weight checkpoints/fish-speech-1.4 \
121
+ --lora-weight results/$project/checkpoints/step_000000010.ckpt \
122
+ --output checkpoints/fish-speech-1.4-yth-lora/
123
+ ```
124
+ !!! note
125
+ É possível também tentar outros checkpoints. Sugerimos usar o checkpoint que melhor atenda aos seus requisitos, pois eles geralmente têm um desempenho melhor em dados fora da distribuição (OOD).
docs/pt/index.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Introdução
2
+
3
+ <div>
4
+ <a target="_blank" href="https://discord.gg/Es5qTB9BcN">
5
+ <img alt="Discord" src="https://img.shields.io/discord/1214047546020728892?color=%23738ADB&label=Discord&logo=discord&logoColor=white&style=flat-square"/>
6
+ </a>
7
+ <a target="_blank" href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=jCKlUP7QgSm9kh95UlBoYv6s1I-Apl1M&authKey=xI5ttVAp3do68IpEYEalwXSYZFdfxZSkah%2BctF5FIMyN2NqAa003vFtLqJyAVRfF&noverify=0&group_code=593946093">
8
+ <img alt="QQ" src="https://img.shields.io/badge/QQ Group-%2312B7F5?logo=tencent-qq&logoColor=white&style=flat-square"/>
9
+ </a>
10
+ <a target="_blank" href="https://hub.docker.com/r/fishaudio/fish-speech">
11
+ <img alt="Docker" src="https://img.shields.io/docker/pulls/fishaudio/fish-speech?style=flat-square&logo=docker"/>
12
+ </a>
13
+ </div>
14
+
15
+ !!! warning
16
+ Não nos responsabilizamos por qualquer uso ilegal do código-fonte. Consulte as leis locais sobre DMCA (Digital Millennium Copyright Act) e outras leis relevantes em sua região. <br/>
17
+ Este repositório de código e os modelos são distribuídos sob a licença CC-BY-NC-SA-4.0.
18
+
19
+ <p align="center">
20
+ <img src="../assets/figs/diagrama.png" width="75%">
21
+ </p>
22
+
23
+ ## Requisitos
24
+
25
+ - Memória da GPU: 4GB (para inferência), 8GB (para ajuste fino)
26
+ - Sistema: Linux, Windows
27
+
28
+ ## Configuração para Windows
29
+
30
+ No Windows, usuários avançados podem considerar usar o WSL2 ou Docker para executar o código.
31
+
32
+ Para Usuários comuns (não-avançados), siga os métodos abaixo para executar o código sem um ambiente Linux (incluindo suporte para `torch.compile`):
33
+
34
+ <ol>
35
+ <li>Extraia o arquivo compactado do projeto.</li>
36
+ <li>Prepare o ambiente conda:
37
+ <ul>
38
+ <li>Abra o <code>install_env.bat</code> para baixar e iniciar a instalação do miniconda.</li>
39
+ <li>Personalize o download (opcional):
40
+ <ul>
41
+ <li>**Site espelho:** Para usar um site espelho para downloads mais rápidos, defina <code>USE_MIRROR=true</code> no <code>install_env.bat</code> (padrão). Caso contrário, use <code>USE_MIRROR=false</code>.</li>
42
+ <li>**Ambiente compilado:** Para baixar a versão de prévia com o ambiente compilado, defina <code>INSTALL_TYPE=preview</code>. Para a versão estável sem ambiente compilado, use <code>INSTALL_TYPE=stable</code>.</li>
43
+ </ul>
44
+ </li>
45
+ </ul>
46
+ </li>
47
+ <li>Se você escolheu a versão de prévia com ambiente compilado (<code>INSTALL_TYPE=preview</code>), siga para a próxima etapa (opcional):
48
+ <ol>
49
+ <li>Baixe o compilador LLVM usando os seguintes links:
50
+ <ul>
51
+ <li><a href="https://huggingface.co/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true">LLVM-17.0.6 (download do site original)</a></li>
52
+ <li><a href="https://hf-mirror.com/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true">LLVM-17.0.6 (download do site espelho)</a></li>
53
+ <li>Após baixar o <code>LLVM-17.0.6-win64.exe</code>, clique duas vezes para instalá-lo, escolha um local de instalação apropriado. E durante a instalação, marque a opção <code>Add Path to Current User</code> para adicionar às variáveis de ambiente.</li>
54
+ <li>Confirme se a instalação foi concluída.</li>
55
+ </ul>
56
+ </li>
57
+ <li>Baixe e instale o pacote Microsoft Visual C++ Redistributable para resolver possíveis problemas de .dll ausentes.
58
+ <ul>
59
+ <li><a href="https://aka.ms/vs/17/release/vc_redist.x64.exe">Download do MSVC++ 14.40.33810.0</a></li>
60
+ </ul>
61
+ </li>
62
+ <li>Baixe e instale o Visual Studio Community Edition para obter as ferramentas de compilação MSVC++, resolvendo as dependências do arquivo de cabeçalho LLVM.
63
+ <ul>
64
+ <li><a href="https://visualstudio.microsoft.com/pt-br/downloads/">Download do Visual Studio</a></li>
65
+ <li>Após instalar o Visual Studio Installer, baixe o Visual Studio Community 2022.</li>
66
+ <li>Clique no botão <code>Modificar</code>, conforme mostrado abaixo, encontre a opção <code>Desenvolvimento para desktop com C++</code> e marque-a para download.</li>
67
+ <p align="center">
68
+ <img src="../assets/figs/VS_1_pt-BR.png" width="75%">
69
+ </p>
70
+ </ul>
71
+ </li>
72
+ <li>Instale o <a href="https://developer.nvidia.com/cuda-12-1-0-download-archive?target_os=Windows&target_arch=x86_64">CUDA Toolkit 12</a></li>
73
+ </ol>
74
+ </li>
75
+ <li>Clique duas vezes em <code>start.bat</code> para entrar na página da WebUI de configuração de inferência de treinamento do Fish-Speech.
76
+ <ul>
77
+ <li>(Opcional) Se desejar ir direto para a página de inferência, edite o arquivo <code>API_FLAGS.txt</code> no diretório raiz do projeto e modifique as três primeiras linhas da seguinte forma:
78
+ <pre><code>--infer
79
+ # --api
80
+ # --listen ...
81
+ ...</code></pre>
82
+ </li>
83
+ <li>(Opcional) Se preferir iniciar o servidor da API, edite o arquivo <code>API_FLAGS.txt</code> no diretório raiz do projeto e modifique as três primeiras linhas da seguinte forma:
84
+ <pre><code># --infer
85
+ --api
86
+ --listen ...
87
+ ...</code></pre>
88
+ </li>
89
+ </ul>
90
+ </li>
91
+ <li>(Opcional) Clique duas vezes em <code>run_cmd.bat</code> para entrar na CLI do conda/python deste projeto.</li>
92
+ </ol>
93
+
94
+ ## Configuração para Linux
95
+
96
+ ```bash
97
+ # Crie um ambiente virtual python 3.10, você também pode usar virtualenv
98
+ conda create -n fish-speech python=3.10
99
+ conda activate fish-speech
100
+
101
+ # Instale o pytorch
102
+ pip3 install torch torchvision torchaudio
103
+
104
+ # Instale o fish-speech
105
+ pip3 install -e .[stable]
106
+
107
+ # Para os Usuário do Ubuntu / Debian: Instale o sox
108
+ apt install libsox-dev
109
+ ```
110
+
111
+ ## Histórico de Alterações
112
+
113
+ - 02/07/2024: Fish-Speech atualizado para a versão 1.2, removido o Decodificador VITS e aprimorado consideravelmente a capacidade de zero-shot.
114
+ - 10/05/2024: Fish-Speech atualizado para a versão 1.1, implementado o decodificador VITS para reduzir a WER e melhorar a similaridade de timbre.
115
+ - 22/04/2024: Finalizada a versão 1.0 do Fish-Speech, modificados significativamente os modelos VQGAN e LLAMA.
116
+ - 28/12/2023: Adicionado suporte para ajuste fino `lora`.
117
+ - 27/12/2023: Adicionado suporte para `gradient checkpointing`, `causual sampling` e `flash-attn`.
118
+ - 19/12/2023: Atualizada a interface web e a API HTTP.
119
+ - 18/12/2023: Atualizada a documentação de ajuste fino e exemplos relacionados.
120
+ - 17/12/2023: Atualizado o modelo `text2semantic`, suportando o modo sem fonemas.
121
+ - 13/12/2023: Versão beta lançada, incluindo o modelo VQGAN e um modelo de linguagem baseado em LLAMA (suporte apenas a fonemas).
122
+
123
+ ## Agradecimentos
124
+
125
+ - [VITS2 (daniilrobnikov)](https://github.com/daniilrobnikov/vits2)
126
+ - [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)
127
+ - [GPT VITS](https://github.com/innnky/gpt-vits)
128
+ - [MQTTS](https://github.com/b04901014/MQTTS)
129
+ - [GPT Fast](https://github.com/pytorch-labs/gpt-fast)
130
+ - [Transformers](https://github.com/huggingface/transformers)
131
+ - [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS)
docs/pt/inference.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inferência
2
+
3
+ Suporte para inferência por linha de comando, API HTTP e interface web (WebUI).
4
+
5
+ !!! note
6
+ O processo de raciocínio, em geral, consiste em várias partes:
7
+
8
+ 1. Codificar cerca de 10 segundos de voz usando VQGAN.
9
+ 2. Inserir os tokens semânticos codificados e o texto correspondente no modelo de linguagem como um exemplo.
10
+ 3. Dado um novo trecho de texto, fazer com que o modelo gere os tokens semânticos correspondentes.
11
+ 4. Inserir os tokens semânticos gerados no VITS / VQGAN para decodificar e gerar a voz correspondente.
12
+
13
+ ## Inferência por Linha de Comando
14
+
15
+ Baixe os modelos `vqgan` e `llama` necessários do nosso repositório Hugging Face.
16
+
17
+ ```bash
18
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
19
+ ```
20
+
21
+ ### 1. Gerar prompt a partir da voz:
22
+
23
+ !!! note
24
+ Se quiser permitir que o modelo escolha aleatoriamente um timbre de voz, pule esta etapa.
25
+
26
+ ```bash
27
+ python tools/vqgan/inference.py \
28
+ -i "paimon.wav" \
29
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
30
+ ```
31
+
32
+ Você deverá obter um arquivo `fake.npy`.
33
+
34
+ ### 2. Gerar tokens semânticos a partir do texto:
35
+
36
+ ```bash
37
+ python tools/llama/generate.py \
38
+ --text "O texto que você deseja converter" \
39
+ --prompt-text "Seu texto de referência" \
40
+ --prompt-tokens "fake.npy" \
41
+ --checkpoint-path "checkpoints/fish-speech-1.4" \
42
+ --num-samples 2 \
43
+ --compile
44
+ ```
45
+
46
+ Este comando criará um arquivo `codes_N` no diretório de trabalho, onde N é um número inteiro começando de 0.
47
+
48
+ !!! note
49
+ Use `--compile` para fundir kernels CUDA para ter uma inferência mais rápida (~30 tokens/segundo -> ~500 tokens/segundo).
50
+ Mas, se não planeja usar a aceleração CUDA, comente o parâmetro `--compile`.
51
+
52
+ !!! info
53
+ Para GPUs que não suportam bf16, pode ser necessário usar o parâmetro `--half`.
54
+
55
+ ### 3. Gerar vocais a partir de tokens semânticos:
56
+
57
+ #### Decodificador VQGAN
58
+
59
+ ```bash
60
+ python tools/vqgan/inference.py \
61
+ -i "codes_0.npy" \
62
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
63
+ ```
64
+
65
+ ## Inferência por API HTTP
66
+
67
+ Fornecemos uma API HTTP para inferência. O seguinte comando pode ser usado para iniciar o servidor:
68
+
69
+ ```bash
70
+ python -m tools.api \
71
+ --listen 0.0.0.0:8080 \
72
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
73
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
74
+ --decoder-config-name firefly_gan_vq
75
+ ```
76
+
77
+ Para acelerar a inferência, adicione o parâmetro `--compile`.
78
+
79
+ Depois disso, é possível visualizar e testar a API em http://127.0.0.1:8080/.
80
+
81
+ Abaixo está um exemplo de envio de uma solicitação usando `tools/post_api.py`.
82
+
83
+ ```bash
84
+ python -m tools.post_api \
85
+ --text "Texto a ser inserido" \
86
+ --reference_audio "Caminho para o áudio de referência" \
87
+ --reference_text "Conteúdo de texto do áudio de referência" \
88
+ --streaming True
89
+ ```
90
+
91
+ O comando acima indica a síntese do áudio desejada de acordo com as informações do áudio de referência e a retorna em modo de streaming.
92
+
93
+ Caso selecione, de forma aleatória, o áudio de referência com base em `{SPEAKER}` e `{EMOTION}`, o configure de acordo com as seguintes etapas:
94
+
95
+ ### 1. Crie uma pasta `ref_data` no diretório raiz do projeto.
96
+
97
+ ### 2. Crie uma estrutura de diretórios semelhante à seguinte dentro da pasta `ref_data`.
98
+
99
+ ```
100
+ .
101
+ ├── SPEAKER1
102
+ │ ├──EMOTION1
103
+ │ │ ├── 21.15-26.44.lab
104
+ │ │ ├── 21.15-26.44.wav
105
+ │ │ ├── 27.51-29.98.lab
106
+ │ │ ├── 27.51-29.98.wav
107
+ │ │ ├── 30.1-32.71.lab
108
+ │ │ └── 30.1-32.71.flac
109
+ │ └──EMOTION2
110
+ │ ├── 30.1-32.71.lab
111
+ │ └── 30.1-32.71.mp3
112
+ └── SPEAKER2
113
+ └─── EMOTION3
114
+ ├── 30.1-32.71.lab
115
+ └── 30.1-32.71.mp3
116
+ ```
117
+
118
+ Ou seja, primeiro coloque as pastas `{SPEAKER}` em `ref_data`, depois coloque as pastas `{EMOTION}` em cada pasta de orador (speaker) e coloque qualquer número de `pares áudio-texto` em cada pasta de emoção.
119
+
120
+ ### 3. Digite o seguinte comando no ambiente virtual
121
+
122
+ ```bash
123
+ python tools/gen_ref.py
124
+
125
+ ```
126
+
127
+ ### 4. Chame a API.
128
+
129
+ ```bash
130
+ python -m tools.post_api \
131
+ --text "Texto a ser inserido" \
132
+ --speaker "${SPEAKER1}" \
133
+ --emotion "${EMOTION1}" \
134
+ --streaming True
135
+ ```
136
+
137
+ O exemplo acima é apenas para fins de teste.
138
+
139
+ ## Inferência por WebUI
140
+
141
+ Para iniciar a WebUI de Inferência execute o seguinte comando:
142
+
143
+ ```bash
144
+ python -m tools.webui \
145
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
146
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
147
+ --decoder-config-name firefly_gan_vq
148
+ ```
149
+
150
+ !!! note
151
+ É possível usar variáveis de ambiente do Gradio, como `GRADIO_SHARE`, `GRADIO_SERVER_PORT`, `GRADIO_SERVER_NAME`, para configurar a WebUI.
152
+
153
+ Divirta-se!
docs/pt/samples.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Amostras
2
+
3
+ As amostras da v1.2 estão disponíveis em [Bilibili](https://www.bilibili.com/video/BV1wz421B71D/).
4
+
5
+ As seguintes amostras são do modelo v1.1.
6
+
7
+ ## Frase em Chinês 1
8
+ ```
9
+ 人间灯火倒映湖中,她的渴望让静水泛起涟漪。若代价只是孤独,那就让这份愿望肆意流淌。
10
+ 流入她所注视的世间,也流入她如湖水般澄澈的目光。
11
+ ```
12
+
13
+ <table>
14
+ <thead>
15
+ <tr>
16
+ <th>Orador</th>
17
+ <th>Áudio de Entrada</th>
18
+ <th>Áudio Sintetizado</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>Nahida (Genshin Impact)</td>
24
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
25
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_output.wav" /></td>
26
+ </tr>
27
+ <tr>
28
+ <td>Zhongli (Genshin Impact)</td>
29
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_input.wav" /></td>
30
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_output.wav" /></td>
31
+ </tr>
32
+ <tr>
33
+ <td>Furina (Genshin Impact)</td>
34
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_input.wav" /></td>
35
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_output.wav" /></td>
36
+ </tr>
37
+ <tr>
38
+ <td>Orador Aleatório 1</td>
39
+ <td> - </td>
40
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/4_output.wav" /></td>
41
+ </tr>
42
+ <tr>
43
+ <td>Orador Aleatório 2</td>
44
+ <td> - </td>
45
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/5_output.wav" /></td>
46
+ </tr>
47
+ </tbody>
48
+ </table>
49
+
50
+
51
+ ## Frase em Chinês 2
52
+ ```
53
+ 你们这个是什么群啊,你们这是害人不浅啊你们这个群!谁是群主,出来!真的太过分了。你们搞这个群干什么?
54
+ 我儿子每一科的成绩都不过那个平均分呐,他现在初二,你叫我儿子怎么办啊?他现在还不到高中啊?
55
+ 你们害死我儿子了!快点出来你这个群主!再这样我去报警了啊!我跟你们说你们这一帮人啊,一天到晚啊,
56
+ 搞这些什么游戏啊,动漫啊,会害死你们的,你们没有前途我跟你说。你们这九百多个人,好好学习不好吗?
57
+ 一天到晚在上网。有什么意思啊?麻烦你重视一下你们的生活的目标啊?有一点学习目标行不行?一天到晚上网是不是人啊?
58
+ ```
59
+
60
+ <table>
61
+ <thead>
62
+ <tr>
63
+ <th>Orador</th>
64
+ <th>Áudio de Entrada</th>
65
+ <th>Áudio Sintetizado</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <tr>
70
+ <td>Nahida (Genshin Impact)</td>
71
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
72
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/6_output.wav" /></td>
73
+ </tr>
74
+ <tr>
75
+ <td>Orador Aleatório</td>
76
+ <td> - </td>
77
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/7_output.wav" /></td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+
82
+
83
+ ## Frase em Chinês 3
84
+ ```
85
+ 大家好,我是 Fish Audio 开发的开源文本转语音模型。经过十五万小时的数据训练,
86
+ 我已经能够熟练掌握中文、日语和英语,我的语言处理能力接近人类水平,声音表现形式丰富多变。
87
+ 作为一个仅有亿级参数的模型,我相信社区成员能够在个人设备上轻松运行和微调,让我成为您的私人语音助手。
88
+ ```
89
+
90
+
91
+ <table>
92
+ <thead>
93
+ <tr>
94
+ <th>Orador</th>
95
+ <th>Áudio de Entrada</th>
96
+ <th>Áudio Sintetizado</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>
100
+ <tr>
101
+ <td>Orador Aleatório</td>
102
+ <td> - </td>
103
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/8_output.wav" /></td>
104
+ </tr>
105
+ </tbody>
106
+ </table>
107
+
108
+ ## Frase em Inglês 1
109
+
110
+ ```
111
+ In the realm of advanced technology, the evolution of artificial intelligence stands as a
112
+ monumental achievement. This dynamic field, constantly pushing the boundaries of what
113
+ machines can do, has seen rapid growth and innovation. From deciphering complex data
114
+ patterns to driving cars autonomously, AI's applications are vast and diverse.
115
+ ```
116
+
117
+ <table>
118
+ <thead>
119
+ <tr>
120
+ <th>Orador</th>
121
+ <th>Áudio de Entrada</th>
122
+ <th>Áudio Sintetizado</th>
123
+ </tr>
124
+ </thead>
125
+ <tbody>
126
+ <tr>
127
+ <td>Orador Aleatório 1</td>
128
+ <td> - </td>
129
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/0_output.wav" /></td>
130
+ </tr>
131
+ <tr>
132
+ <td>Orador Aleatório 2</td>
133
+ <td> - </td>
134
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/1_output.wav" /></td>
135
+ </tr>
136
+ </tbody>
137
+ </table>
138
+
139
+ ## Frase em Inglês 2
140
+ ```
141
+ Hello everyone, I am an open-source text-to-speech model developed by
142
+ Fish Audio. After training with 150,000 hours of data, I have become proficient
143
+ in Chinese, Japanese, and English, and my language processing abilities
144
+ are close to human level. My voice is capable of a wide range of expressions.
145
+ As a model with only hundreds of millions of parameters, I believe community
146
+ members can easily run and fine-tune me on their personal devices, allowing
147
+ me to serve as your personal voice assistant.
148
+ ```
149
+
150
+ <table>
151
+ <thead>
152
+ <tr>
153
+ <th>Orador</th>
154
+ <th>Áudio de Entrada</th>
155
+ <th>Áudio Sintetizado</th>
156
+ </tr>
157
+ </thead>
158
+ <tbody>
159
+ <tr>
160
+ <td>Orador Aleatório</td>
161
+ <td> - </td>
162
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/2_output.wav" /></td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+ ## Frase em Japonês 1
168
+
169
+ ```
170
+ 先進技術の領域において、人工知能の進化は画期的な成果として立っています。常に機械ができることの限界を
171
+ 押し広げているこのダイナミックな分野は、急速な成長と革新を見せています。複雑なデータパターンの解読か
172
+ ら自動運転車の操縦まで、AIの応用は広範囲に及びます。
173
+ ```
174
+
175
+
176
+ <table>
177
+ <thead>
178
+ <tr>
179
+ <th>Orador</th>
180
+ <th>Áudio de Entrada</th>
181
+ <th>Áudio Sintetizado</th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr>
186
+ <td>Orador Aleatório 1</td>
187
+ <td> - </td>
188
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/0_output.wav" /></td>
189
+ </tr>
190
+ <tr>
191
+ <td>Orador Aleatório 2</td>
192
+ <td> - </td>
193
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/1_output.wav" /></td>
194
+ </tr>
195
+ </tbody>
196
+ </table>
197
+
198
+ ## Frase em Japonês 2
199
+ ```
200
+ 皆さん、こんにちは。私はフィッシュオーディオによって開発されたオープンソースのテ
201
+ キストから音声への変換モデルです。15万時間のデータトレーニングを経て、
202
+ 中国語、日本語、英語を熟知しており、言語処理能力は人間に近いレベルです。
203
+ 声の表現も多彩で豊かです。数億のパラメータを持つこのモデルは、コミュニティ
204
+ のメンバーが個人のデバイスで簡単に実行し、微調整することができると
205
+ 信じています。これにより、私を個人の音声アシスタントとして活用できます。
206
+ ```
207
+
208
+ <table>
209
+ <thead>
210
+ <tr>
211
+ <th>Orador</th>
212
+ <th>Áudio de Entrada</th>
213
+ <th>Áudio Sintetizado</th>
214
+ </tr>
215
+ </thead>
216
+ <tbody>
217
+ <tr>
218
+ <td>Orador Aleatório</td>
219
+ <td> - </td>
220
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/2_output.wav" /></td>
221
+ </tr>
222
+ </tbody>
223
+ </table>
docs/requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ mkdocs-material
2
+ mkdocs-static-i18n[material]
3
+ mkdocs[i18n]
docs/stylesheets/extra.css ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .md-grid {
2
+ max-width: 1440px;
3
+ }
docs/zh/finetune.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 微调
2
+
3
+ 显然, 当你打开这个页面的时候, 你已经对预训练模型 zero-shot 的效果不算满意. 你想要微调一个模型, 使得它在你的数据集上表现更好.
4
+
5
+ 在目前版本,你只需要微调'LLAMA'部分即可.
6
+
7
+ ## LLAMA 微调
8
+ ### 1. 准备数据集
9
+
10
+ ```
11
+ .
12
+ ├── SPK1
13
+ │ ├── 21.15-26.44.lab
14
+ │ ├── 21.15-26.44.mp3
15
+ │ ├── 27.51-29.98.lab
16
+ │ ├── 27.51-29.98.mp3
17
+ │ ├── 30.1-32.71.lab
18
+ │ └── 30.1-32.71.mp3
19
+ └── SPK2
20
+ ├── 38.79-40.85.lab
21
+ └── 38.79-40.85.mp3
22
+ ```
23
+
24
+ 你需要将数据集转为以上格式, 并放到 `data` 下, 音频后缀可以为 `.mp3`, `.wav` 或 `.flac`, 标注文件后缀建议为 `.lab`.
25
+
26
+ !!! warning
27
+ 建议先对数据集进行响度匹配, 你可以使用 [fish-audio-preprocess](https://github.com/fishaudio/audio-preprocess) 来完成这一步骤.
28
+ ```bash
29
+ fap loudness-norm data-raw data --clean
30
+ ```
31
+
32
+ ### 2. 批量提取语义 token
33
+
34
+ 确保你已经下载了 vqgan 权重, 如果没有, 请运行以下命令:
35
+
36
+ ```bash
37
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
38
+ ```
39
+
40
+ 对于中国大陆用户, 可使用 mirror 下载.
41
+
42
+ ```bash
43
+ HF_ENDPOINT=https://hf-mirror.com huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
44
+ ```
45
+
46
+ 随后可运行以下命令来提取语义 token:
47
+
48
+ ```bash
49
+ python tools/vqgan/extract_vq.py data \
50
+ --num-workers 1 --batch-size 16 \
51
+ --config-name "firefly_gan_vq" \
52
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
53
+ ```
54
+
55
+ !!! note
56
+ 你可以调整 `--num-workers` 和 `--batch-size` 来提高提取速度, 但是请注意不要超过你的显存限制.
57
+
58
+ 该命令会在 `data` 目录下创建 `.npy` 文件, 如下所示:
59
+
60
+ ```
61
+ .
62
+ ├── SPK1
63
+ │ ├── 21.15-26.44.lab
64
+ │ ├── 21.15-26.44.mp3
65
+ │ ├── 21.15-26.44.npy
66
+ │ ├── 27.51-29.98.lab
67
+ │ ├── 27.51-29.98.mp3
68
+ │ ├── 27.51-29.98.npy
69
+ │ ├── 30.1-32.71.lab
70
+ │ ├── 30.1-32.71.mp3
71
+ │ └── 30.1-32.71.npy
72
+ └── SPK2
73
+ ├── 38.79-40.85.lab
74
+ ├── 38.79-40.85.mp3
75
+ └── 38.79-40.85.npy
76
+ ```
77
+
78
+ ### 3. 打包数据集为 protobuf
79
+
80
+ ```bash
81
+ python tools/llama/build_dataset.py \
82
+ --input "data" \
83
+ --output "data/protos" \
84
+ --text-extension .lab \
85
+ --num-workers 16
86
+ ```
87
+
88
+ 命令执行完毕后, 你应该能在 `data` 目录下看到 `protos` 文件.
89
+
90
+
91
+ ### 4. 最后, 使用 LoRA 进行微调
92
+
93
+ 同样的, 请确保你已经下载了 `LLAMA` 权重, 如果没有, 请运行以下命令:
94
+
95
+ ```bash
96
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
97
+ ```
98
+
99
+ 对于中国大陆用户, 可使用 mirror 下载.
100
+
101
+ ```bash
102
+ HF_ENDPOINT=https://hf-mirror.com huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
103
+ ```
104
+
105
+ 最后, 你可以运行以下命令来启动微调:
106
+
107
+ ```bash
108
+ python fish_speech/train.py --config-name text2semantic_finetune \
109
+ project=$project \
110
+ +lora@model.model.lora_config=r_8_alpha_16
111
+ ```
112
+
113
+ !!! note
114
+ 你可以通过修改 `fish_speech/configs/text2semantic_finetune.yaml` 来修改训练参数如 `batch_size`, `gradient_accumulation_steps` 等, 来适应你的显存.
115
+
116
+ !!! note
117
+ 对于 Windows 用户, 你可以使用 `trainer.strategy.process_group_backend=gloo` 来避免 `nccl` 的问题.
118
+
119
+ 训练结束后, 你可以参考 [推理](inference.md) 部分, 并携带 `--speaker SPK1` 参数来测试你的模型.
120
+
121
+ !!! info
122
+ 默认配置下, 基本只会学到说话人的发音方式, 而不包含音色, 你依然需要使用 prompt 来保证音色的稳定性.
123
+ 如果你想要学到音色, 请将训练步数调大, 但这有可能会导致过拟合.
124
+
125
+ 训练完成后, 你需要先将 loRA 的权重转为普通权重, 然后再进行推理.
126
+
127
+ ```bash
128
+ python tools/llama/merge_lora.py \
129
+ --lora-config r_8_alpha_16 \
130
+ --base-weight checkpoints/fish-speech-1.4 \
131
+ --lora-weight results/$project/checkpoints/step_000000010.ckpt \
132
+ --output checkpoints/fish-speech-1.4-yth-lora/
133
+ ```
134
+
135
+ !!! note
136
+ 你也可以尝试其他的 checkpoint, 我们建议你使用最早的满足你要求的 checkpoint, 他们通常在 OOD 上表现更好.
docs/zh/index.md ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 介绍
2
+
3
+ <div>
4
+ <a target="_blank" href="https://discord.gg/Es5qTB9BcN">
5
+ <img alt="Discord" src="https://img.shields.io/discord/1214047546020728892?color=%23738ADB&label=Discord&logo=discord&logoColor=white&style=flat-square"/>
6
+ </a>
7
+ <a target="_blank" href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=jCKlUP7QgSm9kh95UlBoYv6s1I-Apl1M&authKey=xI5ttVAp3do68IpEYEalwXSYZFdfxZSkah%2BctF5FIMyN2NqAa003vFtLqJyAVRfF&noverify=0&group_code=593946093">
8
+ <img alt="QQ" src="https://img.shields.io/badge/QQ Group-%2312B7F5?logo=tencent-qq&logoColor=white&style=flat-square"/>
9
+ </a>
10
+ <a target="_blank" href="https://hub.docker.com/r/fishaudio/fish-speech">
11
+ <img alt="Docker" src="https://img.shields.io/docker/pulls/fishaudio/fish-speech?style=flat-square&logo=docker"/>
12
+ </a>
13
+ </div>
14
+
15
+ !!! warning
16
+ 我们不对代码库的任何非法使用承担任何责任. 请参阅您当地关于 DMCA (数字千年法案) 和其他相关法律法规. <br/>
17
+ 此代码库与所有模型根据 CC-BY-NC-SA-4.0 许可证发布.
18
+
19
+ <p align="center">
20
+ <img src="../assets/figs/diagram.png" width="75%">
21
+ </p>
22
+
23
+ ## 要求
24
+
25
+ - GPU 内存: 4GB (用于推理), 8GB (用于微调)
26
+ - 系统: Linux, Windows
27
+
28
+ ## Windows 配置
29
+
30
+ Windows 专业用户可以考虑 WSL2 或 docker 来运行代码库。
31
+
32
+ ```bash
33
+ # 创建一个 python 3.10 虚拟环境, 你也可以用 virtualenv
34
+ conda create -n fish-speech python=3.10
35
+ conda activate fish-speech
36
+
37
+ # 安装 pytorch
38
+ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
39
+
40
+ # 安装 fish-speech
41
+ pip3 install -e .
42
+
43
+ # (开启编译加速) 安装 triton-windows
44
+ pip install https://github.com/AnyaCoder/fish-speech/releases/download/v0.1.0/triton_windows-0.1.0-py3-none-any.whl
45
+ ```
46
+
47
+ Windows 非专业用户可考虑以下为免 Linux 环境的基础运行方法(附带模型编译功能,即 `torch.compile`):
48
+
49
+ 1. 解压项目压缩包。
50
+ 2. 点击 `install_env.bat` 安装环境。
51
+ 3. 若需要开启编译加速则执行这一步:
52
+ 1. 使用如下链接下载 LLVM 编译器。
53
+ - [LLVM-17.0.6(原站站点下载)](https://huggingface.co/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true)
54
+ - [LLVM-17.0.6(镜像站点下载)](https://hf-mirror.com/fishaudio/fish-speech-1/resolve/main/LLVM-17.0.6-win64.exe?download=true)
55
+ - 下载完 `LLVM-17.0.6-win64.exe` 后,双击进行安装,选择合适的安装位置,最重要的是勾选 `Add Path to Current User` 添加环境变量。
56
+ - 确认安装完成。
57
+ 2. 下载安装 Microsoft Visual C++ 可再发行程序包,解决潜在 .dll 丢失问题。
58
+ - [MSVC++ 14.40.33810.0 下载](https://aka.ms/vs/17/release/vc_redist.x64.exe)
59
+ 3. 下载安装 Visual Studio 社区版以获取 MSVC++ 编译工具, 解决 LLVM 的头文件依赖问题。
60
+ - [Visual Studio 下载](https://visualstudio.microsoft.com/zh-hans/downloads/)
61
+ - 安装好 Visual Studio Installer 之后,下载 Visual Studio Community 2022
62
+ - 如下图点击`修改`按钮,找到`使用C++的桌面开发`项,勾选下载
63
+ 4. 下载安装 [CUDA Toolkit 12.x](https://developer.nvidia.com/cuda-12-1-0-download-archive?target_os=Windows&target_arch=x86_64)
64
+ 4. 双击 `start.bat` 打开训练推理 WebUI 管理界面. 如有需要,可照下列提示修改`API_FLAGS`.
65
+
66
+ !!! info "可选"
67
+
68
+ 想启动 推理 WebUI 界面?编辑项目根目录下的 `API_FLAGS.txt`, 前三行修改成如下格式:
69
+ ```
70
+ --infer
71
+ # --api
72
+ # --listen ...
73
+ ...
74
+ ```
75
+
76
+ !!! info "可选"
77
+
78
+ 想启动 API 服务器?编辑项目根目录下的 `API_FLAGS.txt`, 前三行修改成如下格式:
79
+ ```
80
+ # --infer
81
+ --api
82
+ --listen ...
83
+ ...
84
+ ```
85
+
86
+ !!! info "可选"
87
+
88
+ 双击 `run_cmd.bat` 进入本项目的 conda/python 命令行环境
89
+
90
+ ## Linux 配置
91
+
92
+ ```bash
93
+ # 创建一个 python 3.10 虚拟环境, 你也可以用 virtualenv
94
+ conda create -n fish-speech python=3.10
95
+ conda activate fish-speech
96
+
97
+ # 安装 pytorch
98
+ pip3 install torch torchvision torchaudio
99
+
100
+ # 安装 fish-speech
101
+ pip3 install -e .[stable]
102
+
103
+ # (Ubuntu / Debian 用户) 安装 sox
104
+ apt install libsox-dev
105
+ ```
106
+
107
+ ## Docker 配置
108
+
109
+ 1. 安装 NVIDIA Container Toolkit:
110
+
111
+ Docker 如果想使用 GPU 进行模型训练和推理,需要安装 NVIDIA Container Toolkit :
112
+
113
+ 对于 Ubuntu 用户:
114
+
115
+ ```bash
116
+ # 添加远程仓库
117
+ curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
118
+ && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
119
+ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
120
+ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
121
+ # 安装 nvidia-container-toolkit
122
+ sudo apt-get update
123
+ sudo apt-get install -y nvidia-container-toolkit
124
+ # 重启 Docker 服务
125
+ sudo systemctl restart docker
126
+ ```
127
+
128
+ 对于使用其他 Linux 发行版的用户,安装指南请参考:[NVIDIA Container Toolkit Install-guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)。
129
+
130
+ 注:对于中国大陆的用户,您可能需要使用代理来完成相关工具的安装。
131
+
132
+ 2. 拉取并运行 fish-speech 镜像
133
+
134
+ ```shell
135
+ # 拉取镜像
136
+ docker pull fishaudio/fish-speech
137
+ # 运行镜像
138
+ docker run -it \
139
+ --name fish-speech \
140
+ --gpus all \
141
+ -p 7860:7860 \
142
+ fishaudio/fish-speech \
143
+ zsh
144
+ # 如果需要使用其他端口,请修改 -p 参数为 YourPort:7860
145
+ ```
146
+
147
+ 3. 下载模型依赖
148
+
149
+ 确保您在 docker 容器内的终端,然后再从我们的 huggingface 仓库下载所需的 `vqgan` 和 `llama` 模型。
150
+
151
+ ```bash
152
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
153
+ ```
154
+
155
+ 对于中国大陆用户,可以通过镜像站下载。
156
+
157
+ ```bash
158
+ HF_ENDPOINT=https://hf-mirror.com huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
159
+ ```
160
+
161
+ 4. 配置环境变量,访问 WebUI
162
+
163
+ 在 docker 容器内的终端,输入 `export GRADIO_SERVER_NAME="0.0.0.0"` ,从而让外部可以访问 docker 内的 gradio 服务。
164
+ 接着在 docker 容器内的终端,输入 `python tools/webui.py` 即可开启 WebUI 服务。
165
+
166
+ 如果是 WSL 或者是 MacOS ,访问 [http://localhost:7860](http://localhost:7860) 即可打开 WebUI 界面。
167
+
168
+ 如果是部署在服务器上,更换 localhost 为您的服务器 ip 即可。
169
+
170
+ ## 更新日志
171
+
172
+ - 2024/09/10: 更新了 Fish-Speech 到 1.4, 增加了数据集大小, quantizer n_groups 4 -> 8.
173
+ - 2024/07/02: 更新了 Fish-Speech 到 1.2 版本,移除 VITS Decoder,同时极大幅度提升 zero-shot 能力.
174
+ - 2024/05/10: 更新了 Fish-Speech 到 1.1 版本,引入了 VITS Decoder 来降低口胡和提高音色相似度.
175
+ - 2024/04/22: 完成了 Fish-Speech 1.0 版本, 大幅修改了 VQGAN 和 LLAMA 模型.
176
+ - 2023/12/28: 添加了 `lora` 微调支持.
177
+ - 2023/12/27: 添加了 `gradient checkpointing`, `causual sampling` 和 `flash-attn` 支持.
178
+ - 2023/12/19: 更新了 Webui 和 HTTP API.
179
+ - 2023/12/18: 更新了微调文档和相关例子.
180
+ - 2023/12/17: 更新了 `text2semantic` 模型, 支持无音素模式.
181
+ - 2023/12/13: 测试版发布, 包含 VQGAN 模型和一个基于 LLAMA 的语言模型 (只支持音素).
182
+
183
+ ## 致谢
184
+
185
+ - [VITS2 (daniilrobnikov)](https://github.com/daniilrobnikov/vits2)
186
+ - [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)
187
+ - [GPT VITS](https://github.com/innnky/gpt-vits)
188
+ - [MQTTS](https://github.com/b04901014/MQTTS)
189
+ - [GPT Fast](https://github.com/pytorch-labs/gpt-fast)
190
+ - [Transformers](https://github.com/huggingface/transformers)
191
+ - [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS)
docs/zh/inference.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 推理
2
+
3
+ 推理支持命令行, http api, 以及 webui 三种方式.
4
+
5
+ !!! note
6
+ 总的来说, 推理分为几个部分:
7
+
8
+ 1. 给定一段 ~10 秒的语音, 将它用 VQGAN 编码.
9
+ 2. 将编码后的语义 token 和对应文本输入语言模型作为例子.
10
+ 3. 给定一段新文本, 让模型生成对应的语义 token.
11
+ 4. 将生成的语义 token 输入 VQGAN 解码, 生成对应的语音.
12
+
13
+ ## 命令行推理
14
+
15
+ 从我们的 huggingface 仓库下载所需的 `vqgan` 和 `llama` 模型。
16
+
17
+ ```bash
18
+ huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
19
+ ```
20
+
21
+ 对于中国大陆用户,可使用 mirror 下载。
22
+
23
+ ```bash
24
+ HF_ENDPOINT=https://hf-mirror.com huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
25
+ ```
26
+
27
+ ### 1. 从语音生成 prompt:
28
+
29
+ !!! note
30
+ 如果你打算让模型随机选择音色, 你可以跳过这一步.
31
+
32
+ ```bash
33
+ python tools/vqgan/inference.py \
34
+ -i "paimon.wav" \
35
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
36
+ ```
37
+
38
+ 你应该能得到一个 `fake.npy` 文件.
39
+
40
+ ### 2. 从文本生成语义 token:
41
+
42
+ ```bash
43
+ python tools/llama/generate.py \
44
+ --text "要转换的文本" \
45
+ --prompt-text "你的参考文本" \
46
+ --prompt-tokens "fake.npy" \
47
+ --checkpoint-path "checkpoints/fish-speech-1.4" \
48
+ --num-samples 2 \
49
+ --compile
50
+ ```
51
+
52
+ 该命令会在工作目录下创建 `codes_N` 文件, 其中 N 是从 0 开始的整数.
53
+
54
+ !!! note
55
+ 您可能希望使用 `--compile` 来融合 cuda 内核以实现更快的推理 (~30 个 token/秒 -> ~500 个 token/秒).
56
+ 对应的, 如果你不打算使用加速, 你可以注释掉 `--compile` 参数.
57
+
58
+ !!! info
59
+ 对于不支持 bf16 的 GPU, 你可能需要使用 `--half` 参数.
60
+
61
+ ### 3. 从语义 token 生成人声:
62
+
63
+ #### VQGAN 解码
64
+
65
+ ```bash
66
+ python tools/vqgan/inference.py \
67
+ -i "codes_0.npy" \
68
+ --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
69
+ ```
70
+
71
+ ## HTTP API 推理
72
+
73
+ 运行以下命令来启动 HTTP 服务:
74
+
75
+ ```bash
76
+ python -m tools.api \
77
+ --listen 0.0.0.0:8080 \
78
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
79
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
80
+ --decoder-config-name firefly_gan_vq
81
+ ```
82
+ 如果你想要加速推理,可以加上`--compile`参数。
83
+
84
+ 推荐中国大陆用户运行以下命令来启动 HTTP 服务:
85
+ ```bash
86
+ HF_ENDPOINT=https://hf-mirror.com python -m ...(同上)
87
+ ```
88
+
89
+ 随后, 你可以在 `http://127.0.0.1:8080/` 中查看并测试 API.
90
+
91
+ 下面是使用`tools/post_api.py`发送请求的示例。
92
+
93
+ ```bash
94
+ python -m tools.post_api \
95
+ --text "要输入的文本" \
96
+ --reference_audio "参考音频路径" \
97
+ --reference_text "参考音频的文本内容" \
98
+ --streaming True
99
+ ```
100
+
101
+ 上面的命令表示按照参考音频的信息,合成所需的音频并流式返回.
102
+
103
+ 下面的示例展示了, 可以一次使用**多个** `参考音频路径` 和 `参考音频的文本内容`。在命令里用空格隔开即可。
104
+
105
+ ```bash
106
+ python -m tools.post_api \
107
+ --text "要输入的文本" \
108
+ --reference_audio "参考音频路径1" "参考音频路径2" \
109
+ --reference_text "参考音频的文本内容1" "参考音频的文本内容2"\
110
+ --streaming False \
111
+ --output "generated" \
112
+ --format "mp3"
113
+ ```
114
+
115
+ 上面的命令表示按照多个参考音频的信息,合成所需的`MP3`格式音频,并保存为当前目录的`generated.mp3`文件。
116
+
117
+ ## GUI 推理
118
+ [下载客户端](https://github.com/AnyaCoder/fish-speech-gui/releases/tag/v0.1.0)
119
+
120
+ ## WebUI 推理
121
+
122
+ 你可以使用以下命令来启动 WebUI:
123
+
124
+ ```bash
125
+ python -m tools.webui \
126
+ --llama-checkpoint-path "checkpoints/fish-speech-1.4" \
127
+ --decoder-checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth" \
128
+ --decoder-config-name firefly_gan_vq
129
+ ```
130
+
131
+ !!! note
132
+ 你可以使用 Gradio 环境变量, 如 `GRADIO_SHARE`, `GRADIO_SERVER_PORT`, `GRADIO_SERVER_NAME` 来配置 WebUI.
133
+
134
+ 祝大家玩得开心!
docs/zh/samples.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 例子
2
+
3
+ v1.2 的样本可以在 [Bilibili](https://www.bilibili.com/video/BV1wz421B71D/) 观看。
4
+
5
+ 以下样本来自 v1.1 版本的模型。
6
+
7
+ ## 中文句子 1
8
+ ```
9
+ 人间灯火倒映湖中,她的渴望让静水泛起涟漪。若代价只是孤独,那就让这份愿望肆意流淌。
10
+ 流入她所注视的世间,也流入她如湖水般澄澈的目光。
11
+ ```
12
+
13
+ <table>
14
+ <thead>
15
+ <tr>
16
+ <th>说话人</th>
17
+ <th>输入音频</th>
18
+ <th>合成音频</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>纳西妲 (原神)</td>
24
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
25
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_output.wav" /></td>
26
+ </tr>
27
+ <tr>
28
+ <td>钟离 (原神)</td>
29
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_input.wav" /></td>
30
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/1_output.wav" /></td>
31
+ </tr>
32
+ <tr>
33
+ <td>芙宁娜 (原神)</td>
34
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_input.wav" /></td>
35
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/2_output.wav" /></td>
36
+ </tr>
37
+ <tr>
38
+ <td>随机说话人 1</td>
39
+ <td> - </td>
40
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/4_output.wav" /></td>
41
+ </tr>
42
+ <tr>
43
+ <td>随机说话人 2</td>
44
+ <td> - </td>
45
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/5_output.wav" /></td>
46
+ </tr>
47
+ </tbody>
48
+ </table>
49
+
50
+
51
+ ## 中文句子 2
52
+ ```
53
+ 你们这个是什么群啊,你们这是害人不浅啊你们这个群!谁是群主,出来!真的太过分了。你们搞这个群干什么?
54
+ 我儿子每一科的成绩都不过那个平均分呐,他现在初二,你叫我儿子怎么办啊?他现在还不到高中啊?
55
+ 你们害死我儿子了!快点出来你这个群主!再这样我去报警了啊!我跟你们说你们这一帮人啊,一天到晚啊,
56
+ 搞这些什么游戏啊,动漫啊,会害死你们的,你们没有前途我跟你说。你们这九百多个人,好好学习不好吗?
57
+ 一天到晚在上网。有什么意思啊?麻烦你重视一下你们的生活的目标啊?有一点学习目标行不行?一天到晚上网是不是人啊?
58
+ ```
59
+
60
+ <table>
61
+ <thead>
62
+ <tr>
63
+ <th>说话人</th>
64
+ <th>输入音频</th>
65
+ <th>合成音频</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <tr>
70
+ <td>纳西妲 (原神)</td>
71
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/0_input.wav" /></td>
72
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/6_output.wav" /></td>
73
+ </tr>
74
+ <tr>
75
+ <td>随机说话人</td>
76
+ <td> - </td>
77
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/7_output.wav" /></td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+
82
+
83
+ ## 中文句子 3
84
+ ```
85
+ 大家好,我是 Fish Audio 开发的开源文本转语音模型。经过十五万小时的数据训练,
86
+ 我已经能够熟练掌握中文、日语和英语,我的语言处理能力接近人类水平,声音表现形式丰富多变。
87
+ 作为一个仅有亿级参数的模型,我相信社区成员能够在个人设备上轻松运行和微调,让我成为您的私人语音助手。
88
+ ```
89
+
90
+
91
+ <table>
92
+ <thead>
93
+ <tr>
94
+ <th>说话人</th>
95
+ <th>输入音频</th>
96
+ <th>合成音频</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>
100
+ <tr>
101
+ <td>随机说话人</td>
102
+ <td> - </td>
103
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/zh/8_output.wav" /></td>
104
+ </tr>
105
+ </tbody>
106
+ </table>
107
+
108
+ ## 英文句子 1
109
+
110
+ ```
111
+ In the realm of advanced technology, the evolution of artificial intelligence stands as a
112
+ monumental achievement. This dynamic field, constantly pushing the boundaries of what
113
+ machines can do, has seen rapid growth and innovation. From deciphering complex data
114
+ patterns to driving cars autonomously, AI's applications are vast and diverse.
115
+ ```
116
+
117
+ <table>
118
+ <thead>
119
+ <tr>
120
+ <th>说话人</th>
121
+ <th>输入音频</th>
122
+ <th>合成音频</th>
123
+ </tr>
124
+ </thead>
125
+ <tbody>
126
+ <tr>
127
+ <td>随机说话人 1</td>
128
+ <td> - </td>
129
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/0_output.wav" /></td>
130
+ </tr>
131
+ <tr>
132
+ <td>随机说话人 2</td>
133
+ <td> - </td>
134
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/1_output.wav" /></td>
135
+ </tr>
136
+ </tbody>
137
+ </table>
138
+
139
+ ## 英文句子 2
140
+ ```
141
+ Hello everyone, I am an open-source text-to-speech model developed by
142
+ Fish Audio. After training with 150,000 hours of data, I have become proficient
143
+ in Chinese, Japanese, and English, and my language processing abilities
144
+ are close to human level. My voice is capable of a wide range of expressions.
145
+ As a model with only hundreds of millions of parameters, I believe community
146
+ members can easily run and fine-tune me on their personal devices, allowing
147
+ me to serve as your personal voice assistant.
148
+ ```
149
+
150
+ <table>
151
+ <thead>
152
+ <tr>
153
+ <th>说话人</th>
154
+ <th>输入音频</th>
155
+ <th>合成音频</th>
156
+ </tr>
157
+ </thead>
158
+ <tbody>
159
+ <tr>
160
+ <td>随机说话人</td>
161
+ <td> - </td>
162
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/en/2_output.wav" /></td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+ ## 日文句子 1
168
+
169
+ ```
170
+ 先進技術の領域において、人工知能の進化は画期的な成果として立っています。常に機械ができることの限界を
171
+ 押し広げているこのダイナミックな分野は、急速な成長と革新を見せています。複雑なデータパターンの解読か
172
+ ら自動運転車の操縦まで、AIの応用は広範囲に及びます。
173
+ ```
174
+
175
+
176
+ <table>
177
+ <thead>
178
+ <tr>
179
+ <th>说话人</th>
180
+ <th>输入音频</th>
181
+ <th>合成音频</th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr>
186
+ <td>随机说话人 1</td>
187
+ <td> - </td>
188
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/0_output.wav" /></td>
189
+ </tr>
190
+ <tr>
191
+ <td>随机说话人 2</td>
192
+ <td> - </td>
193
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/1_output.wav" /></td>
194
+ </tr>
195
+ </tbody>
196
+ </table>
197
+
198
+ ## 日文句子 2
199
+ ```
200
+ 皆さん、こんにちは。私はフィッシュオーディオによって開発されたオープンソースのテ
201
+ キストから音声への変換モデルです。15万時間のデータトレーニングを経て、
202
+ 中国語、日本語、英語を熟知しており、言語処理能力は人間に近いレベルです。
203
+ 声の表現も多彩で豊かです。数億のパラメータを持つこのモデルは、コミュニティ
204
+ のメンバーが個人のデバイスで簡単に実行し、微調整することができると
205
+ 信じています。これにより、私を個人の音声アシスタントとして活用できます。
206
+ ```
207
+
208
+ <table>
209
+ <thead>
210
+ <tr>
211
+ <th>说话人</th>
212
+ <th>输入音频</th>
213
+ <th>合成音频</th>
214
+ </tr>
215
+ </thead>
216
+ <tbody>
217
+ <tr>
218
+ <td>随机说话人</td>
219
+ <td> - </td>
220
+ <td><audio controls preload="auto" src="https://demo-r2.speech.fish.audio/v1.1-sft-large/ja/2_output.wav" /></td>
221
+ </tr>
222
+ </tbody>
223
+ </table>
entrypoint.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ CUDA_ENABLED=${CUDA_ENABLED:-true}
4
+ DEVICE=""
5
+
6
+ if [ "${CUDA_ENABLED}" != "true" ]; then
7
+ DEVICE="--device cpu"
8
+ fi
9
+
10
+ exec python tools/webui.py ${DEVICE}
fish_speech/callbacks/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .grad_norm import GradNormMonitor
2
+
3
+ __all__ = ["GradNormMonitor"]
fish_speech/callbacks/grad_norm.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Union
2
+
3
+ import lightning.pytorch as pl
4
+ import torch
5
+ from lightning import LightningModule, Trainer
6
+ from lightning.pytorch.callbacks import Callback
7
+ from torch import Tensor, nn
8
+ from torch.utils._foreach_utils import (
9
+ _group_tensors_by_device_and_dtype,
10
+ _has_foreach_support,
11
+ )
12
+
13
+
14
+ @torch.no_grad()
15
+ def grad_norm(
16
+ parameters: Union[Tensor, list[Tensor]],
17
+ norm_type: float = 2.0,
18
+ ) -> float:
19
+ """
20
+ Returns the norm of the gradients of the given parameters.
21
+
22
+ Args:
23
+ parameters (Iterable[Tensor] or Tensor): an iterable of Tensors or a
24
+ single Tensor that will have gradients normalized
25
+ norm_type (float): type of the used p-norm.
26
+
27
+ Returns:
28
+ Total norm of the parameter gradients (viewed as a single vector).
29
+ """ # noqa: E501
30
+
31
+ if isinstance(parameters, Tensor):
32
+ parameters = [parameters]
33
+
34
+ grads = [p.grad for p in parameters if p.grad is not None]
35
+ if len(grads) == 0:
36
+ return None
37
+
38
+ first_device = grads[0].device
39
+ grouped_grads: dict[
40
+ tuple[torch.device, torch.dtype], list[list[Tensor]]
41
+ ] = _group_tensors_by_device_and_dtype(
42
+ [[g.detach() for g in grads]]
43
+ ) # type: ignore[assignment]
44
+
45
+ norms = []
46
+ for (device, _), ([grads], _) in grouped_grads.items():
47
+ if _has_foreach_support(grads, device=device):
48
+ norms.extend(torch._foreach_norm(grads, norm_type))
49
+ else:
50
+ norms.extend([torch.norm(g, norm_type) for g in grads])
51
+
52
+ return torch.norm(torch.stack([norm.to(first_device) for norm in norms]), norm_type)
53
+
54
+
55
+ class GradNormMonitor(Callback):
56
+ """
57
+ Callback that computes the gradient norm of the model parameters.
58
+ """
59
+
60
+ def __init__(
61
+ self,
62
+ norm_type: float = 2.0,
63
+ logging_interval: str = "step",
64
+ sub_module: Optional[Union[str, list[str]]] = None,
65
+ ) -> None:
66
+ """
67
+ Args:
68
+ norm_type (float): type of the used p-norm.
69
+ logging_interval (str): "step" or "epoch".
70
+ """
71
+ super().__init__()
72
+
73
+ self.norm_type = norm_type
74
+ self.logging_interval = logging_interval
75
+ self.sub_module = sub_module
76
+
77
+ def on_after_backward(self, trainer: Trainer, model: LightningModule) -> None:
78
+ """
79
+ Computes the gradient norm of the model parameters and logs it to the logger.
80
+
81
+ Args:
82
+ trainer (Trainer): The trainer object
83
+ model (LightningModule): The current lightningModule
84
+ """
85
+
86
+ lightning_model = model
87
+
88
+ if self.sub_module is None:
89
+ return self.log_sub_module_grad_norm(lightning_model, model, "")
90
+
91
+ sub_modules = self.sub_module
92
+ if isinstance(sub_modules, str):
93
+ sub_modules = [sub_modules]
94
+
95
+ for sub_module in sub_modules:
96
+ self.log_sub_module_grad_norm(
97
+ lightning_model, getattr(model, sub_module), f"/{sub_module}"
98
+ )
99
+
100
+ def log_sub_module_grad_norm(
101
+ self, lightning_model: LightningModule, model: nn.Module, path: str
102
+ ) -> None:
103
+ grad_norm_val = grad_norm(model.parameters(), self.norm_type)
104
+ if grad_norm_val is None:
105
+ return
106
+
107
+ on_step = self.logging_interval == "step"
108
+ lightning_model.log(
109
+ f"train{path}/grad_norm",
110
+ grad_norm_val,
111
+ on_step=on_step,
112
+ on_epoch=not on_step,
113
+ )
fish_speech/configs/base.yaml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Base configuration for training a model
2
+ paths:
3
+ run_dir: results/${project}
4
+ ckpt_dir: ${paths.run_dir}/checkpoints
5
+
6
+ hydra:
7
+ run:
8
+ dir: ${paths.run_dir}
9
+
10
+ # Lightning Trainer
11
+ trainer:
12
+ _target_: lightning.pytorch.trainer.Trainer
13
+
14
+ default_root_dir: ${paths.run_dir}
15
+ accelerator: gpu
16
+ num_nodes: 1
17
+ devices: auto
18
+ strategy:
19
+ _target_: lightning.pytorch.strategies.DDPStrategy
20
+ process_group_backend: nccl # This should be override when training on windows
21
+
22
+ precision: bf16-mixed
23
+
24
+ # disable validation by epoch end
25
+ check_val_every_n_epoch: null
26
+ val_check_interval: 5000
27
+ max_steps: 100_000
28
+
29
+ # Use torch.backends.cudnn.benchmark to speed up training
30
+ benchmark: true
31
+
32
+ # Callbacks
33
+ callbacks:
34
+ model_checkpoint:
35
+ _target_: lightning.pytorch.callbacks.ModelCheckpoint
36
+ dirpath: ${paths.ckpt_dir}
37
+ filename: "step_{step:09d}"
38
+ save_last: false # additionally always save an exact copy of the last checkpoint to a file last.ckpt
39
+ save_top_k: 5 # save 5 latest checkpoints
40
+ monitor: step # use step to monitor checkpoints
41
+ mode: max # save the latest checkpoint with the highest global_step
42
+ every_n_epochs: null # don't save checkpoints by epoch end
43
+ every_n_train_steps: 5000 # save checkpoints every 5000 steps
44
+ auto_insert_metric_name: false
45
+
46
+ model_summary:
47
+ _target_: lightning.pytorch.callbacks.ModelSummary
48
+ max_depth: 2 # the maximum depth of layer nesting that the summary will include
49
+
50
+ learning_rate_monitor:
51
+ _target_: lightning.pytorch.callbacks.LearningRateMonitor
52
+ logging_interval: step
53
+ log_momentum: false
54
+
55
+ grad_norm_monitor:
56
+ _target_: fish_speech.callbacks.GradNormMonitor
57
+ norm_type: 2
58
+ logging_interval: step
59
+
60
+ # Logger
61
+ logger:
62
+ tensorboard:
63
+ _target_: lightning.pytorch.loggers.tensorboard.TensorBoardLogger
64
+ save_dir: "${paths.run_dir}/tensorboard/"
65
+ name: null
66
+ log_graph: false
67
+ default_hp_metric: true
68
+ prefix: ""
69
+
70
+ # wandb:
71
+ # _target_: lightning.pytorch.loggers.wandb.WandbLogger
72
+ # # name: "" # name of the run (normally generated by wandb)
73
+ # save_dir: "${paths.run_dir}"
74
+ # offline: False
75
+ # id: null # pass correct id to resume experiment!
76
+ # anonymous: null # enable anonymous logging
77
+ # project: "fish-speech"
78
+ # log_model: False # upload lightning ckpts
79
+ # prefix: "" # a string to put at the beginning of metric keys
80
+ # # entity: "" # set to name of your wandb team
81
+ # group: ""
82
+ # tags: ["vq", "hq", "finetune"]
83
+ # job_type: ""
84
+
85
+ # Loop
86
+ train: true
87
+ test: false
fish_speech/configs/firefly_gan_vq.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _target_: fish_speech.models.vqgan.modules.firefly.FireflyArchitecture
2
+ spec_transform:
3
+ _target_: fish_speech.utils.spectrogram.LogMelSpectrogram
4
+ sample_rate: 44100
5
+ n_mels: 160
6
+ n_fft: 2048
7
+ hop_length: 512
8
+ win_length: 2048
9
+ backbone:
10
+ _target_: fish_speech.models.vqgan.modules.firefly.ConvNeXtEncoder
11
+ input_channels: 160
12
+ depths: [3, 3, 9, 3]
13
+ dims: [128, 256, 384, 512]
14
+ drop_path_rate: 0.2
15
+ kernel_size: 7
16
+ head:
17
+ _target_: fish_speech.models.vqgan.modules.firefly.HiFiGANGenerator
18
+ hop_length: 512
19
+ upsample_rates: [8, 8, 2, 2, 2] # aka. strides
20
+ upsample_kernel_sizes: [16, 16, 4, 4, 4]
21
+ resblock_kernel_sizes: [3, 7, 11]
22
+ resblock_dilation_sizes: [[1, 3, 5], [1, 3, 5], [1, 3, 5]]
23
+ num_mels: 512
24
+ upsample_initial_channel: 512
25
+ pre_conv_kernel_size: 13
26
+ post_conv_kernel_size: 13
27
+ quantizer:
28
+ _target_: fish_speech.models.vqgan.modules.fsq.DownsampleFiniteScalarQuantize
29
+ input_dim: 512
30
+ n_groups: 8
31
+ n_codebooks: 1
32
+ levels: [8, 5, 5, 5]
33
+ downsample_factor: [2, 2]
fish_speech/configs/lora/r_8_alpha_16.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ _target_: fish_speech.models.text2semantic.lora.LoraConfig
2
+ r: 8
3
+ lora_alpha: 16
4
+ lora_dropout: 0.01
fish_speech/configs/text2semantic_finetune.yaml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - base
3
+ - _self_
4
+
5
+ project: text2semantic_finetune_dual_ar
6
+ max_length: 4096
7
+ pretrained_ckpt_path: checkpoints/fish-speech-1.4
8
+
9
+ # Lightning Trainer
10
+ trainer:
11
+ accumulate_grad_batches: 1
12
+ gradient_clip_val: 1.0
13
+ gradient_clip_algorithm: "norm"
14
+ max_steps: 1000
15
+ precision: bf16-true
16
+ limit_val_batches: 10
17
+ val_check_interval: 100
18
+
19
+ # Dataset Configuration
20
+ tokenizer:
21
+ _target_: transformers.AutoTokenizer.from_pretrained
22
+ pretrained_model_name_or_path: ${pretrained_ckpt_path}
23
+
24
+ # Dataset Configuration
25
+ train_dataset:
26
+ _target_: fish_speech.datasets.semantic.AutoTextSemanticInstructionDataset
27
+ proto_files:
28
+ - data/protos
29
+ tokenizer: ${tokenizer}
30
+ causal: true
31
+ max_length: ${max_length}
32
+ use_speaker: false
33
+ interactive_prob: 0.7
34
+
35
+ val_dataset:
36
+ _target_: fish_speech.datasets.semantic.AutoTextSemanticInstructionDataset
37
+ proto_files:
38
+ - data/protos
39
+ tokenizer: ${tokenizer}
40
+ causal: true
41
+ max_length: ${max_length}
42
+ use_speaker: false
43
+ interactive_prob: 0.7
44
+
45
+ data:
46
+ _target_: fish_speech.datasets.semantic.SemanticDataModule
47
+ train_dataset: ${train_dataset}
48
+ val_dataset: ${val_dataset}
49
+ num_workers: 4
50
+ batch_size: 8
51
+ tokenizer: ${tokenizer}
52
+ max_length: ${max_length}
53
+
54
+ # Model Configuration
55
+ model:
56
+ _target_: fish_speech.models.text2semantic.lit_module.TextToSemantic
57
+ model:
58
+ _target_: fish_speech.models.text2semantic.llama.BaseTransformer.from_pretrained
59
+ path: ${pretrained_ckpt_path}
60
+ load_weights: true
61
+ max_length: ${max_length}
62
+ lora_config: null
63
+
64
+ optimizer:
65
+ _target_: torch.optim.AdamW
66
+ _partial_: true
67
+ lr: 1e-4
68
+ weight_decay: 0
69
+ betas: [0.9, 0.95]
70
+ eps: 1e-5
71
+
72
+ lr_scheduler:
73
+ _target_: torch.optim.lr_scheduler.LambdaLR
74
+ _partial_: true
75
+ lr_lambda:
76
+ _target_: fish_speech.scheduler.get_constant_schedule_with_warmup_lr_lambda
77
+ _partial_: true
78
+ num_warmup_steps: 10
79
+
80
+ # Callbacks
81
+ callbacks:
82
+ model_checkpoint:
83
+ every_n_train_steps: ${trainer.val_check_interval}
fish_speech/conversation.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ SEMANTIC_TOKEN = "<|semantic|>"
2
+ CODEBOOK_PAD_TOKEN_ID = 0
fish_speech/datasets/concat_repeat.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import bisect
2
+ import random
3
+ from typing import Iterable
4
+
5
+ from torch.utils.data import Dataset, IterableDataset
6
+
7
+
8
+ class ConcatRepeatDataset(Dataset):
9
+ datasets: list[Dataset]
10
+ cumulative_sizes: list[int]
11
+ repeats: list[int]
12
+
13
+ @staticmethod
14
+ def cumsum(sequence, repeats):
15
+ r, s = [], 0
16
+ for dataset, repeat in zip(sequence, repeats):
17
+ l = len(dataset) * repeat
18
+ r.append(l + s)
19
+ s += l
20
+ return r
21
+
22
+ def __init__(self, datasets: Iterable[Dataset], repeats: list[int]):
23
+ super().__init__()
24
+
25
+ self.datasets = list(datasets)
26
+ self.repeats = repeats
27
+
28
+ assert len(self.datasets) > 0, "datasets should not be an empty iterable"
29
+ assert len(self.datasets) == len(
30
+ repeats
31
+ ), "datasets and repeats should have the same length"
32
+
33
+ for d in self.datasets:
34
+ assert not isinstance(
35
+ d, IterableDataset
36
+ ), "ConcatRepeatDataset does not support IterableDataset"
37
+
38
+ self.cumulative_sizes = self.cumsum(self.datasets, self.repeats)
39
+
40
+ def __len__(self):
41
+ return self.cumulative_sizes[-1]
42
+
43
+ def __getitem__(self, idx):
44
+ dataset_idx = bisect.bisect_right(self.cumulative_sizes, idx)
45
+
46
+ if dataset_idx == 0:
47
+ sample_idx = idx
48
+ else:
49
+ sample_idx = idx - self.cumulative_sizes[dataset_idx - 1]
50
+
51
+ dataset = self.datasets[dataset_idx]
52
+
53
+ return dataset[sample_idx % len(dataset)]
fish_speech/datasets/protos/text-data.proto ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ syntax = "proto3";
2
+
3
+ package text_data;
4
+
5
+ message Semantics {
6
+ repeated uint32 values = 1;
7
+ }
8
+
9
+ message Sentence {
10
+ repeated string texts = 1;
11
+ repeated Semantics semantics = 3;
12
+ }
13
+
14
+ message TextData {
15
+ string source = 1;
16
+ string name = 2;
17
+ repeated Sentence sentences = 4;
18
+ }
19
+
20
+ message SampledData {
21
+ string source = 1;
22
+ string name = 2;
23
+ repeated Sentence samples = 3;
24
+ }