Commit 566b6235 authored by Sulfyderz's avatar Sulfyderz
Browse files

Adding a new parameter to read methods from diar.py.

parent df48d986
......@@ -623,7 +623,7 @@ class Diar():
:param coveringOverlap: a boolean value
"""
#index = self.make_index(['show'])
#index = self.make_index(['show'])
#lst = list()
#for show in index:
# diar = index[show]
......@@ -735,8 +735,9 @@ class Diar():
if segment['start'] < first:
first = segment['start']
return first
@classmethod
def read_seg(cls, filename, normalize_cluster=False):
def read_seg(cls, filename, normalize_cluster=False, encoding="utf8"):
"""
Read a segmentation file
:param filename: the str input filename
......@@ -744,7 +745,7 @@ class Diar():
case and accents
:return: a diarization object
"""
fic = open(filename, 'r', encoding="utf8")
fic = open(filename, 'r', encoding=encoding)
diarization = Diar()
if not diarization._attributes.exist('gender'):
diarization.add_attribut(new_attribut='gender', default='U')
......@@ -775,7 +776,7 @@ class Diar():
return diarization
@classmethod
def read_ctm(cls, filename, normalize_cluster=False):
def read_ctm(cls, filename, normalize_cluster=False, encoding="utf8"):
"""
Read a segmentation file
:param filename: the str input filename
......@@ -783,7 +784,7 @@ class Diar():
and accents
:return: a diarization object
"""
fic = open(filename, 'r', encoding="utf8")
fic = open(filename, 'r', encoding=encoding)
diarization = Diar()
try:
for line in fic:
......@@ -806,7 +807,7 @@ class Diar():
return diarization
@classmethod
def read_mdtm(cls, filename, normalize_cluster=False):
def read_mdtm(cls, filename, normalize_cluster=False, encoding="utf8"):
"""
Read a MDTM file
:param filename: the str input filename
......@@ -815,7 +816,7 @@ class Diar():
:return: a diarization object
"""
fic = open(filename, 'r', encoding="utf8")
fic = open(filename, 'r', encoding=encoding)
diarization = Diar()
if not diarization._attributes.exist('gender'):
diarization.add_attribut(new_attribut='gender', default='U')
......@@ -842,13 +843,13 @@ class Diar():
return diarization
@classmethod
def read_uem(cls, filename):
def read_uem(cls, filename, encoding="utf8"):
"""
Read a UEM file
:param filename: the str input filename
:return: a diarization object
"""
fic = open(filename, 'r', encoding="utf8")
fic = open(filename, 'r', encoding=encoding)
diarization = Diar()
if not diarization._attributes.exist('gender'):
diarization.add_attribut(new_attribut='gender', default='U')
......@@ -873,14 +874,14 @@ class Diar():
return diarization
@classmethod
def read_rttm(cls, filename, normalize_cluster=False):
def read_rttm(cls, filename, normalize_cluster=False, encoding="utf8"):
"""
Read rttm file
:param filename: str input filename
:param normalize_cluster: normalize the cluster by removing upper case and accents
:return: a diarization object
"""
fic = open(filename, 'r', encoding="utf8")
fic = open(filename, 'r', encoding=encoding)
diarization = Diar()
if not diarization._attributes.exist('gender'):
diarization.add_attribut(new_attribut='gender', default='U')
......
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