Commit c1a7039b authored by Anthony Larcher's avatar Anthony Larcher
Browse files

trs

parent f5d3d991
......@@ -36,40 +36,17 @@ from .user_simulation import FileInfo
from .user_simulation import Reference
from .user_simulation import UEM
def get_key(filename):
if filename[0:3] == "199" or filename[0:3] == "200":
return filename[0:8] + "." + filename[9:13] + "." + filename[19:]
l = len(filename)
if filename[l - 17 : l - 14] == "201":
return (
filename[l - 17 : l - 13]
+ filename[l - 12 : l - 10]
+ filename[l - 9 : l - 7]
+ "."
+ filename[l - 6 : l - 2]
+ "."
+ filename[0 : l - 18]
)
if filename[14:18] == "2010":
if filename[27:28] == "_":
return filename[14:22] + "." + filename[23:27] + "." + filename[28:]
else:
return filename[14:22] + "." + filename[23:27] + "." + filename[30:]
if filename[:3] == "201":
pp = filename.split(".")[0].split("_")
return pp[0] + "." + "_".join(pp[1:-1]) + "." + pp[-1]
return "???"
def get_file_list(path):
pairs = []
file_list = []
for name in os.listdir(path):
if not name.startswith('.'):
name = name[:-5]
k = get_key(name)
pairs.append([k, name])
pairs.sort(key=lambda p: p[0])
return pairs
# remove the last extension only
name = ".".join(name.split(".")[:-1])
#name = name[:-5]
file_list.append(name)
file_list.sort()
return file_list
def hashrand(a):
......@@ -96,12 +73,7 @@ class Database:
"""
def __init__(self, root_folder, parameters, show=None):
"""
:param root_folder:
:param parameters:
:param show: can be LCP, BFM, topquestions, pileetface, cultureetvous, cavousregarde, lcpinfo, entre, ruthelkrief or a list of files to process
"""
filter_mode = None
if show is None:
pass
......@@ -117,12 +89,10 @@ class Database:
filter_mode = "list"
filter_list = [show,]
self.index = 0
self.root_folder = root_folder
self.fl = get_file_list(root_folder + "/mdtm")
self.fl = get_file_list(root_folder + "/trs")
Entry = namedtuple(
# 'Entry', ['root_folder', 'filename', 'file_info', 'speech', 'uem', 'speakers', 'llmode']
......@@ -137,16 +107,16 @@ class Database:
# Check if this file is processed of filtered
# Default is True (in case filter_mode is None
process = True
if filter_mode == "title" and show not in f[0].lower():
if filter_mode == "title" and show not in f.lower():
process = False
elif filter_mode == "list" and f[1] not in filter_list:
elif filter_mode == "list" and f not in filter_list:
process = False
# According to the filtering, remove now files which are not in the time range
if process:
if ("start_date" in parameters) and f[0] < parameters["start_date"]:
if ("start_date" in parameters) and f < parameters["start_date"]:
continue
if ("end_date" in parameters) and f[0] >= parameters["end_date"]:
if ("end_date" in parameters) and f >= parameters["end_date"]:
continue
llmode = "none"
if "interactive_ratio" in parameters:
......@@ -157,11 +127,11 @@ class Database:
self.ents.append(
Entry(
root_folder,
f[1],
f,
FileInfo(f[0], llmode, f[0][0:13]),
[f[0]],
[f[0]],
[f[0]],
[f],
[f],
[f],
)
)
self.number_of_files = len(self.ents)
......@@ -198,11 +168,11 @@ class Database:
spk = []
ref_st = []
ref_en = []
for l in open(self.root_folder + "/mdtm/" + self.ents[self.index].filename + ".mdtm", "r"):
e = l.split()
ref_st.append(np.cast["float64"](round(float(e[2]), 3)))
ref_en.append(np.cast["float64"](round(float(e[2]) + float(e[3]), 3)))
spk.append(e[7])
#for l in open(self.root_folder + "/mdtm/" + self.ents[self.index].filename + ".mdtm", "r"):
# e = l.split()
# ref_st.append(np.cast["float64"](round(float(e[2]), 3)))
# ref_en.append(np.cast["float64"](round(float(e[2]) + float(e[3]), 3)))
# spk.append(e[7])
speakers = Reference(spk, ref_st, ref_en)
self.index += 1
return filename, file_info, uem, speakers, complete_filename
......
......@@ -279,6 +279,7 @@ def extract_vectors(current_diar, root_folder, model_cfg, show, model=None):
device=torch.device("cuda"),
file_extension="wav",
transform_pipeline={},
win_duration=1.,
sliding_window=False,
sample_rate=16000,
num_thread=5,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment