Skip to content

Commit

Permalink
'#1823: add a better error message if FFmpeg is not found on PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Apr 30, 2024
1 parent dd206f8 commit 4737172
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.commons.lang3.SystemUtils;
import org.apache.logging.log4j.LogManager;
Expand All @@ -15,6 +16,8 @@
import iped.configuration.IConfigurationDirectory;
import iped.engine.config.AudioTranscriptConfig;
import iped.engine.config.Configuration;
import iped.engine.config.ConfigurationManager;
import iped.exception.IPEDException;

public class WhisperTranscriptTask extends Wav2Vec2TranscriptTask {

Expand All @@ -24,6 +27,20 @@ public class WhisperTranscriptTask extends Wav2Vec2TranscriptTask {
private static final String LIBRARY_LOADED = "library_loaded";
private static final String MODEL_LOADED = "model_loaded";

private static final AtomicBoolean ffmpegTested = new AtomicBoolean();

@Override
public void init(ConfigurationManager configurationManager) throws Exception {
if (!ffmpegTested.getAndSet(true)) {
try {
Runtime.getRuntime().exec("ffmpeg");
} catch (IOException e) {
throw new IPEDException("Error checking FFmpeg presence, is it on PATH?");
}
}
super.init(configurationManager);
}

@Override
protected Server startServer0(int device) throws IOException {
if (numProcesses != null && device == numProcesses) {
Expand Down

0 comments on commit 4737172

Please sign in to comment.