|
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()) |
|
|
|
current_datetime = datetime.datetime.fromtimestamp(current_timestamp) |
|
return current_datetime.strftime("%Y-%m-%d-%H-%M-%S") |