我使用IBM Watson Speech来发送文本API以将音频文件转换为文本。每个功能都适合我。但我无法使用关键字定位功能。输出没有提供有关被发现关键字的任何信息。
这是我的代码:
SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("*********", "********");
//SpeechModel model =service.getModel("en-US_NarrowbandModel");
service.setEndPoint("https://stream.watsonplatform.net/speech-to-text/api");
String[] keys= {"abuse","bullying","parents","physical","assaulting"};
RecognizeOptions options = new RecognizeOptions().contentType("audio/wav").model("en-US_NarrowbandModel").continuous(true).inactivityTimeout(500).keywords(keys).keywordsThreshold(0.7);
File audio = new File("C:\\Users\\AudioFiles\\me.wav");
SpeechResults transcript = service.recognize(audio, options);
//Speech t1 = service.recognize(audio, options);
System.out.println(transcript);
是否有任何特殊功能可以将发现的关键字作为输出以及成绩单?
答案 0 :(得分:1)
这已在Java SDK v3.2.0
中修复。请务必下载最新版本(4.2.1
)jar:java-sdk-4.2.1-jar-with-dependencies.jar或更新您的Gradle / Maven以获取最新版本。
以下代码基于您问题中的代码。
SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("USERNAME", "PASSWORD");
File audio = new File("C:\\Users\\AudioFiles\\me.wav");
RecognizeOptions options = new RecognizeOptions().Builder()
.contentType("audio/wav)
.inactivityTimeout(500)
.keywords({"abuse", "bullying", "parents", "physical", "assaulting"})
.keywordsThreshold(0.5)
.build();
SpeechResults transcript = service.recognize(audio, options).execute();
System.out.println(transcript);