Comments (4)
Hi @ykcadcg, data type of keywords should be a JSONArray type and it could be used directly using "obj.put(key, value)", here is the sample:
obj.put("keywords", this.sConfig.keywords);
If the data type of this.sConfig.keywords can't be changed, please consider this:
JSONArray jsonArray = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
jsonArray = new JSONArray(this.sConfig.keywords);
}
obj.put("keywords", jsonArray);
Or
JSONArray jsonArray = null;
for(int i = 0; i < this.sConfig.keywords.length; i++){
jsonArray.put(this.sConfig.keywords[i]);
}
obj.put("keywords", jsonArray);
Thanks.
from speech-android-sdk.
I thought I had a fix for it, but I was wrong
from speech-android-sdk.
Hi, could you help me with a quick question that has been blocking me: my code is 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)); //_Problematic_*: 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."
from speech-android-sdk.
Thank you so much mihui! That's exactly what I need.
from speech-android-sdk.
Related Issues (20)
- The SDK failed to run on Emulator HOT 1
- Websocket ssl error HOT 3
- No watsonsdk.aar HOT 2
- UnsatisfiedLinkError libjnidispatch.so HOT 1
- SpeechRecorderDelegate documentation or souce code HOT 2
- Deprecate speech-android-sdk HOT 5
- AndroidManifest.xml merge conflict when added to cordova plugin HOT 2
- stop currently playing audio of Text-to-Speech HOT 3
- android.media.AudioTrack: getMinBufferSize(): 1948401012 Hz is not a supported sample rate. HOT 8
- crash when microphone permissions are not granted HOT 2
- com-sun-jna-android-arm-libjnidispatch-so-not-found-in-resource-path HOT 6
- Response different than java-sdk HOT 2
- documentation is awful mate... HOT 7
- inconsistencies with the AAR which is not updated HOT 3
- Provide a sample implementation that extends Android's RecognitionService HOT 1
- speech-android-sdk and Bluemix HOT 2
- Quick Start Guide HOT 4
- how do i get user credentials HOT 2
- New Project Quick Start Guide
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from speech-android-sdk.