Skip to content

Commit

Permalink
Merge pull request #670 from FunAudioLLM/dev/lyuxiang.lx
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
aluminumbox authored Nov 22, 2024
2 parents d6dbdfb + dc3f643 commit 07352a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cosyvoice/cli/cosyvoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from tqdm import tqdm
from hyperpyyaml import load_hyperpyyaml
from modelscope import snapshot_download
import torch
from cosyvoice.cli.frontend import CosyVoiceFrontEnd
from cosyvoice.cli.model import CosyVoiceModel
from cosyvoice.utils.file_utils import logging
Expand All @@ -37,6 +38,10 @@ def __init__(self, model_dir, load_jit=True, load_onnx=False, fp16=True):
'{}/spk2info.pt'.format(model_dir),
instruct,
configs['allowed_special'])
if torch.cuda.is_available() is False and (fp16 is True or load_jit is True):
load_jit = False
fp16 = False
logging.warning('cpu do not support fp16 and jit, force set to False')
self.model = CosyVoiceModel(configs['llm'], configs['flow'], configs['hift'], fp16)
self.model.load('{}/llm.pt'.format(model_dir),
'{}/flow.pt'.format(model_dir),
Expand Down
2 changes: 2 additions & 0 deletions cosyvoice/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def fade_in_out(fade_in_mel, fade_out_mel, window):
device = fade_in_mel.device
fade_in_mel, fade_out_mel = fade_in_mel.cpu(), fade_out_mel.cpu()
mel_overlap_len = int(window.shape[0] / 2)
if fade_in_mel.device == torch.device('cpu'):
fade_in_mel = fade_in_mel.clone()
fade_in_mel[..., :mel_overlap_len] = fade_in_mel[..., :mel_overlap_len] * window[:mel_overlap_len] + \
fade_out_mel[..., -mel_overlap_len:] * window[mel_overlap_len:]
return fade_in_mel.to(device)
Expand Down

0 comments on commit 07352a5

Please sign in to comment.