- config_string = "task_language=pol|is_text_type=unparsed|is_text_unparsed_id_regex=sec\d+$|is_text_unparsed_id_sort=numeric|os_task_file_format=tab"
- task = Task(config_string=config_string)
-
- with tempfile.TemporaryDirectory() as temp:
- syncfile = temp + "/sync"
- task.audio_file_path_absolute = mp3[i]
- task.text_file_path_absolute = html.get_filename()
- task.sync_map_file_path_absolute = syncfile
-
- ExecuteTask(task).execute()
- task.output_sync_map_file()
-
- sync = []
- with open(syncfile) as f:
- for line in f:
- start, end, sec = line.strip().split('\t')
- start = float(start)
- end = float(end)
- sync.append([start, end, sec])
-
- hms = format_hms(durations[i])
- elapsed_hms = format_hms(sum(durations[:i]))
-
- context = {
- "VERSION": "1.10",
-
- "HHMMSSmmm": hms,
- "HHMMSS": hms.split('.')[0],
- "Sd": "%.1f" % durations[i],
- "ELAPSED": elapsed_hms,
-
- "TITLE": document.meta.title,
- "PUBLISHER": document.meta.publisher[0],
- "YEAR": document.meta.created_at[:4],
- "MONTH": document.meta.created_at[5:7],
- "AUTHOR": document.meta.author.readable(),
-
- "NARRATOR": narrator,
- }
-
- with open(get_resource('res/daisy/content.smil')) as f:
- tree = etree.parse(f)