Actualiser src/tadam.py

modif compteur découpe, renommage avec prise en compte du temps écoulé dans chunk
This commit is contained in:
babakounine 2024-01-08 13:09:16 +01:00
parent fe2c750e03
commit 31d6ac7c36

View File

@ -22,6 +22,8 @@ import os
import sys
import numpy as np
import getopt
from datetime import datetime
from datetime import timedelta
verbose = False
@ -105,10 +107,14 @@ def chunk(outfolder, length):
for i in range(sections):
if verbose:
print(
f"\t {str(i).zfill(len(str(sections)))}/{sections} \t {infile}")
filename = infile.replace('.wav', f'_{str(i).zfill(3)}.wav')
f"\t {str(i + 1).zfill(len(str(sections)))}/{sections} \t {infile}")
temp = data[i*samplerate*length: i *
samplerate*length+samplerate*length]
time_file = datetime.strptime(time, "%H%M%S") + timedelta(seconds = 5 * i)
time_file = str(time_file.time().__format__("%H%M%S"))
filename = infile.replace(f'{time}.wav', f'{time_file}_000.wav')
try:
sf.write(filename, temp, samplerate)
except: