簡體   English   中英

如何為 IBM Waston 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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM