Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external package for monotonic alignment search #135

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 19 additions & 29 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ defaults:
shell:
bash
jobs:
build-sdist:
name: Build source distribution
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -20,37 +19,29 @@ jobs:
if [[ "v$version" != "$tag" ]]; then
exit 1
fi
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: 3.9
- run: |
python -m pip install -U pip setuptools build
- run: |
python -m build
- run: |
pip install dist/*.tar.gz
- uses: actions/upload-artifact@v4
with:
name: build-sdist
path: dist/*.tar.gz
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
version: "0.4.27"
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
- name: Set up Python
run: uv python install 3.12
- name: Build sdist and wheel
run: uv build
- name: Test installation of sdist and wheel
run: |
uv venv --no-project
uv pip install dist/*.tar.gz
uv pip install dist/*.whl
- uses: actions/upload-artifact@v4
with:
name: build-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
name: build
path: dist/*
publish-artifacts:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-sdist, build-wheels]
needs: [build]
environment:
name: release
url: https://pypi.org/p/coqui-tts
Expand All @@ -60,8 +51,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: build-*
merge-multiple: true
pattern: build
- run: |
ls -lh dist/
- name: Publish package distributions to PyPI
Expand Down
75 changes: 0 additions & 75 deletions CODE_OWNERS.rst

This file was deleted.

10 changes: 0 additions & 10 deletions MANIFEST.in

This file was deleted.

42 changes: 19 additions & 23 deletions TTS/tts/utils/helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import numpy as np
import torch
from monotonic_alignment_search import maximum_path as maximum_path_cython
from scipy.stats import betabinom
from torch.nn import functional as F

try:
from TTS.tts.utils.monotonic_align.core import maximum_path_c

CYTHON = True
except ModuleNotFoundError:
CYTHON = False
CYTHON = True


class StandardScaler:
Expand Down Expand Up @@ -174,23 +170,23 @@ def maximum_path(value, mask):
return maximum_path_numpy(value, mask)


def maximum_path_cython(value, mask):
"""Cython optimised version.
Shapes:
- value: :math:`[B, T_en, T_de]`
- mask: :math:`[B, T_en, T_de]`
"""
value = value * mask
device = value.device
dtype = value.dtype
value = value.data.cpu().numpy().astype(np.float32)
path = np.zeros_like(value).astype(np.int32)
mask = mask.data.cpu().numpy()

t_x_max = mask.sum(1)[:, 0].astype(np.int32)
t_y_max = mask.sum(2)[:, 0].astype(np.int32)
maximum_path_c(path, value, t_x_max, t_y_max)
return torch.from_numpy(path).to(device=device, dtype=dtype)
# def maximum_path_cython(value, mask):
# """Cython optimised version.
# Shapes:
# - value: :math:`[B, T_en, T_de]`
# - mask: :math:`[B, T_en, T_de]`
# """
# value = value * mask
# device = value.device
# dtype = value.dtype
# value = value.data.cpu().numpy().astype(np.float32)
# path = np.zeros_like(value).astype(np.int32)
# mask = mask.data.cpu().numpy()

# t_x_max = mask.sum(1)[:, 0].astype(np.int32)
# t_y_max = mask.sum(2)[:, 0].astype(np.int32)
# maximum_path_c(path, value, t_x_max, t_y_max)
# return torch.from_numpy(path).to(device=device, dtype=dtype)


def maximum_path_numpy(value, mask, max_neg_val=None):
Expand Down
Empty file.
47 changes: 0 additions & 47 deletions TTS/tts/utils/monotonic_align/core.pyx

This file was deleted.

50 changes: 40 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
[build-system]
requires = [
"setuptools",
"setuptools-scm",
"cython>=3.0.0",
"numpy>=2.0.0",
]
build-backend = "setuptools.build_meta"
# ,*++++++*, ,*++++++*,
# *++. .+++ *++. .++*
# *+* ,++++* *+* *+* ,++++, *+*
# ,+, .++++++++++* ,++,,,,*+, ,++++++++++. *+,
# *+. .++++++++++++..++ *+.,++++++++++++. .+*
# .+* ++++++++++++.*+, .+*.++++++++++++ *+,
# .++ *++++++++* ++, .++.*++++++++* ++,
# ,+++*. . .*++, ,++*. .*+++*
# *+, .,*++**. .**++**. ,+*
# .+* *+,
# *+. Coqui .+*
# *+* +++ TTS +++ *+*
# .+++*. . . *+++.
# ,+* *+++*... ...*+++* *+,
# .++. .""""+++++++****+++++++"""". ++.
# ,++. .++,
# .++* *++.
# *+++, ,+++*
# .,*++++::::::++++*,.
# ``````

[tool.setuptools.packages.find]
include = ["TTS*"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "coqui-tts"
Expand Down Expand Up @@ -64,6 +77,7 @@ dependencies = [
# Coqui stack
"coqui-tts-trainer>=0.1.4,<0.2.0",
"coqpit>=0.0.16",
"monotonic-alignment-search>=0.1.0",
# Gruut + supported languages
"gruut[de,es,fr]>=2.4.0",
# Tortoise
Expand Down Expand Up @@ -151,6 +165,22 @@ tts-server = "TTS.server.server:main"
[tool.uv]
constraint-dependencies = ["numba>0.58.0"]

[tool.hatch.build]
exclude = [
"/.github",
"/.gitignore",
"/.pre-commit-config.yaml",
"/.readthedocs.yml",
"/Makefile",
"/dockerfiles",
"/run_bash_tests.sh",
"/scripts",
"/tests",
]

[tool.hatch.build.targets.wheel]
packages = ["TTS"]

[tool.ruff]
line-length = 120
extend-exclude = ["*.ipynb"]
Expand Down
37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

Loading