mirror of
https://github.com/2noise/ChatTTS.git
synced 2026-08-28 17:45:02 +08:00
chore(format): run black on dev (#670)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f3dcd970c9
commit
ccf7e4da6f
File diff suppressed because one or more lines are too long
+14
-4
@@ -152,7 +152,7 @@ class Chat:
|
||||
if hasattr(self, module):
|
||||
delattr(self, module)
|
||||
self.__init__(logger)
|
||||
|
||||
|
||||
def sample_random_speaker(self) -> str:
|
||||
return self.speaker.sample_random()
|
||||
|
||||
@@ -290,7 +290,9 @@ class Chat:
|
||||
gpt.prepare(compile=compile and "cuda" in str(device))
|
||||
self.gpt = gpt
|
||||
|
||||
self.speaker = Speaker(self.config.gpt.hidden_size, self.config.spk_stat, device)
|
||||
self.speaker = Speaker(
|
||||
self.config.gpt.hidden_size, self.config.spk_stat, device
|
||||
)
|
||||
self.logger.log(logging.INFO, "gpt loaded.")
|
||||
|
||||
decoder = (
|
||||
@@ -465,7 +467,11 @@ class Chat:
|
||||
params.spk_emb,
|
||||
),
|
||||
self.config.gpt.num_vq,
|
||||
prompt=self.speaker.decode_prompt(params.spk_smp) if params.spk_smp is not None else None,
|
||||
prompt=(
|
||||
self.speaker.decode_prompt(params.spk_smp)
|
||||
if params.spk_smp is not None
|
||||
else None
|
||||
),
|
||||
device=self.device_gpt,
|
||||
)
|
||||
start_idx = input_ids.shape[-2]
|
||||
@@ -524,7 +530,11 @@ class Chat:
|
||||
|
||||
if params.spk_emb is not None:
|
||||
self.speaker.apply(
|
||||
emb, params.spk_emb, input_ids, self.tokenizer.spk_emb_ids, self.gpt.device_gpt,
|
||||
emb,
|
||||
params.spk_emb,
|
||||
input_ids,
|
||||
self.tokenizer.spk_emb_ids,
|
||||
self.gpt.device_gpt,
|
||||
)
|
||||
|
||||
result = gpt.generate(
|
||||
|
||||
@@ -6,9 +6,12 @@ import numpy as np
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
|
||||
|
||||
class Speaker:
|
||||
def __init__(self, dim: int, spk_cfg: str, device=torch.device("cpu")) -> None:
|
||||
spk_stat = torch.from_numpy(np.frombuffer(b14.decode_from_string(spk_cfg), dtype=np.float16).copy()).to(device=device)
|
||||
spk_stat = torch.from_numpy(
|
||||
np.frombuffer(b14.decode_from_string(spk_cfg), dtype=np.float16).copy()
|
||||
).to(device=device)
|
||||
self.std, self.mean = spk_stat.requires_grad_(False).chunk(2)
|
||||
self.dim = dim
|
||||
|
||||
|
||||
+5
-1
@@ -60,7 +60,11 @@ input_ids, attention_mask, text_mask = chat.tokenizer.encode(
|
||||
params.spk_emb,
|
||||
),
|
||||
chat.config.gpt.num_vq,
|
||||
prompt=chat.speaker.decode_prompt(params.spk_smp) if params.spk_smp is not None else None,
|
||||
prompt=(
|
||||
chat.speaker.decode_prompt(params.spk_smp)
|
||||
if params.spk_smp is not None
|
||||
else None
|
||||
),
|
||||
device=chat.device_gpt,
|
||||
)
|
||||
with torch.inference_mode():
|
||||
|
||||
Reference in New Issue
Block a user