Skip to content

Commit

Permalink
Release version 1.0.0
Browse files Browse the repository at this point in the history
What's new:
 - added lexicons support
 - added speechmarks support
 - AWS SDK version 1.10.4

For more info please refer to the documentation:
https://developer.ivona.com
  • Loading branch information
cucitid committed Sep 4, 2015
1 parent 80dfe81 commit 25e67ba
Show file tree
Hide file tree
Showing 42 changed files with 2,071 additions and 132 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A ready-to-use package is available through Maven:
<dependency>
<groupId>com.ivona</groupId>
<artifactId>ivona-speechcloud-sdk-java</artifactId>
<version>0.3.0</version>
<version>1.0.0</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.ivona</groupId>
<artifactId>ivona-speechcloud-sdk-java</artifactId>
<version>0.3.1</version>
<version>1.0.0</version>
<name>IVONA SpeechCloud SDK for Java</name>
<description>IVONA SpeechCloud SDK for Java provides Java API.</description>
<url>http://www.ivona.com/</url>
Expand Down Expand Up @@ -39,7 +39,7 @@
</distributionManagement>

<properties>
<aws-sdk-java.version>1.9.19</aws-sdk-java.version>
<aws-sdk-java.version>1.10.4</aws-sdk-java.version>
</properties>

<dependencies>
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/com/ivona/services/tts/IvonaSpeechCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
import com.amazonaws.regions.Region;
import com.ivona.services.tts.model.CreateSpeechRequest;
import com.ivona.services.tts.model.CreateSpeechResult;
import com.ivona.services.tts.model.DeleteLexiconRequest;
import com.ivona.services.tts.model.GetLexiconRequest;
import com.ivona.services.tts.model.GetLexiconResult;
import com.ivona.services.tts.model.ListLexiconsResult;
import com.ivona.services.tts.model.ListVoicesRequest;
import com.ivona.services.tts.model.ListVoicesResult;
import com.ivona.services.tts.model.PutLexiconRequest;

/**
* Ivona Speech Cloud Client interface.
Expand Down Expand Up @@ -133,4 +138,47 @@ public void setEndpoint(String endpoint, String serviceName, String regionId)
public void setRegion(Region region) throws IllegalArgumentException;

public void shutdown();

/**
* Method that calls Ivona Speech Cloud and deletes lexicon specified in the lexiconNameRequest.
*
* @param deleteLexiconRequest
* request of the DeleteLexicon operation
* @throws AmazonServiceException
* @throws AmazonClientException
*/
public void deleteLexicon(DeleteLexiconRequest deleteLexiconRequest)
throws AmazonServiceException, AmazonClientException;

/**
* Method that calls Ivona Speech Cloud and returns a lexicon.
*
* @param getLexiconRequest
* request of the GetLexicon operation
* @return GetLexiconResult
* result of the GetLexicon call
* @throws AmazonServiceException
* @throws AmazonClientException
*/
public GetLexiconResult getLexicon(GetLexiconRequest getLexiconRequest)
throws AmazonServiceException, AmazonClientException;

/**
* Method that calls Ivona Speech Cloud and returns list of lexicons.
*
* @return ListLexiconsOutput
* result of the ListLexicons call
*/
public ListLexiconsResult listLexicons();

/**
* Method that calls Ivona Speech Cloud and creates or updates a lexicon.
*
* @param putLexiconRequest
* request of the PutLexicon operation
* @throws AmazonServiceException
* @throws AmazonClientException
*/
public void putLexicon(PutLexiconRequest putLexiconRequest)
throws AmazonServiceException, AmazonClientException;
}
84 changes: 77 additions & 7 deletions src/main/java/com/ivona/services/tts/IvonaSpeechCloudClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,27 @@
import com.ivona.services.tts.http.StreamResponseHandler;
import com.ivona.services.tts.model.CreateSpeechRequest;
import com.ivona.services.tts.model.CreateSpeechResult;
import com.ivona.services.tts.model.DeleteLexiconRequest;
import com.ivona.services.tts.model.GetLexiconRequest;
import com.ivona.services.tts.model.GetLexiconResult;
import com.ivona.services.tts.model.ListLexiconsRequest;
import com.ivona.services.tts.model.ListLexiconsResult;
import com.ivona.services.tts.model.ListVoicesRequest;
import com.ivona.services.tts.model.ListVoicesResult;
import com.ivona.services.tts.model.MethodType;
import com.ivona.services.tts.model.PutLexiconRequest;
import com.ivona.services.tts.model.transform.createspeech.CreateSpeechRequestMarshallerFactory;
import com.ivona.services.tts.model.transform.createspeech.CreateSpeechResultUnmarshaller;
import com.ivona.services.tts.model.transform.lexicons.DeleteLexiconPostRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.DeleteLexiconRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.GetLexiconPostRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.GetLexiconRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.GetLexiconResultJsonUnmarshaller;
import com.ivona.services.tts.model.transform.lexicons.ListLexiconsPostRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.ListLexiconsRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.ListLexiconsResultJsonUnmarshaller;
import com.ivona.services.tts.model.transform.lexicons.PutLexiconPostRequestMarshaller;
import com.ivona.services.tts.model.transform.lexicons.PutLexiconRequestMarshaller;
import com.ivona.services.tts.model.transform.listvoices.ListVoicesRequestMarshallerFactory;
import com.ivona.services.tts.model.transform.listvoices.ListVoicesResultJsonUnmarshaller;
import org.joda.time.DateTime;
Expand All @@ -70,8 +86,8 @@ public class IvonaSpeechCloudClient extends AmazonWebServiceClient implements Iv
private final static String SERVICE_PROTOCOL = "https://";
private final static String SERVICE_DOMAIN = "ivonacloud.com";

private final static Pattern REGION_PATTERN = Pattern.compile(SERVICE_PROTOCOL + SERVICE_NAME +
"\\.([^.]*)\\." + SERVICE_DOMAIN.replace(".", "\\."));
private final static Pattern REGION_PATTERN = Pattern.compile(SERVICE_PROTOCOL + SERVICE_NAME
+ "\\.([^.]*)\\." + SERVICE_DOMAIN.replace(".", "\\."));

private final static int DEFAULT_GET_REQUEST_EXPIRATION_MINUTES = 5;

Expand Down Expand Up @@ -131,7 +147,8 @@ public IvonaSpeechCloudClient(AWSCredentialsProvider awsCredentialsProvider) {
* @param awsCredentialsProvider
* @param clientConfiguration
*/
public IvonaSpeechCloudClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) {
public IvonaSpeechCloudClient(AWSCredentialsProvider awsCredentialsProvider,
ClientConfiguration clientConfiguration) {
super(clientConfiguration);
this.awsCredentialsProvider = awsCredentialsProvider;
init();
Expand All @@ -145,8 +162,8 @@ public CreateSpeechResult createSpeech(CreateSpeechRequest createSpeechRequest)
Request<CreateSpeechRequest> request = CreateSpeechRequestMarshallerFactory.getMarshaller(
createSpeechRequest.getMethodType()).marshall(createSpeechRequest);
CreateSpeechResultUnmarshaller unmarshaller = new CreateSpeechResultUnmarshaller();
StreamResponseHandler<CreateSpeechResult> responseHandler = new StreamResponseHandler<CreateSpeechResult>(unmarshaller);

StreamResponseHandler<CreateSpeechResult> responseHandler =
new StreamResponseHandler<CreateSpeechResult>(unmarshaller);
Response<CreateSpeechResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}
Expand All @@ -167,8 +184,8 @@ public ListVoicesResult listVoices(ListVoicesRequest listVoicesRequest) throws A
Request<ListVoicesRequest> request = ListVoicesRequestMarshallerFactory.getMarshaller(
listVoicesRequest.getMethodType()).marshall(listVoicesRequest);
Unmarshaller<ListVoicesResult, JsonUnmarshallerContext> unmarshaller = new ListVoicesResultJsonUnmarshaller();
JsonResponseHandler<ListVoicesResult> responseHandler = new JsonResponseHandler<ListVoicesResult>(unmarshaller);

JsonResponseHandler<ListVoicesResult> responseHandler =
new JsonResponseHandler<ListVoicesResult>(unmarshaller);
Response<ListVoicesResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}
Expand Down Expand Up @@ -236,6 +253,59 @@ public void setRegion(Region region) throws IllegalArgumentException {
throw new UnsupportedOperationException();
}

