Skip to content

Commit

Permalink
chore(format): run black on dev (#558)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Jul 10, 2024
1 parent 7ee5426 commit b517b38
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions tests/#521.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
fail = False
logger = get_logger("Test #521", lv=logging.WARN)


# 计算rms
# nan为噪声 !!!
def calculate_rms(data):
Expand All @@ -32,6 +33,7 @@ def calculate_rms(data):
# data = np.nan_to_num(data)
return np.sqrt(np.mean(np.square(data)))


# 流式声音处理器
class AudioStreamer:
# 流式写入
Expand All @@ -43,6 +45,7 @@ def write(waveform):
fail = True
logger.warning("NAN RMS found")


# ChatTTS流式处理
class ChatStreamer:
def __init__(self, waittime_topause=50, base_block_size=8000):
Expand Down Expand Up @@ -166,17 +169,18 @@ def start_writing(self, streamchat):
self.writer = threading.Thread(target=self.write, args=(streamchat,))
self.writer.start()


chat = ChatTTS.Chat(logger)
chat.load(compile=False) # Set to True for better performance

rand_spk = chat.sample_random_speaker()
params_infer_code = ChatTTS.Chat.InferCodeParams(
spk_emb=rand_spk, # add sampled speaker
temperature=0.0001, # using custom temperature
prompt="[speed_0]"
prompt="[speed_0]",
)
params_refine_text = ChatTTS.Chat.RefineTextParams(
prompt='[oral_2][laugh_0][break_6]',
prompt="[oral_2][laugh_0][break_6]",
)

# 获取ChatTTS 流式推理generator
Expand All @@ -193,19 +197,23 @@ def start_writing(self, streamchat):
# 一次性生成
streamer.write(streamchat)

streamer.write(chat.infer(
"有一个神奇的故事,传说在很远很远的未来。",
skip_refine_text=True,
params_infer_code=params_infer_code,
stream=True,
))
streamer.write(
chat.infer(
"有一个神奇的故事,传说在很远很远的未来。",
skip_refine_text=True,
params_infer_code=params_infer_code,
stream=True,
)
)

streamer.write(chat.infer(
"有一种叫做奥特曼的物种。他是超人族的一员。",
skip_refine_text=True,
params_infer_code=params_infer_code,
stream=True,
))
streamer.write(
chat.infer(
"有一种叫做奥特曼的物种。他是超人族的一员。",
skip_refine_text=True,
params_infer_code=params_infer_code,
stream=True,
)
)

if fail:
import sys
Expand Down

0 comments on commit b517b38

Please sign in to comment.