Skip to content

Commit

Permalink
'#1823: abort with error message if whisperx found and ffmpeg not found
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed May 27, 2024
1 parent 982622c commit 548215b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions iped-app/resources/scripts/tasks/WhisperProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def main():
whisperx_found = False

print(library_loaded, file=stdout, flush=True)
print('whisperx' if whisperx_found else 'faster_whisper', file=stdout, flush=True)

import GPUtil
cudaCount = len(GPUtil.getGPUs())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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 @@ -27,14 +28,16 @@ public class WhisperTranscriptTask extends Wav2Vec2TranscriptTask {
private static final String MODEL_LOADED = "model_loaded";

private static final AtomicBoolean ffmpegTested = new AtomicBoolean();
private static volatile boolean ffmpegFound;

@Override
public void init(ConfigurationManager configurationManager) throws Exception {
if (!ffmpegTested.getAndSet(true)) {
try {
Runtime.getRuntime().exec("ffmpeg");
ffmpegFound = true;
} catch (IOException e) {
logger.warn("FFmpeg not found on PATH, transcription won't work if you switched to WhisperX library.");
ffmpegFound = false;
}
}
super.init(configurationManager);
Expand Down Expand Up @@ -79,7 +82,14 @@ protected Server startServer0(int device) throws IOException {
String line = reader.readLine();

if (!LIBRARY_LOADED.equals(line)) {
throw new StartupException("Neither 'faster_whisper' nor 'whisperx' python libraries were loaded correctly. Have you installed one of them?");
throw new StartupException("Neither 'faster_whisper' nor 'whisperx' python libraries were loaded correctly. You need to install one of them!");
}

line = reader.readLine();
logger.info("Transcription library loaded: {}", line);

if ("whisperx".equals(line) && !ffmpegFound) {
throw new IPEDException("FFmpeg not found on PATH, it is needed by WhisperX python library.");
}

int cudaCount = Integer.valueOf(reader.readLine());
Expand Down

0 comments on commit 548215b

Please sign in to comment.