mirror of
https://github.com/FunAudioLLM/CosyVoice.git
synced 2026-02-05 01:49:25 +08:00
fix(bug).when generating text that contains only punctuation marks or whitespace characters, the CPU usage reaches 100%, and the process crashes.
This commit is contained in:
@@ -20,7 +20,6 @@ from typing import List
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
import regex
|
||||
|
||||
IGNORE_ID = -1
|
||||
|
||||
@@ -156,12 +155,6 @@ def set_all_random_seed(seed):
|
||||
torch.cuda.manual_seed_all(seed)
|
||||
|
||||
|
||||
def is_only_punctuation(text):
|
||||
# Regular expression: Match strings that consist only of punctuation marks or are empty.
|
||||
punctuation_pattern = r'^[\p{P}\p{S}]*$'
|
||||
return bool(regex.fullmatch(punctuation_pattern, text))
|
||||
|
||||
|
||||
def mask_to_bias(mask: torch.Tensor, dtype: torch.dtype) -> torch.Tensor:
|
||||
assert mask.dtype == torch.bool
|
||||
assert dtype in [torch.float32, torch.bfloat16, torch.float16]
|
||||
|
||||
Reference in New Issue
Block a user