chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
id 'application'
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = 'org.vosk.demo.DecoderDemo'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'com.alphacephei', name: 'vosk', version: '0.3.75'
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.vosk.demo;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
|
||||
import org.vosk.LogLevel;
|
||||
import org.vosk.Recognizer;
|
||||
import org.vosk.LibVosk;
|
||||
import org.vosk.Model;
|
||||
|
||||
public class DecoderDemo {
|
||||
|
||||
public static void main(String[] argv) throws IOException, UnsupportedAudioFileException {
|
||||
LibVosk.setLogLevel(LogLevel.DEBUG);
|
||||
|
||||
try (Model model = new Model("model");
|
||||
InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("../../python/example/test.wav")));
|
||||
Recognizer recognizer = new Recognizer(model, 16000)) {
|
||||
|
||||
int nbytes;
|
||||
byte[] b = new byte[4096];
|
||||
while ((nbytes = ais.read(b)) >= 0) {
|
||||
if (recognizer.acceptWaveForm(b, nbytes)) {
|
||||
System.out.println(recognizer.getResult());
|
||||
} else {
|
||||
System.out.println(recognizer.getPartialResult());
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(recognizer.getFinalResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user