Skip to content

Commit

Permalink
save transcript to WAV file. close #2594
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Oct 1, 2024
1 parent 645a75f commit 9c1eabf
Show file tree
Hide file tree
Showing 12 changed files with 1,065 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@
<Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons16/material/baseline_folder_white_36dp.png"/>
<Image iconType="3" name="/icons16/material/inventory_24dp_FFFFFF.png"/>
</Property>
<Property name="text" type="java.lang.String" value="0"/>
<Property name="toolTipText" type="java.lang.String" value="0 Akten im Archiv"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ public void mousePressed(java.awt.event.MouseEvent evt) {

lblArchiveFileArchivedCount.setFont(lblArchiveFileArchivedCount.getFont().deriveFont(lblArchiveFileArchivedCount.getFont().getStyle() | java.awt.Font.BOLD));
lblArchiveFileArchivedCount.setForeground(java.awt.Color.white);
lblArchiveFileArchivedCount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/baseline_folder_white_36dp.png"))); // NOI18N
lblArchiveFileArchivedCount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/inventory_24dp_FFFFFF.png"))); // NOI18N
lblArchiveFileArchivedCount.setText("0");
lblArchiveFileArchivedCount.setToolTipText("0 Akten im Archiv");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public static JComponent getDocumentViewer(ArchiveFileBean caseDto, String id, S
}
return ptp;
} else if (lFileName.endsWith(".wav") || lFileName.endsWith(".ogg") || lFileName.endsWith(".mp3")) {
SoundplayerPanel spp=new SoundplayerPanel();
SoundplayerPanel spp=new SoundplayerPanel(id, readOnly);
spp.setSize(new Dimension(width, height));
spp.setMaximumSize(new Dimension(width, height));
spp.setPreferredSize(new Dimension(width, height));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,12 @@
import com.jdimension.jlawyer.client.assistant.AssistantAccess;
import com.jdimension.jlawyer.client.assistant.AssistantFlowAdapter;
import com.jdimension.jlawyer.client.assistant.AssistantInputAdapter;
import com.jdimension.jlawyer.client.editors.EditorsRegistry;
import com.jdimension.jlawyer.client.settings.ClientSettings;
import com.jdimension.jlawyer.client.utils.ThreadUtils;
import com.jdimension.jlawyer.client.utils.WavAudioUtils;
import com.jdimension.jlawyer.persistence.AssistantConfig;
import com.jdimension.jlawyer.services.JLawyerServiceLocator;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
Expand All @@ -683,6 +688,7 @@
import javax.swing.Timer;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.sound.sampled.LineEvent;
Expand All @@ -699,14 +705,21 @@ public class SoundplayerPanel extends javax.swing.JPanel implements PreviewPanel

private String documentId = null;
private byte[] content=null;
private String initialComment = null;

private Clip clip;
private Timer timer;

private boolean readOnly = true;

/**
* Creates new form PlaintextPanel
* Creates new form SoundplayerPanel
* @param docId
* @param readOnly
*/
public SoundplayerPanel() {
public SoundplayerPanel(String docId, boolean readOnly) {
this.documentId = docId;
this.readOnly = readOnly;
initComponents();
}

Expand Down Expand Up @@ -859,13 +872,41 @@ public void showStatus(String text) {
public void removeNotify() {
super.removeNotify();
stop(); // Stop the sound when the panel is removed or no longer displayed

if (this.documentId != null && !this.readOnly) {

String currentComment = this.taTranscription.getText();
if (currentComment!=null && !currentComment.equals(this.initialComment)) {
try {

byte[] newWav=WavAudioUtils.addOrUpdateCommentInWav(this.content, this.taTranscription.getText());

ClientSettings settings = ClientSettings.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
locator.lookupArchiveFileServiceRemote().setDocumentContent(this.documentId, newWav);
this.content=newWav;
} catch (Throwable t) {
log.error("Error saving document with id " + this.documentId, t);
ThreadUtils.showErrorDialog(EditorsRegistry.getInstance().getMainWindow(), "Fehler beim Speichern: " + t.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR);

}
}
}
}

@Override
public void showContent(String documentId, byte[] content) {
this.documentId = documentId;
this.content=content;


this.initialComment=WavAudioUtils.getInfoChunk(this.content);
if(this.initialComment!=null) {
this.initialComment=this.initialComment.replace("ICMT: ", "");
this.taTranscription.setText(this.initialComment);
} else {
this.taTranscription.setText("");
}

try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(content));
clip = AudioSystem.getClip();
Expand Down
Loading

0 comments on commit 9c1eabf

Please sign in to comment.