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

ENH: Update ChatTTS #1776

Merged
merged 4 commits into from
Jul 8, 2024
Merged
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
3 changes: 1 addition & 2 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ jobs:
${{ env.SELF_HOST_PYTHON }} -m conda install -c conda-forge pynini=2.1.5
${{ env.SELF_HOST_PYTHON }} -m pip install -U nemo_text_processing
${{ env.SELF_HOST_PYTHON }} -m pip install -U omegaconf~=2.3.0
${{ env.SELF_HOST_PYTHON }} -m pip install -U vector_quantize_pytorch
${{ env.SELF_HOST_PYTHON }} -m pip install -U vocos
${{ env.SELF_HOST_PYTHON }} -m pip install -U WeTextProcessing
${{ env.SELF_HOST_PYTHON }} -m pip install -U librosa
${{ env.SELF_HOST_PYTHON }} -m pip install -U xxhash
${{ env.SELF_HOST_PYTHON }} -m pip install -U "ChatTTS>0.1"
${{ env.SELF_HOST_PYTHON }} -m pytest --timeout=1500 \
-W ignore::PendingDeprecationWarning \
--cov-config=setup.cfg --cov-report=xml --cov=xinference xinference/model/image/tests/test_stable_diffusion.py
Expand Down
6 changes: 2 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ all =
torchvision # For deepseek VL
FlagEmbedding # For rerank
omegaconf~=2.3.0 # For ChatTTS
vector_quantize_pytorch # For ChatTTS
vocos # For ChatTTS
nemo_text_processing # For ChatTTS
WeTextProcessing # For ChatTTS
librosa # For ChatTTS
xxhash # For ChatTTS
ChatTTS>0.1
boto3>=1.28.55,<1.28.65 # For tensorizer
tensorizer~=2.9.0
intel =
Expand Down Expand Up @@ -155,12 +154,11 @@ image =
controlnet_aux
audio =
omegaconf~=2.3.0
vector_quantize_pytorch
vocos
nemo_text_processing
WeTextProcessing
librosa
xxhash
ChatTTS>0.1
doc =
ipython>=6.5.0
sphinx>=3.0.0
Expand Down
12 changes: 6 additions & 6 deletions xinference/model/audio/chattts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,19 @@ def __init__(
self._kwargs = kwargs

def load(self):
import ChatTTS
import torch

from xinference.thirdparty import ChatTTS

torch._dynamo.config.cache_size_limit = 64
torch._dynamo.config.suppress_errors = True
torch.set_float32_matmul_precision("high")
self._model = ChatTTS.Chat()
self._model.load_models(
source="local", local_path=self._model_path, compile=True
)
self._model.load(source="custom", custom_path=self._model_path, compile=True)

def speech(
self, input: str, voice: str, response_format: str = "mp3", speed: float = 1.0
):
import ChatTTS
import numpy as np
import torch
import torchaudio
Expand All @@ -71,7 +69,9 @@ def speech(

default = 5
infer_speed = int(default * speed)
params_infer_code = {"spk_emb": rnd_spk_emb, "prompt": f"[speed_{infer_speed}]"}
params_infer_code = ChatTTS.Chat.InferCodeParams(
prompt=f"[speed_{infer_speed}]", spk_emb=rnd_spk_emb
)

assert self._model is not None
wavs = self._model.infer([input], params_infer_code=params_infer_code)
Expand Down
5 changes: 3 additions & 2 deletions xinference/model/audio/tests/test_chattts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os.path
import tempfile


Expand Down Expand Up @@ -40,5 +40,6 @@ def test_chattts(setup):
response = client.audio.speech.create(
model=model_uid, input=input_string, voice="echo"
)
with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as f:
with tempfile.NamedTemporaryFile(suffix=".mp3", delete=True) as f:
response.stream_to_file(f.name)
assert os.stat(f.name).st_size > 0
1 change: 0 additions & 1 deletion xinference/thirdparty/ChatTTS/__init__.py

This file was deleted.

200 changes: 0 additions & 200 deletions xinference/thirdparty/ChatTTS/core.py

This file was deleted.

Empty file.
40 changes: 0 additions & 40 deletions xinference/thirdparty/ChatTTS/experimental/llm.py

This file was deleted.

Empty file.
Loading
Loading