diff --git a/src/org/exmaralda/partitureditor/jexmaralda/convert/SubtitleConverter.java b/src/org/exmaralda/partitureditor/jexmaralda/convert/SubtitleConverter.java index 5243007c..5b40d830 100644 --- a/src/org/exmaralda/partitureditor/jexmaralda/convert/SubtitleConverter.java +++ b/src/org/exmaralda/partitureditor/jexmaralda/convert/SubtitleConverter.java @@ -54,7 +54,7 @@ * * @author Schmidt */ -public class SubtitleConverter { +public class SubtitleConverter { private static double parseTime(String timeString) { int hours = Integer.parseInt(timeString.substring(0, 2)); @@ -342,7 +342,7 @@ public static BasicTranscription readVTT(File file) throws FileNotFoundException public static BasicTranscription readVTT(File file, String encoding) throws FileNotFoundException, IOException, JexmaraldaException { BasicTranscription result = new BasicTranscription(); - Tier defaultTier = new Tier("TIE0", null, "v", "t", "VTT"); + Tier defaultTier = new Tier("TIE0", null, "v", "t", "[vtt]"); result.getBody().addTier(defaultTier); try { VttParser parser = new VttParser(encoding); @@ -388,6 +388,7 @@ public static BasicTranscription readVTT(File file, String encoding) throws File for (SubtitleLine l : lines4Cue){ VttLine line = (VttLine)l; String voice = line.getVoice(); + System.out.println("VOICE: " + voice); List texts4Line = line.getTexts(); for (SubtitleText text : texts4Line){ String textString = text.toString(); @@ -395,23 +396,25 @@ public static BasicTranscription readVTT(File file, String encoding) throws File } //System.out.println(startTimeInSeconds + "\t" + endTimeInSeconds + "\t" + voice + "\t" + allTheText); - } - org.exmaralda.partitureditor.jexmaralda.Event event = - new org.exmaralda.partitureditor.jexmaralda.Event(startID, endID, - allTheText.trim().replaceAll(" +", " ")); - //if (voice==null){ - defaultTier.addEvent(event); - /*} else { - String tierID = "TIE_" + voice; - if (!(result.getBody().containsTierWithID(tierID))){ - String speakerID = "SPK_" + voice; - Speaker newSpeaker = new Speaker(); - newSpeaker.setID(speakerID); - result.getHead().getSpeakertable().addSpeaker(newSpeaker); - Tier newTier = new Tier(tierID, speakerID, "v", "t", "VTT"); + org.exmaralda.partitureditor.jexmaralda.Event event = + new org.exmaralda.partitureditor.jexmaralda.Event(startID, endID, + allTheText.trim().replaceAll(" +", " ")); + if (voice==null){ + defaultTier.addEvent(event); + } else { + String tierID = "TIE_" + voice; + if (!(result.getBody().containsTierWithID(tierID))){ + String speakerID = "SPK_" + voice; + Speaker newSpeaker = new Speaker(); + newSpeaker.setID(speakerID); + newSpeaker.setAbbreviation(voice); + result.getHead().getSpeakertable().addSpeaker(newSpeaker); + Tier newTier = new Tier(tierID, speakerID, "v", "t", voice + " [vtt]"); + result.getBody().addTier(newTier); + } + result.getBody().getTierWithID(tierID).addEvent(event); } - result.getBody().getTierWithID(tierID).addEvent(event); - }*/ + } } } catch (SubtitleParsingException ex) { Logger.getLogger(SubtitleConverter.class.getName()).log(Level.SEVERE, null, ex); diff --git a/src/org/exmaralda/partitureditor/jexmaralda/convert/test/TestSubtitleConverter.java b/src/org/exmaralda/partitureditor/jexmaralda/convert/test/TestSubtitleConverter.java index ab7b795e..7b7ef987 100644 --- a/src/org/exmaralda/partitureditor/jexmaralda/convert/test/TestSubtitleConverter.java +++ b/src/org/exmaralda/partitureditor/jexmaralda/convert/test/TestSubtitleConverter.java @@ -32,19 +32,21 @@ public static void main(String[] args) throws IOException, JDOMException, SAXExc private void doit() throws IOException, JDOMException, SAXException, ParserConfigurationException, TransformerException, TransformerConfigurationException, JexmaraldaException { File[] vttFiles = new File("C:\\Users\\bernd\\Dropbox\\work\\EXMARaLDA_Support\\2023_01_13_ISSUE_119").listFiles(new FilenameFilter(){ + //File[] vttFiles = new File("C:\\Users\\bernd\\Dropbox\\work\\EXMARaLDA_Support\\2024_05_11_VTT_NO_SCRIBE").listFiles(new FilenameFilter(){ @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".vtt"); } }); for (File vttFile : vttFiles){ + System.out.println(vttFile.getName()); BasicTranscription bt = SubtitleConverter.readVTT(vttFile); String outFilename = vttFile.getName().replace(".vtt", ".exb"); bt.writeXMLToFile(new File(vttFile.getParent(), outFilename).getAbsolutePath(), "none"); //System.out.println(bt.toXML()); } - File[] srtFiles = new File("C:\\Users\\bernd\\Dropbox\\work\\EXMARaLDA_Support\\2023_01_13_ISSUE_119").listFiles(new FilenameFilter(){ + /*File[] srtFiles = new File("C:\\Users\\bernd\\Dropbox\\work\\EXMARaLDA_Support\\2023_01_13_ISSUE_119").listFiles(new FilenameFilter(){ @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".srt"); @@ -55,7 +57,7 @@ public boolean accept(File dir, String name) { String outFilename = srtFile.getName().replace(".srt", "_SRT.exb"); bt.writeXMLToFile(new File(srtFile.getParent(), outFilename).getAbsolutePath(), "none"); //System.out.println(bt.toXML()); - } + }*/ } diff --git a/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.form b/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.form index e7f0cfd7..e33d6faa 100644 --- a/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.form +++ b/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.form @@ -1379,7 +1379,7 @@ - + diff --git a/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.java b/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.java index e259f0c8..b5f6da1a 100644 --- a/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.java +++ b/src/org/exmaralda/partitureditor/jexmaraldaswing/EditPreferencesDialog.java @@ -935,7 +935,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { playerSelectionPanel.add(jdsPlayerRadioButton); mediaPlayersButtonGroup.add(javaFXPlayerRadioButton); - javaFXPlayerRadioButton.setText("Java FX Player: A player provided by the Language Archive at the MPI Nijmegen, also used inside ELAN. Uses Java's FX framework to playback audio and video files. New since 2020. Try this player for MPEG-4 videos under Windows. "); + javaFXPlayerRadioButton.setText("Java FX Player: A player provided by the Language Archive at the MPI Nijmegen, also used inside ELAN. Uses Java's FX framework to playback audio and video files. Try this player for MPEG-4 videos under Windows. "); playerSelectionPanel.add(javaFXPlayerRadioButton); mediaPlayersButtonGroup.add(mmfPlayerRadioButton);