@Override
public void deleteLexicon(DeleteLexiconRequest deleteLexiconRequest)
throws AmazonServiceException, AmazonClientException {

ExecutionContext executionContext = createExecutionContext(deleteLexiconRequest);
DeleteLexiconRequestMarshaller marshaller = new DeleteLexiconPostRequestMarshaller();
Request<DeleteLexiconRequest> request = marshaller.marshall(deleteLexiconRequest);
JsonResponseHandler<Void> responseHandler = new JsonResponseHandler<Void>(null);

invoke(request, responseHandler, executionContext);
}

@Override
public GetLexiconResult getLexicon(GetLexiconRequest getLexiconRequest)
throws AmazonServiceException, AmazonClientException {

ExecutionContext executionContext = createExecutionContext(getLexiconRequest);
GetLexiconRequestMarshaller marshaller = new GetLexiconPostRequestMarshaller();
Request<GetLexiconRequest> request = marshaller.marshall(getLexiconRequest);
Unmarshaller<GetLexiconResult, JsonUnmarshallerContext> unmarshaller = new GetLexiconResultJsonUnmarshaller();
JsonResponseHandler<GetLexiconResult> responseHandler = new JsonResponseHandler<GetLexiconResult>(unmarshaller);

Response<GetLexiconResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}

@Override
public ListLexiconsResult listLexicons() {
ListLexiconsRequest listLexiconsRequest = new ListLexiconsRequest();
ExecutionContext executionContext = createExecutionContext(listLexiconsRequest);
ListLexiconsRequestMarshaller marshaller = new ListLexiconsPostRequestMarshaller();
Request<ListLexiconsRequest> request = marshaller.marshall(listLexiconsRequest);
Unmarshaller<ListLexiconsResult, JsonUnmarshallerContext> unmarshaller =
new ListLexiconsResultJsonUnmarshaller();
JsonResponseHandler<ListLexiconsResult> responseHandler =
new JsonResponseHandler<ListLexiconsResult>(unmarshaller);

Response<ListLexiconsResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}

@Override
public void putLexicon(PutLexiconRequest putLexiconRequest)
throws AmazonServiceException, AmazonClientException {

ExecutionContext executionContext = createExecutionContext(putLexiconRequest);
PutLexiconRequestMarshaller marshaller = new PutLexiconPostRequestMarshaller();
Request<PutLexiconRequest> request = marshaller.marshall(putLexiconRequest);
JsonResponseHandler<Void> responseHandler = new JsonResponseHandler<Void>(null);

invoke(request, responseHandler, executionContext);
}

