大規模なオーディオ・ファイルを転記するには、Watson Developer Cloud Java SDKを使用しようとしています。セッションレスメソッドを試してみましたが、正常に動作しますが、WebSocketsメソッドを試してみると、信頼できなくなります。WebSocketを使用したIBM Watson Speech to Text
ほとんどの場合、メソッドはデリゲートに渡されたSpeechResult
が返されます。まれにしか動作しませんが、最初の数秒間しか転写しません。私が有効に連続してい
static SpeechResults transcript = null;
private static String SpeechToText(String audioFile) throws FileNotFoundException {
SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("<!!USERNAME!!>", "<!!PASSWORD!!>");
service.setEndPoint("https://stream.watsonplatform.net/speech-to-text/api");
RecognizeOptions options = new RecognizeOptions();
options.contentType("audio/ogg;codecs=opus");
options.continuous(Boolean.TRUE);
options.inactivityTimeout(-1);
options.model(Models.GetModelName(Models.SpeechModelEnums.ArabicBroadband));
options.timestamps(Boolean.TRUE);
options.wordAlternativesThreshold(0.5);
options.wordConfidence(Boolean.TRUE);
options.interimResults(Boolean.FALSE);
File audio = new File(audioFile);
//This is my sessionless call
//SpeechResults transcript = service.recognize(audio, options);
service.recognizeUsingWebSockets(new FileInputStream(audio), options, new BaseRecognizeDelegate()
{
@Override
public void onMessage(SpeechResults speechResults){
System.out.println(speechResults);
}
}
);
return "";//transcript.toString();
}
:
これは次のように私のコードが見えるものです。私はinterimResultsを手抜きしようとしましたが、うまくいきませんでした。
私は間違っていますか?
使用しているSDKのバージョンは何ですか?私は彼らが最近websocketsライブラリを置き換えたと思います。 (私自身も同じ種類の問題を抱えていた) – Leo