如何使用 IBM Watson Speech to text API 的关键字识别功能?
How to use keyword spotting feature for IBM Waston Speech to text API?
我正在使用 IBM Watson Speech to text 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);
是否有任何特殊功能可以将发现的关键字与成绩单一起输出?
这已在 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);
我正在使用 IBM Watson Speech to text 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);
是否有任何特殊功能可以将发现的关键字与成绩单一起输出?
这已在 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);