Skip to content

Commit

Permalink
move use_spk_embedding to processor
Browse files Browse the repository at this point in the history
  • Loading branch information
aluminumbox committed Jul 11, 2024
1 parent 0fd15bb commit 6cebcb3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cosyvoice/dataset/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def batch(data, batch_type='static', batch_size=16, max_frames_in_batch=12000, m
logging.fatal('Unsupported batch type {}'.format(batch_type))


def padding(data, mode='train'):
def padding(data, use_spk_embedding, mode='train'):
""" Padding the data into training data
Args:
Expand Down Expand Up @@ -362,4 +362,8 @@ def padding(data, mode='train'):
'tts_index': tts_index,
'tts_text_token': tts_text_token,
'tts_text_token_len': tts_text_token_len})
if use_spk_embedding is True:
batch["embedding"] = batch["spk_embedding"]
else:
batch["embedding"] = batch["utt_embedding"]
yield batch
4 changes: 0 additions & 4 deletions cosyvoice/utils/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def train_one_epoc(self, model, optimizer, scheduler, train_data_loader, cv_data
info_dict["batch_idx"] = batch_idx
if cosyvoice_join(group_join, info_dict):
break
if info_dict["use_spk_embedding"] is True:
batch_dict["embedding"] = batch_dict["spk_embedding"]
else:
batch_dict["embedding"] = batch_dict["utt_embedding"]

# Disable gradient synchronizations across DDP processes.
# Within this context, gradients will be accumulated on module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ batch: !name:cosyvoice.dataset.processor.batch
batch_type: 'dynamic'
max_frames_in_batch: 12000
padding: !name:cosyvoice.dataset.processor.padding
use_spk_embedding: False # change to True during sft

# dataset processor pipeline
data_pipeline: [
Expand All @@ -190,7 +191,6 @@ train_conf:
scheduler: warmuplr
scheduler_conf:
warmup_steps: 25000
use_spk_embedding: False # change to True during sft
max_epoch: 200
grad_clip: 5
accum_grad: 2
Expand Down
2 changes: 1 addition & 1 deletion examples/libritts/cosyvoice/conf/cosyvoice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ batch: !name:cosyvoice.dataset.processor.batch
batch_type: 'dynamic'
max_frames_in_batch: 2000
padding: !name:cosyvoice.dataset.processor.padding
use_spk_embedding: False # change to True during sft

# dataset processor pipeline
data_pipeline: [
Expand All @@ -190,7 +191,6 @@ train_conf:
scheduler: warmuplr # change to constantlr during sft
scheduler_conf:
warmup_steps: 2500
use_spk_embedding: False # change to True during sft
max_epoch: 200
grad_clip: 5
accum_grad: 2
Expand Down

0 comments on commit 6cebcb3

Please sign in to comment.