Add Tritex to recording controls
This commit is contained in:
@@ -24,6 +24,7 @@ import edu.cmu.sphinx.api.*;
|
|||||||
import edu.cmu.sphinx.decoder.adaptation.*;
|
import edu.cmu.sphinx.decoder.adaptation.*;
|
||||||
import edu.cmu.sphinx.result.*;
|
import edu.cmu.sphinx.result.*;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
public class AudiobookRecorder extends JFrame {
|
public class AudiobookRecorder extends JFrame {
|
||||||
|
|
||||||
@@ -38,6 +39,11 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
String defaultEffectChain = "none";
|
String defaultEffectChain = "none";
|
||||||
|
|
||||||
|
public final static int IDLE = 0;
|
||||||
|
public final static int RECORDING = 1;
|
||||||
|
public final static int STOPPING = 2;
|
||||||
|
public int state = IDLE;
|
||||||
|
|
||||||
MainToolBar toolBar;
|
MainToolBar toolBar;
|
||||||
|
|
||||||
JMenuBar menuBar;
|
JMenuBar menuBar;
|
||||||
@@ -548,6 +554,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
int i = effectChain.getSelectedIndex();
|
int i = effectChain.getSelectedIndex();
|
||||||
KVPair<String, String> p = effectChain.getItemAt(i);
|
KVPair<String, String> p = effectChain.getItemAt(i);
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
|
CacheManager.removeFromCache(selectedSentence);
|
||||||
selectedSentence.setEffectChain(p.getKey());
|
selectedSentence.setEffectChain(p.getKey());
|
||||||
updateWaveform();
|
updateWaveform();
|
||||||
}
|
}
|
||||||
@@ -596,6 +603,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
alertNoRoomNoise();
|
alertNoRoomNoise();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!getLock()) return;
|
||||||
startRecording();
|
startRecording();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -606,6 +614,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
alertNoRoomNoise();
|
alertNoRoomNoise();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!getLock()) return;
|
||||||
startRecordingShort();
|
startRecordingShort();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -616,6 +625,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
alertNoRoomNoise();
|
alertNoRoomNoise();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!getLock()) return;
|
||||||
startRecordingNewParagraph();
|
startRecordingNewParagraph();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -626,6 +636,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
alertNoRoomNoise();
|
alertNoRoomNoise();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!getLock()) return;
|
||||||
startRecordingNewSection();
|
startRecordingNewSection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -636,13 +647,16 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
alertNoRoomNoise();
|
alertNoRoomNoise();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!getLock()) return;
|
||||||
startReRecording();
|
startReRecording();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
|
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (bookTree.isEditing()) return;
|
if (bookTree.isEditing()) return;
|
||||||
|
stopLock();
|
||||||
stopRecording();
|
stopRecording();
|
||||||
|
freeLock();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
|
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
|
||||||
@@ -2950,4 +2964,31 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
public String getDefaultEffectsChain() {
|
public String getDefaultEffectsChain() {
|
||||||
return defaultEffectChain;
|
return defaultEffectChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized boolean getLock() {
|
||||||
|
if (state == RECORDING) return false;
|
||||||
|
|
||||||
|
int counts = 0;
|
||||||
|
while (state == STOPPING) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
counts++;
|
||||||
|
if (counts > 100) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = RECORDING;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void freeLock() {
|
||||||
|
state = IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopLock() {
|
||||||
|
state = STOPPING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,4 +25,8 @@ public class CacheManager {
|
|||||||
public static void setCacheSize(int c) {
|
public static void setCacheSize(int c) {
|
||||||
cacheSize = c;
|
cacheSize = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeFromCache(Cacheable c) {
|
||||||
|
cache.remove(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CacheManager.removeFromCache(this);
|
||||||
|
|
||||||
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat());
|
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat());
|
||||||
|
|
||||||
@@ -180,10 +181,10 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CacheManager.removeFromCache(this);
|
||||||
|
|
||||||
audioData = null;
|
audioData = null;
|
||||||
processedAudio = null;
|
processedAudio = null;
|
||||||
storedFormat = null;
|
|
||||||
storedLength = -1;
|
|
||||||
|
|
||||||
if (!id.equals("room-noise")) {
|
if (!id.equals("room-noise")) {
|
||||||
String tm = Options.get("audio.recording.trim");
|
String tm = Options.get("audio.recording.trim");
|
||||||
@@ -559,6 +560,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
audioData = null;
|
audioData = null;
|
||||||
processedAudio = null;
|
processedAudio = null;
|
||||||
|
storedFormat = null;
|
||||||
|
storedLength = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean lockedInCache() {
|
public boolean lockedInCache() {
|
||||||
|
|||||||
Reference in New Issue
Block a user