<dependency>
<groupId>com.asr.vietspeech</groupId>
<artifactId>asr-vietspeech</artifactId>
<version>0.0.1</version>
</dependency>
'com.vietspeech:asr-vietspeech:0.0.1'
Download the jar with dependencies here.
Use the Speech to Text service to recognize the text from a .wav file.
public class MavenSample {
public static void main(String[] args) {
File file = new File("src/main/resources/process.wav");
if (file.canRead()) {
String token = "replace token here";
int timeout = 10000;
int sampleRate = 16000;
int maxSize = 51200;
Configuration config = new Configuration(token, AudioEncoding.AMR, timeout, sampleRate, maxSize);
SpeechToText asrSpeech = new SpeechToText(config);
try {
String result = asrSpeech.call(file);
if (result == null) System.out.println("Invalid file.");
else System.out.println("Transcription: " + result);
} catch (IllegalArgumentException arEx) {
System.out.println("Token invalid.");
} catch (IOException ex) {
System.out.println("Server connection aborted.");
}
} else {
System.out.println("File not found.");
}
}
}