chat-tts / test /common_test.py
chenjgtea
拆分gpu、cpu模式运行模式
a536c15
raw
history blame contribute delete
734 Bytes
import datetime
import time
import os,sys
now_dir = os.getcwd()
sys.path.append(now_dir)
from tool.logger import get_logger
logger=get_logger("common-test")
def save_mp3_file(wav, index, prefix_name):
from tool.np import pcm_arr_to_mp3_view
data = pcm_arr_to_mp3_view(wav)
mp3_filename = prefix_name + "_" + str(index) + ".mp3"
with open(mp3_filename, "wb") as f:
f.write(data)
logger.info(f"Audio saved to {mp3_filename}")
def get_date_time():
# 获取当前时间戳(秒级别)
current_timestamp = int(time.time())
# 将时间戳转换为datetime对象
current_datetime = datetime.datetime.fromtimestamp(current_timestamp)
return current_datetime.strftime("%Y-%m-%d-%H-%M-%S")