forked from Chiro-Canto/TadaridaTools
Actualiser src/tadam.py
modif compteur découpe, renommage avec prise en compte du temps écoulé dans chunk
This commit is contained in:
parent
fe2c750e03
commit
31d6ac7c36
10
src/tadam.py
10
src/tadam.py
@ -22,6 +22,8 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import getopt
|
import getopt
|
||||||
|
from datetime import datetime
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
verbose = False
|
verbose = False
|
||||||
|
|
||||||
@ -105,10 +107,14 @@ def chunk(outfolder, length):
|
|||||||
for i in range(sections):
|
for i in range(sections):
|
||||||
if verbose:
|
if verbose:
|
||||||
print(
|
print(
|
||||||
f"\t {str(i).zfill(len(str(sections)))}/{sections} \t {infile}")
|
f"\t {str(i + 1).zfill(len(str(sections)))}/{sections} \t {infile}")
|
||||||
filename = infile.replace('.wav', f'_{str(i).zfill(3)}.wav')
|
|
||||||
temp = data[i*samplerate*length: i *
|
temp = data[i*samplerate*length: i *
|
||||||
samplerate*length+samplerate*length]
|
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:
|
try:
|
||||||
sf.write(filename, temp, samplerate)
|
sf.write(filename, temp, samplerate)
|
||||||
except:
|
except:
|
||||||
|
Loading…
Reference in New Issue
Block a user