I have two label tracks as tab separated text files for a given .wav file. I load the wav file using commands over named pipe and additional I can load one of the label tracks by sending addLabel and setLabel: from inside a loop. That works. But if I want to load the second one additionally The first label track is messed up and the second label track has empty text labels and start and end is always the full span.
I guess, there is a problem with label index, but the label index is ascending from 0 and looks good.
This is the relevant code
Code: Select all
def import_label_track(file_name, title): global lastLabelIndex print("Last index", lastLabelIndex) doCommand('NewLabelTrack') doCommand("SetTrack: Name=" "\"" + title + "\"") with open(file_name, 'r') as label_file: lines = label_file.readlines() for index, each_line in enumerate(lines): fields = each_line.strip().split() doCommand("AddLabel") # time.sleep(1.5) command_string = "SetLabel: Label=" + str(lastLabelIndex) + " Text=\"" + fields + "\"" + " Start=" + fields + " End=" + fields # command_string = "SetLabel: Text=\"" + fields + "\"" + " Start=" + fields + " End=" + fields print(command_string) doCommand(command_string) lastLabelIndex = index