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")