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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ibm.watson.developer_cloud.text_to_speech.v1;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

import com.ibm.watson.developer_cloud.http.HttpMediaType;
import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation;
import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationResult;
import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice;

public class TranslateAndSynthesizeExample {

public static void main(String[] args) throws IOException {
LanguageTranslation translator = new LanguageTranslation();
translator.setUsernameAndPassword("username", "password");

TextToSpeech synthesizer = new TextToSpeech();
synthesizer.setUsernameAndPassword("username", "password");

String text = "Greetings from Watson Developer Cloudl";

// translate
TranslationResult translationResult = translator.translate(text, "en", "es");
String translation = translationResult.getTranslations().get(0).getTranslation();

// synthesize
InputStream in = synthesizer.synthesize(translation, Voice.ES_LAURA, HttpMediaType.AUDIO_WAV);
Files.copy(in, Paths.get("output.wav"), StandardCopyOption.REPLACE_EXISTING);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class AlchemyLanguage extends AlchemyService {
public static final String XPATH = "xpath";
public static final String TARGETS = "targets";
public static final String ANCHOR_DATE = "anchorDate";

// language to be used with request
private LanguageSelection language = LanguageSelection.DETECT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ public ImageKeywords getImageKeywords(File image, Boolean forceShowAll, Boolean
params.put(KNOWLEDGE_GRAPH, knowledgeGraph ? 1 : 0);

ImageKeywords imageKeywords = executeRequest(params, AlchemyAPI.image_keywords, ImageKeywords.class);

// Remove the NO_TAGS keywords
ListIterator<ImageKeyword> iter = imageKeywords.getImageKeywords().listIterator();
while (iter.hasNext()){
if (iter.next().getText().equals(NO_TAGS)){
iter.remove();
}
while (iter.hasNext()) {
if (iter.next().getText().equals(NO_TAGS)) {
iter.remove();
}
}
return imageKeywords;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/**
* Copyright 2015 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.ibm.watson.developer_cloud.alchemy.v1.model;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ public void setScore(Double score) {
private Gender gender;

/** The height. */
private String height;
private Integer height;

/** The identity. */
private Identity identity;

/** The position x. */
private String positionX;
private Integer positionX;

/** The position y. */
private String positionY;
private Integer positionY;

/** The width. */
private String width;
private Integer width;

/**
* Gets the age.
Expand All @@ -163,7 +163,7 @@ public Gender getGender() {
*
* @return The height
*/
public String getHeight() {
public Integer getHeight() {
return height;
}

Expand All @@ -181,7 +181,7 @@ public Identity getIdentity() {
*
* @return The positionX
*/
public String getPositionX() {
public Integer getPositionX() {
return positionX;
}

Expand All @@ -190,7 +190,7 @@ public String getPositionX() {
*
* @return The positionY
*/
public String getPositionY() {
public Integer getPositionY() {
return positionY;
}

Expand All @@ -199,7 +199,7 @@ public String getPositionY() {
*
* @return The width
*/
public String getWidth() {
public Integer getWidth() {
return width;
}

Expand All @@ -226,7 +226,7 @@ public void setGender(Gender gender) {
*
* @param height The height
*/
public void setHeight(String height) {
public void setHeight(Integer height) {
this.height = height;
}

Expand All @@ -244,7 +244,7 @@ public void setIdentity(Identity identity) {
*
* @param positionX The positionX
*/
public void setPositionX(String positionX) {
public void setPositionX(Integer positionX) {
this.positionX = positionX;
}

Expand All @@ -253,7 +253,7 @@ public void setPositionX(String positionX) {
*
* @param positionY The positionY
*/
public void setPositionY(String positionY) {
public void setPositionY(Integer positionY) {
this.positionY = positionY;
}

Expand All @@ -262,7 +262,7 @@ public void setPositionY(String positionY) {
*
* @param width The width
*/
public void setWidth(String width) {
public void setWidth(Integer width) {
this.width = width;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public void setHierarchy(String hierarchy) {
}

/**
* Gets the hierarchy. A value is only present if the request that produced this instance
* was made with {@code knowledgeGraph = true}.
* Gets the hierarchy. A value is only present if the request that produced this instance was made
* with {@code knowledgeGraph = true}.
*
* @return The hierarchy, if it exists.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ImageSceneText extends AlchemyGenericModel {

/** The scene text. */
private String sceneText;

/**
* Gets the image faces.
*
Expand All @@ -59,7 +59,7 @@ public String getUrl() {
public String getSceneText() {
return sceneText;
}

/**
* Sets the image faces.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public class ImageSceneTextLine extends GenericModel {
* Region.
*/
public static class Region extends GenericModel {

/** The height. */
private Integer height;

/** The width. */
private Integer width;

/** The x. */
private Integer x;

/** The y. */
private Integer y;

Expand Down Expand Up @@ -118,13 +118,13 @@ public void setY(Integer y) {
* A word within a line of text.
*/
public static class Word extends GenericModel {

/** The confidence. */
private Double confidence;

/** The region. */
private Region region;

/** The text. */
private String text;

Expand Down Expand Up @@ -186,13 +186,13 @@ public void setText(String text) {

/** The confidence. */
private Double confidence;

/** The region. */
private Region region;

/** The text. */
private String text;

/** The words. */
private List<Word> words;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package com.ibm.watson.developer_cloud.alchemy.v1.model;

public enum LanguageSelection {
ENGLISH,
FRENCH,
GERMAN,
ITALIAN,
PORTUGESE,
RUSSIAN,
SPANISH,
SWEDISH,
DETECT
ENGLISH, FRENCH, GERMAN, ITALIAN, PORTUGESE, RUSSIAN, SPANISH, SWEDISH, DETECT
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ public class Sentiment extends GenericModel {
public enum SentimentType {

/** negative sentiment. */
@SerializedName("negative")
NEGATIVE,
@SerializedName("negative") NEGATIVE,

/** neutral sentiment. */
@SerializedName("neutral")
NEUTRAL,
@SerializedName("neutral") NEUTRAL,

/** positive sentiment. */
@SerializedName("positive")
POSITIVE
@SerializedName("positive") POSITIVE
}

/** The mixed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public PublicationDate read(JsonReader reader) throws IOException {

if (name.equals("confident")) {
final String confidentAsString = reader.nextString();
publicationDate.setConfident(confidentAsString != null && !confidentAsString.equals("no") && !confidentAsString.equals("false"));
publicationDate.setConfident(confidentAsString != null && !confidentAsString.equals("no")
&& !confidentAsString.equals("false"));
} else if (name.equals("date")) {
final String dateAsString = reader.nextString();
if (dateAsString != null && !dateAsString.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
* similar contexts.
*
* @version v1
* @see <a
* href="http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/concept-expansion.html">
* @see <a href=
* "http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/concept-expansion.html">
* Concept Expansion</a>
*/
public class ConceptExpansion extends WatsonService {
Expand Down Expand Up @@ -111,12 +111,13 @@ public Job createJob(final String label, final String[] seeds) {
*
* <pre>
* <code> { result:"apple", prevalence:"20" }</code>
* </pre>
* </pre>
*
* @return the concept as POJO Object
*/
private Concept formatConcept(JsonObject conceptJson) {
return new Concept(conceptJson.get(RESULT).getAsString(), conceptJson.get(PREVALENCE)
.getAsDouble());
return new Concept(conceptJson.get(RESULT).getAsString(),
conceptJson.get(PREVALENCE).getAsDouble());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/**
* Copyright 2015 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.ibm.watson.developer_cloud.concept_expansion.v1.model;

Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/**
* Copyright 2015 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.ibm.watson.developer_cloud.concept_expansion.v1;

Loading