Add Tritex to recording controls

This commit is contained in:
2019-08-11 11:15:55 +01:00
parent ea5520a729
commit 54739b0a75
3 changed files with 50 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import edu.cmu.sphinx.api.*;
import edu.cmu.sphinx.decoder.adaptation.*;
import edu.cmu.sphinx.result.*;
import org.w3c.dom.Node;
import java.util.concurrent.*;
public class AudiobookRecorder extends JFrame {
@@ -38,6 +39,11 @@ public class AudiobookRecorder extends JFrame {
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;
JMenuBar menuBar;
@@ -548,6 +554,7 @@ public class AudiobookRecorder extends JFrame {
int i = effectChain.getSelectedIndex();
KVPair<String, String> p = effectChain.getItemAt(i);
if (p == null) return;
CacheManager.removeFromCache(selectedSentence);
selectedSentence.setEffectChain(p.getKey());
updateWaveform();
}
@@ -596,6 +603,7 @@ public class AudiobookRecorder extends JFrame {
alertNoRoomNoise();
return;
}
if (!getLock()) return;
startRecording();
}
});
@@ -606,6 +614,7 @@ public class AudiobookRecorder extends JFrame {
alertNoRoomNoise();
return;
}
if (!getLock()) return;
startRecordingShort();
}
});
@@ -616,6 +625,7 @@ public class AudiobookRecorder extends JFrame {
alertNoRoomNoise();
return;
}
if (!getLock()) return;
startRecordingNewParagraph();
}
});
@@ -626,6 +636,7 @@ public class AudiobookRecorder extends JFrame {
alertNoRoomNoise();
return;
}
if (!getLock()) return;
startRecordingNewSection();
}
});
@@ -636,13 +647,16 @@ public class AudiobookRecorder extends JFrame {
alertNoRoomNoise();
return;
}
if (!getLock()) return;
startReRecording();
}
});
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (bookTree.isEditing()) return;
stopLock();
stopRecording();
freeLock();
}
});
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
@@ -2950,4 +2964,31 @@ public class AudiobookRecorder extends JFrame {
public String getDefaultEffectsChain() {
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;
}
}

View File

@@ -25,4 +25,8 @@ public class CacheManager {
public static void setCacheSize(int c) {
cacheSize = c;
}
public static void removeFromCache(Cacheable c) {
cache.remove(c);
}
}

View File

@@ -160,6 +160,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
return false;
}
CacheManager.removeFromCache(this);
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat());
@@ -180,10 +181,10 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
}
}
CacheManager.removeFromCache(this);
audioData = null;
processedAudio = null;
storedFormat = null;
storedLength = -1;
if (!id.equals("room-noise")) {
String tm = Options.get("audio.recording.trim");
@@ -559,6 +560,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
public void clearCache() {
audioData = null;
processedAudio = null;
storedFormat = null;
storedLength = -1;
}
public boolean lockedInCache() {