@@ -31,7 +31,7 @@ class AnnotationManager:
31
31
IndexColumn (name = 'range_onset' , description = 'covered range start time in milliseconds, measured since `time_seek`' , regex = r"([0-9]+)" , required = True ),
32
32
IndexColumn (name = 'range_offset' , description = 'covered range end time in milliseconds, measured since `time_seek`' , regex = r"([0-9]+)" , required = True ),
33
33
IndexColumn (name = 'raw_filename' , description = 'annotation input filename location, relative to `annotations/<set>/raw`' , filename = True , required = True ),
34
- IndexColumn (name = 'format' , description = 'input annotation format' , choices = [ 'TextGrid' , 'eaf' , 'vtc_rttm' , 'vcm_rttm' , 'alice' , 'its' , 'cha' , 'NA' ], required = False ),
34
+ IndexColumn (name = 'format' , description = 'input annotation format' , choices = converters . keys () + [ 'NA' ], required = False ),
35
35
IndexColumn (name = 'filter' , description = 'source file to filter in (for rttm and alice only)' , required = False ),
36
36
IndexColumn (name = 'annotation_filename' , description = 'output formatted annotation location, relative to `annotations/<set>/converted (automatic column, don\' t specify)' , filename = True , required = False , generated = True ),
37
37
IndexColumn (name = 'imported_at' , description = 'importation date (automatic column, don\' t specify)' , datetime = "%Y-%m-%d %H:%M:%S" , required = False , generated = True ),
@@ -195,27 +195,9 @@ def _import_annotation(self, import_function: Callable[[str], pd.DataFrame], ann
195
195
try :
196
196
if callable (import_function ):
197
197
df = import_function (path )
198
- elif annotation_format == 'TextGrid' :
199
- from .converters import TextGridConverter
200
- df = TextGridConverter .convert (path )
201
- elif annotation_format == 'eaf' :
202
- from .converters import EafConverter
203
- df = EafConverter .convert (path )
204
- elif annotation_format == 'vtc_rttm' :
205
- from .converters import VtcConverter
206
- df = VtcConverter .convert (path , source_file = filter )
207
- elif annotation_format == 'vcm_rttm' :
208
- from .converters import VcmConverter
209
- df = VcmConverter .convert (path , source_file = filter )
210
- elif annotation_format == 'its' :
211
- from .converters import ItsConverter
212
- df = ItsConverter .convert (path , recording_num = filter )
213
- elif annotation_format == 'alice' :
214
- from .converters import AliceConverter
215
- df = AliceConverter .convert (path , source_file = filter )
216
- elif annotation_format == 'cha' :
217
- from .converters import ChatConverter
218
- df = ChatConverter .convert (path )
198
+ elif annotation_format in converters :
199
+ converter = converters [annotation_format ]
200
+ df = converter .convert (path , filter )
219
201
else :
220
202
raise ValueError ("file format '{}' unknown for '{}'" .format (annotation_format , path ))
221
203
except :
0 commit comments