private void init() {
exceptionUnmarshallers = new ArrayList<JsonErrorUnmarshaller>();
exceptionUnmarshallers.add(new JsonErrorUnmarshaller());
Expand Down
96 changes: 69 additions & 27 deletions src/main/java/com/ivona/services/tts/model/CreateSpeechRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
*/
package com.ivona.services.tts.model;

import java.io.Serializable;

import com.amazonaws.AmazonWebServiceRequest;

import java.util.List;

/**
* Class representing CreateSpeech request
* <p>
* Please check the service documentation for more details.
*
* @see <a href="http://developer.ivona.com/en/speechcloud/speechcloud_developer_guide.html">Speech Cloud Developer Guide</a>
* @see <a href="http://developer.ivona.com/en/speechcloud/speechcloud_developer_guide.html">
* Speech Cloud Developer Guide</a>
*/
public class CreateSpeechRequest extends AmazonWebServiceRequest implements Serializable {

private static final long serialVersionUID = 1L;
public class CreateSpeechRequest extends AmazonWebServiceRequest {

private Input input;
private OutputFormat outputFormat;
private Parameters parameters;
private List<String> lexiconNames;
private Voice voice;
private MethodType methodType;

Expand All @@ -49,7 +49,6 @@ public void setInput(Input input) {
this.input = input;
}


/**
* Set the input text for the request.
* <p>
Expand Down Expand Up @@ -112,6 +111,32 @@ public CreateSpeechRequest withParameters(Parameters parameters) {
return this;
}

/**
* Get the lexicons for the request.
* <p>
* Lexicons are optional.
*/
public List<String> getLexiconNames() {
return lexiconNames;
}

/**
* Set the lexicons for the request.
*/
public void setLexiconNames(List<String> lexiconNames) {
this.lexiconNames = lexiconNames;
}

/**
* Set the lexicons for the request.
* <p>
* Returns a reference to this object so that method calls can be chained together.
*/
public CreateSpeechRequest withLexiconNames(List<String> lexiconNames) {
this.lexiconNames = lexiconNames;
return this;
}

/**
* Get which Voice is requested to speak.
* <p>
Expand Down Expand Up @@ -173,10 +198,12 @@ public String toString() {
builder.append(outputFormat);
builder.append(", parameters=");
builder.append(parameters);
builder.append(", lexiconNames=");
builder.append(lexiconNames);
builder.append(", voice=");
builder.append(voice);
builder.append(", methodType=");
builder.append(methodType.toString());
builder.append(methodType);
builder.append("]");
return builder.toString();
}
Expand All @@ -188,6 +215,7 @@ public int hashCode() {
result = prime * result + ((input == null) ? 0 : input.hashCode());
result = prime * result + ((outputFormat == null) ? 0 : outputFormat.hashCode());
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
result = prime * result + ((lexiconNames == null) ? 0 : lexiconNames.hashCode());
result = prime * result + ((voice == null) ? 0 : voice.hashCode());
result = prime * result + ((methodType == null) ? 0 : methodType.hashCode());
return result;
Expand All @@ -196,44 +224,58 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {

if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;

}
CreateSpeechRequest other = (CreateSpeechRequest) obj;
if (input == null) {
if (other.input != null)
if (other.input != null) {
return false;
} else if (!input.equals(other.input))
}
} else if (!input.equals(other.input)) {
return false;

}
if (outputFormat == null) {
if (other.outputFormat != null)
if (other.outputFormat != null) {
return false;
} else if (!outputFormat.equals(other.outputFormat))
}
} else if (!outputFormat.equals(other.outputFormat)) {
return false;

}
if (parameters == null) {
if (other.parameters != null)
if (other.parameters != null) {
return false;
} else if (!parameters.equals(other.parameters))
}
} else if (!parameters.equals(other.parameters)) {
return false;

}
if (lexiconNames == null) {
if (other.lexiconNames != null) {
return false;
}
} else if (!lexiconNames.equals(other.lexiconNames)) {
return false;
}
if (voice == null) {
if (other.voice != null)
if (other.voice != null) {
return false;
} else if (!voice.equals(other.voice))
}
} else if (!voice.equals(other.voice)) {
return false;

}
if (methodType == null) {
if (other.methodType != null)
if (other.methodType != null) {
return false;
} else if (!methodType.equals(other.methodType))
}
} else if (!methodType.equals(other.methodType)) {
return false;

}
return true;
}
}
Loading

0 comments on commit 25e67ba

Please sign in to comment.