|
Project Information
Featured
Downloads
Links
|
AboutJ4SC (Java for SpinVox Create) is a Java API designed to be used by developers for submitting audio and retrieving converted text from the SpinVox Create service (the service). MotivationAs a result of experimenting with the service, the project owners felt Java developers would benefit from an easy to use API which removed them having to deal with the lower level details of the HTTP based service. Instead of having to worry about HTTP requests and responses, J4SC allows you to work with well defined objects which simplifies use of the service. Also, since there is a considerable amount of validation carried out by the service, the API where possible validates up front, thus saving a round trip to the service only to be told the audio codec is invalid or you're missing a mandatory header. Quick Start Example CodeThe code below shows you how to use the API for submission and retrieval, see Tutorial for further information on the code import java.io.File;
import java.util.Date;
import com.googlecode.j4sc.UserCredentials;
import com.googlecode.j4sc.conversion.Conversion;
import com.googlecode.j4sc.conversion.Conversion.Status;
import com.googlecode.j4sc.service.Service;
import com.googlecode.j4sc.submission.Submission;
import com.googlecode.j4sc.submission.SubmissionReference;
import com.googlecode.j4sc.submission.audio.Audio;
public class SubmitAudioAndRetrieveConversion {
public static void main(String[] args) {
try {
String reference = String.valueOf(new Date().getTime());
String accountId = "1234-1234-1234-1234";
String applicationName = "j4sc";
Audio audio = new Audio(new File("src/test/resources/alaw-20seconds.wav"));
String username = "username";
String password = "password";
UserCredentials userCredentials = new UserCredentials(username, password);
PartyInformation partyInfo = new PartyInformationBuilder()
.withCallingParty("a", "4321")
.withCalledParty("b", "1234")
.createPartyInformation();
Submission submission = new Submission(accountId, applicationName, reference, audio, partyInfo,
userCredentials);
SubmissionReference submissionReference = Service.DEVELOPMENT.submit(submission);
Conversion conversion;
do {
Thread.sleep(10000);
conversion = Service.DEVELOPMENT.retrieve(submissionReference);
} while (conversion.isPending());
System.out.println("Status: " + conversion.getStatus());
System.out.println("Text: " + conversion.getText());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|