Skip to content

Commit

Permalink
#463 and #119 : do notte ignore voice in VTT
Browse files Browse the repository at this point in the history
  • Loading branch information
berndmoos committed May 11, 2024
1 parent 4499bd3 commit 00a2843
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -388,30 +388,33 @@ 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<SubtitleText> texts4Line = line.getTexts();
for (SubtitleText text : texts4Line){
String textString = text.toString();
allTheText+=" " + textString;
}

//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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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());
}
}*/

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="mediaPlayersButtonGroup"/>
</Property>
<Property name="text" type="java.lang.String" value="&lt;html&gt;&lt;b&gt;Java FX Player:&lt;/b&gt; A player provided by the Language Archive at the MPI Nijmegen, also used inside ELAN. Uses Java&apos;s FX framework to playback audio and video files. &lt;b&gt;&lt;i&gt;New since 2020&lt;/i&gt;&lt;/b&gt;. Try this player for&lt;b&gt; MPEG-4 videos under Windows&lt;/b&gt;. &lt;/html&gt;"/>
<Property name="text" type="java.lang.String" value="&lt;html&gt;&lt;b&gt;Java FX Player:&lt;/b&gt; A player provided by the Language Archive at the MPI Nijmegen, also used inside ELAN. Uses Java&apos;s FX framework to playback audio and video files. Try this player for&lt;b&gt; MPEG-4 videos under Windows&lt;/b&gt;. &lt;/html&gt;"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="mmfPlayerRadioButton">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
playerSelectionPanel.add(jdsPlayerRadioButton);

mediaPlayersButtonGroup.add(javaFXPlayerRadioButton);
javaFXPlayerRadioButton.setText("<html><b>Java FX Player:</b> 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. <b><i>New since 2020</i></b>. Try this player for<b> MPEG-4 videos under Windows</b>. </html>");
javaFXPlayerRadioButton.setText("<html><b>Java FX Player:</b> 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<b> MPEG-4 videos under Windows</b>. </html>");
playerSelectionPanel.add(javaFXPlayerRadioButton);

mediaPlayersButtonGroup.add(mmfPlayerRadioButton);
Expand Down

0 comments on commit 00a2843

Please sign in to comment.