No segments from result
Opened this issue · 1 comments
AmogusAzul commented
Hello! I'm new in java, however I've used the og python's whisper. I'm trying to create a simple transcription program, but whenever i try to, i'm not getting any Segments, here's my code, anything wrong with it? `
public static String transcribe(short[] decodedSamples) throws IOException{
float[] whisperSamples = reSample(decodedSamples);
WhisperJNI.loadLibrary(); // load platform binaries
WhisperJNI.setLibraryLogger(null); // capture/disable whisper.cpp log
var whisper = new WhisperJNI();
var ctx = whisper.init(Path.of(String.valueOf(QuiltLoader.getGameDir()), VoiceChatSubtitlesConfig.INSTANCE.model.value()));
var params = new WhisperFullParams();
params.detectLanguage = true;
int result = whisper.full(ctx, params, whisperSamples, whisperSamples.length);
if(result != 0) {
throw new RuntimeException("Transcription failed with code " + result);
}
int numSegments = whisper.fullNSegments(ctx);
String text = (numSegments > 0) ? whisper.fullGetSegmentText(ctx,0) : "No segments to display"; // I'm always getting the "No segments to display" response
ctx.close(); // free native memory, should be called when we don't need the context anymore.
return text;
}
`
lukeewin commented
Hello! I'm new in java, however I've used the og python's whisper. I'm trying to create a simple transcription program, but whenever i try to, i'm not getting any Segments, here's my code, anything wrong with it? ` public static String transcribe(short[] decodedSamples) throws IOException{
float[] whisperSamples = reSample(decodedSamples); WhisperJNI.loadLibrary(); // load platform binaries WhisperJNI.setLibraryLogger(null); // capture/disable whisper.cpp log var whisper = new WhisperJNI(); var ctx = whisper.init(Path.of(String.valueOf(QuiltLoader.getGameDir()), VoiceChatSubtitlesConfig.INSTANCE.model.value())); var params = new WhisperFullParams(); params.detectLanguage = true; int result = whisper.full(ctx, params, whisperSamples, whisperSamples.length); if(result != 0) { throw new RuntimeException("Transcription failed with code " + result); } int numSegments = whisper.fullNSegments(ctx); String text = (numSegments > 0) ? whisper.fullGetSegmentText(ctx,0) : "No segments to display"; // I'm always getting the "No segments to display" response ctx.close(); // free native memory, should be called when we don't need the context anymore. return text; }
You should set language="".