From 30e1bbb327c4a1ed7dc7490bcde1557393bec500 Mon Sep 17 00:00:00 2001 From: babakounine Date: Fri, 6 Sep 2024 14:45:12 +0200 Subject: [PATCH 1/3] update date consideration in chunk function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when the recording starts at 23:59 and lasts more than 5 seconds the following splits get an accurate time 00:04, 00:09 and so on, but the date isn’t updated. I modified that in order to take into account both date and time so that timedelta, when adding 5secs also changes the date --- src/tadam.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tadam.py b/src/tadam.py index 1656883..023a819 100755 --- a/src/tadam.py +++ b/src/tadam.py @@ -97,7 +97,9 @@ def chunk(outfolder, length): for file in os.listdir(outfolder): infile = os.path.join(outfolder, file) extension = infile.split(".")[-1] + date = infile.siplit("_")[-2] time = infile.split("_")[-1].split(".")[0] + time = date + "_" + time if not extension in ["wav", "WAV"]: continue try: @@ -116,8 +118,8 @@ def chunk(outfolder, length): 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")) + time_file = datetime.strptime(time, "%Y%m%d_%H%M%S") + timedelta(seconds = 5 * i) + time_file = str(time_file.time().__format__("%Y%m%d_%H%M%S")) filename = infile.replace(f'{time}.wav', f'{time_file}_000.wav') try: sf.write(filename, temp, samplerate) From 4ae3750184ddb2cc4ff51a4a6c19ba5d10d265f0 Mon Sep 17 00:00:00 2001 From: babakounine Date: Fri, 6 Sep 2024 18:34:05 +0200 Subject: [PATCH 2/3] correction typo --- src/tadam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tadam.py b/src/tadam.py index 023a819..53ca741 100755 --- a/src/tadam.py +++ b/src/tadam.py @@ -97,7 +97,7 @@ def chunk(outfolder, length): for file in os.listdir(outfolder): infile = os.path.join(outfolder, file) extension = infile.split(".")[-1] - date = infile.siplit("_")[-2] + date = infile.split("_")[-2] time = infile.split("_")[-1].split(".")[0] time = date + "_" + time if not extension in ["wav", "WAV"]: From 3c474ea1b01f602a9ed0c2a77a3f2d01464a8109 Mon Sep 17 00:00:00 2001 From: babakounine Date: Fri, 6 Sep 2024 19:02:09 +0200 Subject: [PATCH 3/3] time format correction to date --- src/tadam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tadam.py b/src/tadam.py index 53ca741..8a2bee8 100755 --- a/src/tadam.py +++ b/src/tadam.py @@ -119,7 +119,7 @@ def chunk(outfolder, length): samplerate*length+samplerate*length] time_file = datetime.strptime(time, "%Y%m%d_%H%M%S") + timedelta(seconds = 5 * i) - time_file = str(time_file.time().__format__("%Y%m%d_%H%M%S")) + time_file = str(time_file.__format__("%Y%m%d_%H%M%S")) filename = infile.replace(f'{time}.wav', f'{time_file}_000.wav') try: sf.write(filename, temp, samplerate)