Actualiser src/tadam.py #1

Merged
sortion merged 2 commits from babakounine/TadaridaTools:master into master 2024-01-09 13:22:51 +01:00
Showing only changes of commit 31d6ac7c36 - Show all commits

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: