Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ All the services:
Only Assistant:

```gradle
'com.ibm.watson.developer_cloud:assistant:5.0.1'
'com.ibm.watson.developer_cloud:assistant:5.1.1'
```

##### Development Snapshots
Expand All @@ -97,7 +97,7 @@ And then reference the snapshot version on your app module gradle
Only Speech to Text:

```gradle
'com.ibm.watson.developer_cloud:speech-to-text:5.1.1-SNAPSHOT'
'com.ibm.watson.developer_cloud:speech-to-text:5.1.2-SNAPSHOT'
```

##### JAR
Expand Down
26 changes: 14 additions & 12 deletions assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>assistant</artifactId>
<version>5.0.0</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>assistant</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -25,7 +25,9 @@ Assistant service = new Assistant("2018-02-16");
service.setUsernameAndPassword("<username>", "<password>");

InputData input = new InputData.Builder("Hi").build();
MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build();
MessageOptions options = new MessageOptions.Builder(workspaceId)
.input(input)
.build();
MessageResponse response = service.message(options).execute();
System.out.println(response);
```
Expand All @@ -37,19 +39,19 @@ Context context = null;

// first message
MessageOptions newMessageOptions = new MessageOptions.Builder()
.workspaceId("<workspace-id>")
.input(new InputData.Builder("First message").build())
.context(context)
.build();
.workspaceId("<workspace-id>")
.input(new InputData.Builder("First message").build())
.context(context)
.build();

MessageResponse response = service.message(newMessageOptions).execute();

// second message
newMessageOptions = new MessageOptions.Builder()
.workspaceId("<workspace-id>")
.input(new InputData.Builder("Second message").build())
.context(response.getContext()) // output context from the first message
.build();
.workspaceId("<workspace-id>")
.input(new InputData.Builder("Second message").build())
.context(response.getContext()) // output context from the first message
.build();

response = service.message(newMessageOptions).execute();

Expand Down
26 changes: 14 additions & 12 deletions conversation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>conversation</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>conversation</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -25,7 +25,9 @@ Conversation service = new Conversation("2018-02-16");
service.setUsernameAndPassword("<username>", "<password>");

InputData input = new InputData.Builder("Hi").build();
MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build();
MessageOptions options = new MessageOptions.Builder(workspaceId)
.input(input)
.build();
MessageResponse response = service.message(options).execute();
System.out.println(response);
```
Expand All @@ -37,19 +39,19 @@ Context context = null;

// first message
MessageOptions newMessageOptions = new MessageOptions.Builder()
.workspaceId("<workspace-id>")
.input(new InputData.Builder("First message").build())
.context(context)
.build();
.workspaceId("<workspace-id>")
.input(new InputData.Builder("First message").build())
.context(context)
.build();

MessageResponse response = service.message(newMessageOptions).execute();

// second message
newMessageOptions = new MessageOptions.Builder()
.workspaceId("<workspace-id>")
.input(new InputData.Builder("Second message").build())
.context(response.getContext()) // output context from the first message
.build();
.workspaceId("<workspace-id>")
.input(new InputData.Builder("Second message").build())
.context(response.getContext()) // output context from the first message
.build();

response = service.message(newMessageOptions).execute();

Expand Down
11 changes: 7 additions & 4 deletions language-translator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>language-translator</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>language-translator</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -25,7 +25,10 @@ LanguageTranslator service = new LanguageTranslator();
service.setUsernameAndPassword("<username>", "<password>");

TranslateOptions translateOptions = new TranslateOptions.Builder()
.addText("hello").source(Language.ENGLISH).target(Language.SPANISH).build();
.addText("hello")
.source(Language.ENGLISH)
.target(Language.SPANISH)
.build();
TranslationResult translationResult = service.translate(translateOptions).execute();

System.out.println(translationResult);
Expand Down
13 changes: 9 additions & 4 deletions natural-language-classifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>natural-language-classifier</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>natural-language-classifier</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -23,7 +23,12 @@ Use [Natural Language Classifier](https://console.bluemix.net/docs/services/natu
NaturalLanguageClassifier service = new NaturalLanguageClassifier();
service.setUsernameAndPassword("<username>", "<password>");

Classification classification = service.classify("<classifier-id>", "Is it sunny?").execute();
ClassifyOptions classifyOptions = new ClassifyOptions.Builder()
.classifierId("<classifier-id>")
.text("Is it sunny?")
.build();

Classification classification = service.classify(classifyOptions).execute();
System.out.println(classification);
```

Expand Down
31 changes: 19 additions & 12 deletions natural-language-understanding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>natural-language-understanding</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>natural-language-understanding</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -23,16 +23,23 @@ Language Understanding will give you results for the features you request. The s
analysis by default, so the results can ignore most advertisements and other unwanted content.

```java
NaturalLanguageUnderstanding service = new NaturalLanguageUnderstanding(
"2017-02-27",
"username",
"password"
);

EntitiesOptions entities = new EntitiesOptions.Builder().sentiment(true).limit(1).build();
Features features = new Features.Builder().entities(entities).build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder().url("www.cnn.com").features(features).build();
NaturalLanguageUnderstanding service = new NaturalLanguageUnderstanding("2017-02-27");
service.setUsernameAndPassword("<username>", "<password>");

EntitiesOptions entities = new EntitiesOptions.Builder()
.sentiment(true)
.limit(1)
.build();
Features features = new Features.Builder()
.entities(entities)
.build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder()
.url("www.cnn.com")
.features(features)
.build();

AnalysisResults results = service.analyze(parameters).execute();
System.out.println(results);
```

We also offer a cognitive client which makes use of this API to provide enhanced features for applications using our natural language understanding services:
Expand Down
16 changes: 8 additions & 8 deletions personality-insights/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>personality-insights</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>personality-insights</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand Down Expand Up @@ -42,14 +42,14 @@ String text = "Call me Ishmael. Some years ago-never mind how long precisely-hav
+ "city of the Manhattoes, belted round by wharves as Indian isles by coral reefs-commerce surrounds "
+ "it with her surf. Right and left, the streets take you waterward.";

ProfileOptions options = new ProfileOptions.Builder().text(text).build();
Profile profile = service.profile(options).execute();
ProfileOptions options = new ProfileOptions.Builder()
.text(text)
.build();

Profile profile = service.profile(options).execute();
System.out.println(profile);
```

**Note:** Don't forget to update the `text` variable! Also, if you experience
authentication errors, remember that the Personality Insights service is not
a free service.
**Note:** Don't forget to update the `text` variable!

[personality_insights]: https://console.bluemix.net/docs/services/personality-insights/index.html
32 changes: 17 additions & 15 deletions speech-to-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>speech-to-text</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>speech-to-text</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -26,32 +26,33 @@ service.setUsernameAndPassword("<username>", "<password>");
File audio = new File("src/test/resources/sample1.wav");

RecognizeOptions options = new RecognizeOptions.Builder()
.contentType(HttpMediaType.AUDIO_WAV)
.build();
.audio(audio)
.contentType(HttpMediaType.AUDIO_WAV)
.build();

SpeechResults transcript = service.recognize(audio, options).execute();
SpeechRecognitionResults transcript = service.recognize(options).execute();
System.out.println(transcript);
```

#### WebSocket support

Speech to Text supports WebSocket, the url is:
`wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize`
Speech to Text supports WebSocket, the url is: `wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize`

```java
```java
SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("<username>", "<password>");

InputStream audio = new FileInputStream("src/test/resources/sample1.wav");

RecognizeOptions options = new RecognizeOptions.Builder()
.interimResults(true)
.contentType(HttpMediaType.AUDIO_WAV)
.build();
.audio(audio)
.contentType(HttpMediaType.AUDIO_WAV)
.interimResults(true)
.build();

service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() {
@Override
public void onTranscription(SpeechResults speechResults) {
public void onTranscription(SpeechRecognitionResults speechResults) {
System.out.println(speechResults);
}
});
Expand Down Expand Up @@ -86,10 +87,11 @@ RecognizeOptions options = new RecognizeOptions.Builder()
.continuous(true)
.interimResults(true)
//.inactivityTimeout(5) // use this to stop listening when the speaker pauses, i.e. for 5s
.audio(audio)
.contentType(HttpMediaType.AUDIO_RAW + "; rate=" + sampleRate)
.build();

service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() {
@Override
public void onTranscription(SpeechResults speechResults) {
System.out.println(speechResults);
Expand Down
8 changes: 4 additions & 4 deletions text-to-speech/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>text-to-speech</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>text-to-speech</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -23,7 +23,7 @@ Use the [Text to Speech][text_to_speech] service to get the available voices to
TextToSpeech service = new TextToSpeech();
service.setUsernameAndPassword("<username>", "<password>");

List<Voice> voices = service.getVoices().execute();
Voices voices = service.listVoices().execute();
System.out.println(voices);
```

Expand Down
14 changes: 8 additions & 6 deletions tone-analyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
##### Maven
```xml
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>tone-analyzer</artifactId>
<version>5.1.1</version>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>tone-analyzer</artifactId>
<version>5.1.1</version>
</dependency>
```

Expand All @@ -20,8 +20,7 @@
Use the [Tone Analyzer][tone_analyzer] service to get the tone of your email.

```java
final String VERSION_DATE = "2017-09-21";
ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE);
ToneAnalyzer service = new ToneAnalyzer("2017-09-21");
service.setUsernameAndPassword("<username>", "<password>");

String text =
Expand All @@ -37,7 +36,10 @@ String text =
+ "business outcomes. Economy has nothing to do with it.";

// Call the service and get the tone
ToneOptions toneOptions = new ToneOptions.Builder().html(text).build();
ToneOptions toneOptions = new ToneOptions.Builder()
.html(text)
.build();

ToneAnalysis tone = service.tone(toneOptions).execute();
System.out.println(tone);
```
Expand Down
Loading