Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[speech-to-text] keywords, keywords_threshold, word_alternatives_threshold are being dropped #189

Closed
monte-hayward opened this issue Dec 21, 2015 · 7 comments
Assignees

Comments

@monte-hayward
Copy link

The v1 service wrapper would pick params allowed to be sent to the service. This pr updates the "allowed" list with the new parameters announced in Updates for December 2015.

@germanattanasio germanattanasio changed the title keywords, keywords_threshold, word_alternatives_threshold are being dropped [speech-to-text] keywords, keywords_threshold, word_alternatives_threshold are being dropped Dec 21, 2015
@germanattanasio germanattanasio self-assigned this Dec 21, 2015
monte-hayward added a commit to monte-hayward/node-sdk that referenced this issue Dec 30, 2015
monte-hayward added a commit to monte-hayward/node-sdk that referenced this issue Dec 30, 2015
germanattanasio added a commit that referenced this issue Feb 11, 2016
@ykcadcg
Copy link

ykcadcg commented May 29, 2016

what's a good keywords_threshold? 0 or 1 or 0.8 or else? It can't be left unspecified

C:\Users\kyang\Documents\GitHub\curl-7.49.0\AMD64>curl -X POST -u 27f6c1ee-3d03-4ef7-a4ea-c06877ad9d6b:Q03HBDFk07DP --header "Content-Type: audio/flac" --header "Transfer-Encoding: chunked" --data-binary @C:\Users\kyang\Documents\GitHub\0001.flac "
tps://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true&keywords="actually""
{
   "code_description": "Bad Request",
   "code": 400,
   "error": "keywords_threshold must be set if keywords list is not empty."
}

@nfriedly
Copy link
Contributor

Yea, the range is 0-1. I think we set it to 0.2 for the demo, but for real world usage, I would suggest a bit higher, maybe 0.5 or 0.8. It's basically a trade-off though - is it more important that you catch the keyword even if the speaker mumbled it (0.2) or that you avoid false-positives when they actually said something else (0.8). To some extent, you'll want to test different values and see what fits your app.

@ykcadcg
Copy link

ykcadcg commented May 30, 2016

Thank you!
I have another quick question: I'm new to Java/JSON. My code adapting speech-android-wrapper. My this.sConfig.keywords is a public String[]. I know this toString() messed up with passing this.sConfig.keywords, but how to pass it correctly? I got error: "error": "Required type for parameter "keywords" is list. Got type unicode instead." Thanks!
`
private void sendSpeechHeader() {

     JSONObject obj = new JSONObject();
     try {
         obj.put("action", "start");
         obj.put("content-type", this.sConfig.audioFormat);
         obj.put("interim_results", true);
         obj.put("continuous", true);
         obj.put("inactivity_timeout", this.sConfig.inactivityTimeout);
         obj.put("word_confidence", true); 
         obj.put("keywords_threshold", this.sConfig.keywordsThreshold); 
         obj.put("keywords", Arrays.toString(this.sConfig.keywords)); //this.sConfig.keywords is a  public String[]
     } catch (JSONException e) {
         e.printStackTrace();
     }
     String startHeader = obj.toString(); //I know this toString() messed up with passing this.sConfig.keywords, but how to pass it correctly?

     this.upload(startHeader);
     this.encoder.onStart();
     Log.d(TAG, "Sending init message: " + startHeader);
 }`

Got error: 05-29 16:25:53.078 28782-29008/com.ibm.watson.developer_cloud.android.examples D/MainActivity: onMessage, message: { "error": "Required type for parameter "keywords" is list. Got type unicode instead."

@ykcadcg
Copy link

ykcadcg commented May 30, 2016

btw the debugger for startHeader is this:
{"action":"start","content-type":"audio/ogg;codecs=opus","interim_results":true,"continuous":true,"inactivity_timeout":600,"word_confidence":true,"keywords_threshold":0.75,"keywords":"[banana, apple]"}

@ykcadcg
Copy link

ykcadcg commented May 30, 2016

Thanks. I also noticed during debugging: "final" is always "true" and never "false". Is it expected?

@nfriedly
Copy link
Contributor

The final will always be true unless you set interim_results: true in the opening JSON message. Then you'll get a series of non-final "preview" results before each final one.

As for the Java thing, I'm not as familiar with that, but my guess is that it wants a JSONArray: https://developer.android.com/reference/org/json/JSONArray.html

@ykcadcg
Copy link

ykcadcg commented May 31, 2016

Got you, you are right, it needs JSONArray. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants