index
int64
repo_id
string
file_path
string
content
string
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/exceptions/ForbiddenStateException.java
package ai.rev.exceptions; import org.json.JSONObject; /** * The ForbiddenStateException occurs when a user attempts to retrieve the result of * an unprocessed job. */ public class ForbiddenStateException extends RevAiApiException { public ForbiddenStateException(JSONObject errorResponse) { super("Forbidden State Exception", errorResponse, 409); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/exceptions/InvalidHeaderException.java
package ai.rev.exceptions; import org.json.JSONObject; /** * The InvalidHeaderException occurs when a header that's passed along a query is not recognized by * the API. */ public class InvalidHeaderException extends RevAiApiException { public InvalidHeaderException(JSONObject errorResponse) { super("Invalid Header Exception", errorResponse, 406); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/exceptions/InvalidParameterException.java
package ai.rev.exceptions; import org.json.JSONObject; /** * The InvalidParameterException occurs when a parameter that's passed along a query is not * recognized by the API. */ public class InvalidParameterException extends RevAiApiException { public InvalidParameterException(JSONObject errorResponse) { super("Invalid Parameter Exception ", errorResponse, 400); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/exceptions/ResourceNotFoundException.java
package ai.rev.exceptions; import org.json.JSONObject; /** * The ResourceNotFoundException occurs when a job ID queried cannot be found. */ public class ResourceNotFoundException extends RevAiApiException { public ResourceNotFoundException(JSONObject errorResponse) { super("Resource Not Found Exception", errorResponse, 404); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/exceptions/RevAiApiException.java
package ai.rev.exceptions; import org.json.JSONObject; import java.io.IOException; /** * The RevAiApiException wraps standard Java IOException and enriches them with custom information. * You can use this code to retrieve details of exceptions when calling the Rev AI API. */ public class RevAiApiException extends IOException { public RevAiApiException(String message, JSONObject errorResponse, int responseCode) { super(formatErrorDetails(message, errorResponse, responseCode)); } private static String formatErrorDetails( String message, JSONObject errorResponse, int responseCode) { return String.format("Response code: %s, Error: %s, Api response: %s", responseCode, message, errorResponse); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/exceptions/ThrottlingLimitException.java
package ai.rev.exceptions; import org.json.JSONObject; /** * ThrottlingLimitException occurs when the number of queries within a given period exceeds a * throttling limit. */ public class ThrottlingLimitException extends RevAiApiException { public ThrottlingLimitException(JSONObject errorResponse) { super("Throttling Limit Exception", errorResponse, 429); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/helpers/ApiInterceptor.java
package ai.rev.helpers; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import java.io.IOException; /** * An ApiInterceptor object appends authorization information to all API calls and is used to check * the status of the request for debugging purposes. */ public class ApiInterceptor implements Interceptor { private String accessToken; private String sdkVersion; public ApiInterceptor(String accessToken, String sdkVersion) { this.accessToken = accessToken; this.sdkVersion = sdkVersion; } @Override public Response intercept(Chain chain) throws IOException { Request request = chain .request() .newBuilder() .addHeader("Authorization", String.format("Bearer %s", accessToken)) .addHeader("User-Agent", String.format("RevAi-JavaSDK/%s", sdkVersion)) .build(); return chain.proceed(request); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/helpers/ClientHelper.java
package ai.rev.helpers; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.scalars.ScalarsConverterFactory; public class ClientHelper { public static OkHttpClient createOkHttpClient(String accessToken) { return new OkHttpClient.Builder() .retryOnConnectionFailure(false) .addNetworkInterceptor(new ApiInterceptor(accessToken, SDKHelper.getSdkVersion())) .addNetworkInterceptor(new ErrorInterceptor()) .retryOnConnectionFailure(false) .build(); } public static Retrofit createRetrofitInstance( OkHttpClient client, String apiName, String apiVersion ) { return new Retrofit.Builder() .baseUrl(String.format( "%s/%s/%s/", RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl(), apiName, apiVersion )) .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); } public static Retrofit createRetrofitInstance( OkHttpClient client, String apiName, String apiVersion, String baseUrl ) { return new Retrofit.Builder() .baseUrl(String.format( "%s/%s/%s/", baseUrl != null ? baseUrl : RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl(), apiName, apiVersion )) .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/helpers/ErrorInterceptor.java
package ai.rev.helpers; import ai.rev.exceptions.AuthorizationException; import ai.rev.exceptions.ForbiddenRequestException; import ai.rev.exceptions.ForbiddenStateException; import ai.rev.exceptions.InvalidHeaderException; import ai.rev.exceptions.InvalidParameterException; import ai.rev.exceptions.ResourceNotFoundException; import ai.rev.exceptions.RevAiApiException; import ai.rev.exceptions.ThrottlingLimitException; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import org.json.JSONObject; import java.io.IOException; /** The ErrorInterceptor class is used to intercept all responses with erroneous response codes. */ public class ErrorInterceptor implements Interceptor { public ErrorInterceptor() {} @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); Response response = chain.proceed(request); int responseCode = response.code(); if (responseCode > 399) { JSONObject errorResponse = new JSONObject(response.body().string()); switch (responseCode) { case 401: throw new AuthorizationException(errorResponse); case 400: throw new InvalidParameterException(errorResponse); case 403: throw new ForbiddenRequestException(errorResponse); case 404: throw new ResourceNotFoundException(errorResponse); case 406: throw new InvalidHeaderException(errorResponse); case 409: throw new ForbiddenStateException(errorResponse); case 429: throw new ThrottlingLimitException(errorResponse); default: throw new RevAiApiException("Unexpected API Error", errorResponse, responseCode); } } else { return response; } } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/helpers/MockInterceptor.java
package ai.rev.helpers; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import java.io.IOException; /** A MockInterceptor object is used to mock the responses for testing purposes. */ public class MockInterceptor implements Interceptor { private String sampleResponse; private MediaType mediaType; private Integer responseCode; public Request request; public MockInterceptor(MediaType mediaType, Integer responseCode) { this.mediaType = mediaType; this.responseCode = responseCode; } @Override public Response intercept(Chain chain) throws IOException { request = chain.request(); return chain .proceed(chain.request()) .newBuilder() .code(responseCode) .protocol(Protocol.HTTP_2) .message("mock interceptor") .body(ResponseBody.create(sampleResponse, mediaType)) .addHeader("content-type", "application/json") .build(); } public String getSampleResponse() { return sampleResponse; } public void setSampleResponse(String sampleResponse) { this.sampleResponse = sampleResponse; } public Request getRequest() { return request; } public void setRequest(Request request) { this.request = request; } public MediaType getMediaType() { return mediaType; } public void setMediaType(MediaType mediaType) { this.mediaType = mediaType; } public Integer getResponseCode() { return responseCode; } public void setResponseCode(Integer responseCode) { this.responseCode = responseCode; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/helpers/RevAiApiDeploymentConfiguration.java
package ai.rev.helpers; import java.util.HashMap; import java.util.Map; public class RevAiApiDeploymentConfiguration { // Enum for API deployment regions public enum RevAiApiDeployment { US("US"), EU("EU"); private final String value; RevAiApiDeployment(String value) { this.value = value; } public String getValue() { return value; } } // Configuration map for deployment URLs private static final Map<RevAiApiDeployment, DeploymentConfig> RevAiApiDeploymentConfigMap; static { RevAiApiDeploymentConfigMap = new HashMap<>(); RevAiApiDeploymentConfigMap.put( RevAiApiDeployment.US, new DeploymentConfig("https://api.rev.ai", "wss://api.rev.ai") ); RevAiApiDeploymentConfigMap.put( RevAiApiDeployment.EU, new DeploymentConfig("https://ec1.api.rev.ai", "wss://ec1.api.rev.ai") ); } // Inner class for deployment configurations public static class DeploymentConfig { private final String baseUrl; private final String baseWebsocketUrl; public DeploymentConfig(String baseUrl, String baseWebsocketUrl) { this.baseUrl = baseUrl; this.baseWebsocketUrl = baseWebsocketUrl; } public String getBaseUrl() { return baseUrl; } public String getBaseWebsocketUrl() { return baseWebsocketUrl; } } // Method to get the configuration for a specific deployment public static DeploymentConfig getConfig(RevAiApiDeployment deployment) { return RevAiApiDeploymentConfigMap.get(deployment); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/helpers/SDKHelper.java
package ai.rev.helpers; /** A helper class that provides methods for getting SDK information. */ public class SDKHelper { /** * Helper function that reads the current sdk version from pom.xml. * * @return The current SDK version. */ public static String getSdkVersion() { return SDKHelper.class.getPackage().getImplementationVersion(); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/LanguageIdClient.java
package ai.rev.languageid; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import ai.rev.helpers.ClientHelper; import ai.rev.helpers.RevAiApiDeploymentConfiguration; import ai.rev.languageid.models.LanguageIdJob; import ai.rev.languageid.models.LanguageIdJobOptions; import ai.rev.languageid.models.LanguageIdResult; import ai.rev.speechtotext.FileStreamRequestBody; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.RequestBody; import retrofit2.Retrofit; /** * The LanguageIdClient object provides methods to send and retrieve information from all the * Rev AI Language Identification API endpoints using the Retrofit HTTP client. */ public class LanguageIdClient { private OkHttpClient client; /** * Interface that LanguageIdClient methods use to make requests */ public LanguageIdInterface apiInterface; /** * Constructs the API client used to send HTTP requests to Rev AI. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @param baseUrl Optional url of the Rev AI API deployment to use, defaults to the US deployement, i.e. 'https://api.rev.ai', which can be referenced as RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl(). * @throws IllegalArgumentException If the access token is null or empty. */ public LanguageIdClient(String accessToken, String baseUrl) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance( client, "languageid", "v1", baseUrl != null ? baseUrl : RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl() ); this.apiInterface = retrofit.create(LanguageIdInterface.class); } /** * Constructs the API client used to send HTTP requests to Rev AI. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @throws IllegalArgumentException If the access token is null or empty. */ public LanguageIdClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client, "languageid", "v1"); this.apiInterface = retrofit.create(LanguageIdInterface.class); } /** * Manually closes the connection when the code is running in a JVM */ public void closeConnection() { client.dispatcher().executorService().shutdown(); client.connectionPool().evictAll(); } /** * This method sends a GET request to the /jobs endpoint and returns a list of {@link LanguageIdJob} * objects. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @param startingAfter The job ID at which the list begins. * @return A list of {@link LanguageIdJob} objects. * @throws IOException If the response has a status code > 399. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/GetListOfLanguageIdentificationJobs">https://docs.rev.ai/api/language-identification/reference/#operation/GetListOfLanguageIdentificationJobs</a> */ public List<LanguageIdJob> getListOfJobs(Integer limit, String startingAfter) throws IOException { Map<String, String> options = new HashMap<>(); if (startingAfter != null) { options.put("starting_after", startingAfter); } if (limit != null) { options.put("limit", String.valueOf(limit)); } return apiInterface.getListOfJobs(options).execute().body(); } /** * Overload of {@link LanguageIdClient#getListOfJobs(Integer, String)} without the optional startingAfter * parameter. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @return A list of {@link LanguageIdJob} objects. * @throws IOException If the response has a status code > 399. */ public List<LanguageIdJob> getListOfJobs(Integer limit) throws IOException { return getListOfJobs(limit, null); } /** * Overload of {@link LanguageIdClient#getListOfJobs(Integer, String)} without the optional limit * parameter. * * @param startingAfter The job ID at which the list begins. * @return A list of {@link LanguageIdJob} objects. * @throws IOException If the response has a status code > 399. */ public List<LanguageIdJob> getListOfJobs(String startingAfter) throws IOException { return getListOfJobs(null, startingAfter); } /** * Overload of {@link LanguageIdClient#getListOfJobs(Integer, String)} without the optional limit and * startingAfter parameter. * * @return A list of {@link LanguageIdJob} objects. * @throws IOException If the response has a status code > 399. */ public List<LanguageIdJob> getListOfJobs() throws IOException { return getListOfJobs(null, null); } /** * This method sends a GET request to the /jobs/{id} endpoint and returns a {@link LanguageIdJob} * object. * * @param id The ID of the job to return an object for. * @return A {@link LanguageIdJob} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. */ public LanguageIdJob getJobDetails(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Job ID must be provided"); } return apiInterface.getJobDetails(id).execute().body(); } /** * This method sends a DELETE request to the /jobs/{id} endpoint. * * @param id The id of the job to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/DeleteLanguageIdentificationJobById">https://docs.rev.ai/api/language-identification/reference/#operation/DeleteLanguageIdentificationJobById</a> */ public void deleteJob(String id) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } apiInterface.deleteJob(id).execute(); } /** * The method sends a GET request to the /jobs/{id}/result endpoint and returns a {@link LanguageIdResult} object. * * @param id The id of the job to return a result for. * @return LanguageIdResult The result object. * @throws IOException If the response has a status code > 399. * @see LanguageIdResult * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/GetLanguageIdentificationResultById">https://docs.rev.ai/api/language-identification/reference/#operation/GetLanguageIdentificationResultById</a> */ public LanguageIdResult getResultObject(String id) throws IOException { return apiInterface.getResultObject(id).execute().body(); } /** * The method sends a POST request to the /jobs endpoint, starts a language id job for the * provided options and returns a {@link LanguageIdJob} object. * * @param options The language id options associated with this job. * @return LanguageIdJob A representation of the language id job. * @throws IOException If the response has a status code > 399. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public LanguageIdJob submitJob(LanguageIdJobOptions options) throws IOException { return apiInterface.submitJob(options).execute().body(); } /** * The method sends multipart/form POST request to the /jobs endpoint, starts a language id job for the * provided local media file and returns a {@link LanguageIdJob} object. * * @param filePath A local path to the file on the computer. * @param options The language id options associated with this job. * @return LanguageIdJob A representation of the language id job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the file path is null. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public LanguageIdJob submitJobLocalFile(String filePath, LanguageIdJobOptions options) throws IOException { if (filePath == null) { throw new IllegalArgumentException("File path must be provided"); } if (options == null) { options = new LanguageIdJobOptions(); } File file = new File(filePath); return submitMultipartRequest(new FileInputStream(file.getAbsoluteFile()), file.getName(), options); } /** * The method sends a multipart/form POST request to the /jobs endpoint, starts a language id job for the * provided media file provided by InputStream and returns a {@link LanguageIdJob} object. * * @param inputStream An InputStream of the media file. * @param fileName The name of the file being streamed. * @param options The language id options associated with this job. * @return LanguageIdJob A representation of the language id job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the InputStream provided is null. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public LanguageIdJob submitJobLocalFile( InputStream inputStream, String fileName, LanguageIdJobOptions options) throws IOException { if (inputStream == null) { throw new IllegalArgumentException("File stream must be provided"); } if (options == null) { options = new LanguageIdJobOptions(); } if (fileName == null) { fileName = "audio_file"; } return submitMultipartRequest(inputStream, fileName, options); } /** * An overload of {@link LanguageIdClient#submitJobLocalFile(InputStream, String, LanguageIdJobOptions)} * without the optional filename and language id options. * * @param inputStream An InputStream of the media file. * @return LanguageIdJob A representation of the language id job. * @throws IOException If the response has a status code > 399. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public LanguageIdJob submitJobLocalFile(InputStream inputStream) throws IOException { return submitJobLocalFile(inputStream, null, null); } /** * An overload of {@link LanguageIdClient#submitJobLocalFile(InputStream, String, LanguageIdJobOptions)} * without the additional language id options. * * @param inputStream An InputStream of the media file. * @param fileName The name of the file being streamed. * @return LanguageIdJob A representation of the language id job. * @throws IOException If the response has a status code > 399. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public LanguageIdJob submitJobLocalFile(InputStream inputStream, String fileName) throws IOException { return submitJobLocalFile(inputStream, fileName, null); } /** * An overload of {@link LanguageIdClient#submitJobLocalFile(InputStream, String, LanguageIdJobOptions)} * without the optional filename. * * @param inputStream An InputStream of the media file. * @param options The language id options associated with this job. * @return LanguageIdJob A representation of the language id job. * @throws IOException If the response has a status code > 399. * @see LanguageIdJob * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public LanguageIdJob submitJobLocalFile(InputStream inputStream, LanguageIdJobOptions options) throws IOException { return submitJobLocalFile(inputStream, null, options); } private LanguageIdJob submitMultipartRequest( InputStream inputStream, String fileName, LanguageIdJobOptions options) throws IOException { RequestBody fileRequest = FileStreamRequestBody.create(inputStream, MediaType.parse("audio/*")); MultipartBody.Part filePart = MultipartBody.Part.createFormData("media", fileName, fileRequest); return apiInterface.submitJobLocalFile(filePart, options).execute().body(); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/LanguageIdInterface.java
package ai.rev.languageid; import ai.rev.languageid.models.LanguageIdJob; import ai.rev.languageid.models.LanguageIdJobOptions; import ai.rev.languageid.models.LanguageIdResult; import okhttp3.MultipartBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.QueryMap; import java.util.List; import java.util.Map; /** * The LanguageIdInterface is a type-safe Retrofit interface that presents all the endpoints that are made * to communicate with the Rev AI Language Identification API. */ public interface LanguageIdInterface { String REV_LANGUAGE_ID_CONTENT_TYPE = "application/vnd.rev.languageid.v1.0+json"; @GET("jobs/{id}") Call<LanguageIdJob> getJobDetails(@Path("id") String jobID); @GET("jobs") Call<List<LanguageIdJob>> getListOfJobs(@QueryMap Map<String, String> options); @Headers("Accept: " + REV_LANGUAGE_ID_CONTENT_TYPE) @GET("jobs/{id}/result") Call<LanguageIdResult> getResultObject(@Path("id") String jobID); @POST("jobs") Call<LanguageIdJob> submitJob(@Body LanguageIdJobOptions options); @Multipart @POST("jobs") Call<LanguageIdJob> submitJobLocalFile(@Part MultipartBody.Part file, @Part("options") LanguageIdJobOptions options); @DELETE("jobs/{id}") Call<Void> deleteJob(@Path("id") String jobID); }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/models/LanguageConfidence.java
package ai.rev.languageid.models; import com.google.gson.annotations.SerializedName; /** * Represents a predicted language and its corresponding confidences score. */ public class LanguageConfidence { /** * Language code of predicted language. */ @SerializedName("language") private String language; /** * Confidence score, between 0 and 1, for predicted language. */ @SerializedName("confidence") private Double confidence; /** * Get the language of the result. * * @return The language of the result. */ public String getLanguage() { return language; } /** * Set the language of the result. * * @param language the language to be set for the result. */ public void setLanguage(String language) { this.language = language; } /** * Get the confidence of the result. * * @return The confidence of the result. */ public Double getConfidence() { return confidence; } /** * Set the confidence of the result. * * @param confidence the confidence to be set for the result. */ public void setConfidence(Double confidence) { this.confidence = confidence; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/models/LanguageIdJob.java
package ai.rev.languageid.models; import ai.rev.speechtotext.models.asynchronous.RevAiFailureType; import ai.rev.speechtotext.models.asynchronous.RevAiJobType; import com.google.gson.annotations.SerializedName; public class LanguageIdJob { @SerializedName("id") private String jobId; @SerializedName("status") private LanguageIdJobStatus jobStatus; @SerializedName("created_on") private String createdOn; @SerializedName("completed_on") private String completedOn; @SerializedName("callback_url") private String callbackUrl; @SerializedName("metadata") private String metadata; @SerializedName("media_url") private String mediaUrl; @SerializedName("type") private RevAiJobType type; @SerializedName("failure_details") private String failureDetails; @SerializedName("failure") private RevAiFailureType failure; @SerializedName("processed_duration_seconds") private Double processedDurationSeconds; @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; /** * Returns a String that contains the job ID. * * @return A String that contains the job ID. */ public String getJobId() { return jobId; } /** * Sets the Job ID. * * @param jobId The String value to set as the job ID. */ public void setJobId(String jobId) { this.jobId = jobId; } /** * Returns the {@link LanguageIdJobStatus} enumeration value. * * @return The {@link LanguageIdJobStatus} enumeration value. * @see LanguageIdJobStatus */ public LanguageIdJobStatus getJobStatus() { return jobStatus; } /** * Sets the job status to the provided {@link LanguageIdJobStatus} enumeration value. * * @param jobStatus The enumeration value to set as the job status. * @see LanguageIdJobStatus */ public void setJobStatus(LanguageIdJobStatus jobStatus) { this.jobStatus = jobStatus; } /** * Returns a String that contains the date and time the job was created on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was created on in ISO-8601 UTC form. */ public String getCreatedOn() { return createdOn; } /** * Sets the time and date the job was created on. * * @param createdOn The String value to set as the created on date and time. */ public void setCreatedOn(String createdOn) { this.createdOn = createdOn; } /** * Returns a String that contains the date and time the job was completed on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was completed on in ISO-8601 UTC form. */ public String getCompletedOn() { return completedOn; } /** * Set the date and time the job was completed on. * * @param completedOn The String value to set as the date and time the job was completed on. */ public void setCompletedOn(String completedOn) { this.completedOn = completedOn; } /** * Returns the callback url provided in the submission request. * * @return A String containing the callback url provided in the submission request. */ public String getCallbackUrl() { return callbackUrl; } /** * Sets the callback url. * * @param callbackUrl A String value to set as the callback url. */ public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the metadata provided in the submission request. * * @return A String containing the metadata provided in the submission request. */ public String getMetadata() { return metadata; } /** * Sets the metadata. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the media url provided in the submission request. * * @return A String containing the media url provided in the submission request. */ public String getMediaUrl() { return mediaUrl; } /** * Sets the media url. * * @param mediaUrl A String value to set as the media url. */ public void setMediaUrl(String mediaUrl) { this.mediaUrl = mediaUrl; } /** * Returns the {@link RevAiJobType} enumeration value. * * @return the enumeration value. * @see RevAiJobType */ public RevAiJobType getType() { return type; } /** * Sets the job type to the provided {@link RevAiJobType} enumeration. * * @param type The enumeration value to set as the job type. * @see RevAiJobType */ public void setType(RevAiJobType type) { this.type = type; } /** * Returns a detailed, human readable explanation of the failure. * * @return A detailed, human readable explanation of the failure. */ public String getFailureDetails() { return failureDetails; } /** * Sets the failure details to the provided value. * * @param failureDetails A String to set as the failure details. */ public void setFailureDetails(String failureDetails) { this.failureDetails = failureDetails; } /** * Returns the {@link RevAiFailureType} enumeration value. * * @return The {@link RevAiFailureType} enumeration value. * @see RevAiFailureType */ public RevAiFailureType getFailure() { return failure; } /** * Sets the failure to the provided {@link RevAiFailureType} enumeration. * * @param failure The enumeration value to set as the failure. * @see RevAiFailureType */ public void setFailure(RevAiFailureType failure) { this.failure = failure; } /** * Returns the processed audio duration of the file in seconds. * * @return The processed audio duration of the file in seconds. */ public Double getProcessedDurationSeconds() { return processedDurationSeconds; } /** * Sets the processed audio duration. * * @param processedDurationSeconds A Double value to set as processed audio duration. */ public void setDurationSeconds(Double processedDurationSeconds) { this.processedDurationSeconds = processedDurationSeconds; } /** * Returns the duration in seconds before job is deleted * * @return The duration in seconds. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Sets the duration in seconds before job is deleted * * @param deleteAfterSeconds An Integer value to set as seconds before deletion. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } @Override public String toString() { return "{" + "jobID='" + jobId + '\'' + ", jobStatus=" + jobStatus + ", createdOn='" + createdOn + '\'' + ", completedOn='" + completedOn + '\'' + ", callbackUrl='" + callbackUrl + '\'' + ", metadata='" + metadata + '\'' + ", mediaUrl='" + mediaUrl + '\'' + ", type='" + type.getJobType() + '\'' + ", failureDetails='" + failureDetails + '\'' + ", failure='" + failure.getFailureType() + '\'' + ", processedDurationSeconds=" + processedDurationSeconds + '\'' + ", deleteAfterSeconds='" + deleteAfterSeconds + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/models/LanguageIdJobOptions.java
package ai.rev.languageid.models; import ai.rev.speechtotext.models.CustomerUrlData; import com.google.gson.annotations.SerializedName; import java.util.Map; /** * A LanguageIdJobOptions object represents parameters that are submitted along a new job. * * @see <a * href="https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob">https://docs.rev.ai/api/language-identification/reference/#operation/SubmitLanguageIdentificationJob</a> */ public class LanguageIdJobOptions { /** * The callback url that Rev AI will send a POST to when the job has finished. * * @deprecated Use notification_config instead */ @SerializedName("callback_url") @Deprecated private String callbackUrl; /** * Object containing information on the callback url that Rev AI will send a POST to when the job has finished. */ @SerializedName("notification_config") private CustomerUrlData notificationConfig; /** * Optional information that can be provided. */ @SerializedName("metadata") private String metadata; /** * Optional number of seconds after job completion when job is auto-deleted */ @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; /** * The media url where the file can be downloaded. * * @deprecated Use source_config instead */ @SerializedName("media_url") @Deprecated private String mediaUrl; /** * Object containing source media file information. */ @SerializedName("source_config") private CustomerUrlData sourceConfig; /** * Returns the callback url. * * @return the callback url. * @deprecated Use notificationConfig and getNotificationConfig instead */ @Deprecated public String getCallbackUrl() { return callbackUrl; } /** * Specifies the callback url that Rev AI will POST to when job processing is complete. This * property is optional. * * @param callbackUrl The url to POST to when job processing is complete. * @deprecated Use setNotificationConfig instead */ @Deprecated public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the notification config object. * * @return the notification config. */ public CustomerUrlData getNotificationConfig() { return notificationConfig; } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. * @param authHeaders Optional parameter to authenticate access to the callback url */ public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) { this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders); } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. */ public void setNotificationConfig(String callbackUrl) { setNotificationConfig(callbackUrl, null); } /** * Returns the metadata. * * @return A String that contains the metadata. */ public String getMetadata() { return metadata; } /** * Optional metadata that is provided during job submission limited to 512 characters. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the value of deleteAfterSeconds. * * @return The deleteAfterSeconds value. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Specifies the number of seconds to be waited until the job is auto-deleted after its * completion. * * @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } /** * Returns the media url. * * @return The media url. * @deprecated Set sourceConfig and use getSourceConfig instead */ @Deprecated public String getMediaUrl() { return mediaUrl; } /** * Specifies the url where the media can be downloaded. * * @param mediaUrl The direct download url to the file. * @deprecated Use setSourceConfig instead */ @Deprecated public void setMediaUrl(String mediaUrl) { this.mediaUrl = mediaUrl; } /** * Returns the source config object. * * @return the source config. */ public CustomerUrlData getSourceConfig() { return this.sourceConfig; } /** * Specifies the url and any optional auth headers to access the source media download url. * * @param sourceMediaUrl The direct download url to the file. * @param sourceAuth The auth headers to the source media download url. */ public void setSourceConfig(String sourceMediaUrl, Map<String, String> sourceAuth) { this.sourceConfig = new CustomerUrlData(sourceMediaUrl, sourceAuth); } /** * Specifies the source media download url. * * @param sourceMediaUrl The direct download url to the file. */ public void setSourceConfig(String sourceMediaUrl) { setSourceConfig(sourceMediaUrl, null); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/models/LanguageIdJobStatus.java
package ai.rev.languageid.models; import com.google.gson.annotations.SerializedName; /** * Specifies constants that define Rev AI job language id statuses. */ public enum LanguageIdJobStatus { /** * The status when job has failed. */ @SerializedName("failed") FAILED("failed"), /** * The status when job is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"), /** * The status when job processing has been completed. */ @SerializedName("completed") COMPLETED("completed"); private String status; LanguageIdJobStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/languageid/models/LanguageIdResult.java
package ai.rev.languageid.models; import java.util.List; import ai.rev.topicextraction.models.Topic; import com.google.gson.annotations.SerializedName; /** * A Language Id Result object provides all the information associated with the result of a job. */ public class LanguageIdResult { /** * Language code of the top predicted language. */ @SerializedName("top_language") private String topLanguage; /** * List of predicted languages and their confidence scores in descending order of confidence. */ @SerializedName("language_confidences") private List<LanguageConfidence> languageConfidences; /** * Get the top language of the result. * * @return The top language of the result. */ public String getTopLanguage() { return topLanguage; } /** * Set the top language of the result. * * @param topLanguage the top language to be set for the result. */ public void setTopLanguage(String topLanguage) { this.topLanguage = topLanguage; } /** * Get the language confidences of the result. * * @return The language confidences of the result. */ public List<LanguageConfidence> getLanguageConfidences() { return languageConfidences; } /** * Set the language confidences of the result; * * @param languageConfidences the list of language confidences to be set for the result. */ public void setLanguageConfidences(List<LanguageConfidence> languageConfidences) { this.languageConfidences = languageConfidences; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/SentimentAnalysisClient.java
package ai.rev.sentimentanalysis; import ai.rev.helpers.ClientHelper; import ai.rev.sentimentanalysis.models.Sentiment; import ai.rev.sentimentanalysis.models.SentimentAnalysisJob; import ai.rev.sentimentanalysis.models.SentimentAnalysisJobOptions; import ai.rev.sentimentanalysis.models.SentimentAnalysisResult; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The SentimentAnalysisClient object provides methods to send and retrieve information from all the * Rev AI Sentiment Analysis API endpoints using the Retrofit HTTP client. */ public class SentimentAnalysisClient { private OkHttpClient client; /** Interface that SentimentAnalysisClient methods use to make requests */ public SentimentAnalysisInterface apiInterface; /** * Constructs the API client used to send HTTP requests to Rev AI. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @throws IllegalArgumentException If the access token is null or empty. */ public SentimentAnalysisClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client, "sentiment_analysis", "v1"); this.apiInterface = retrofit.create(SentimentAnalysisInterface.class); } /** Manually closes the connection when the code is running in a JVM */ public void closeConnection() { client.dispatcher().executorService().shutdown(); client.connectionPool().evictAll(); } /** * This method sends a GET request to the /jobs endpoint and returns a list of {@link SentimentAnalysisJob} * objects. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @param startingAfter The job ID at which the list begins. * @return A list of {@link SentimentAnalysisJob} objects. * @throws IOException If the response has a status code > 399. * @see SentimentAnalysisJob * @see <a * href="https://docs.rev.ai/api/sentiment-analysis/reference/#operation/GetListOfSentimentAnalysisJobs">https://docs.rev.ai/api/sentiment-analysis/reference/#operation/GetListOfSentimentAnalysisJobs</a> */ public List<SentimentAnalysisJob> getListOfJobs(Integer limit, String startingAfter) throws IOException { Map<String, String> options = new HashMap<>(); if (startingAfter != null) { options.put("starting_after", startingAfter); } if (limit != null) { options.put("limit", String.valueOf(limit)); } return apiInterface.getListOfJobs(options).execute().body(); } /** * Overload of {@link SentimentAnalysisClient#getListOfJobs(Integer, String)} without the optional startingAfter * parameter. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @return A list of {@link SentimentAnalysisJob} objects. * @throws IOException If the response has a status code > 399. */ public List<SentimentAnalysisJob> getListOfJobs(Integer limit) throws IOException { return getListOfJobs(limit, null); } /** * Overload of {@link SentimentAnalysisClient#getListOfJobs(Integer, String)} without the optional limit * parameter. * * @param startingAfter The job ID at which the list begins. * @return A list of {@link SentimentAnalysisJob} objects. * @throws IOException If the response has a status code > 399. */ public List<SentimentAnalysisJob> getListOfJobs(String startingAfter) throws IOException { return getListOfJobs(null, startingAfter); } /** * Overload of {@link SentimentAnalysisClient#getListOfJobs(Integer, String)} without the optional limit and * startingAfter parameter. * * @return A list of {@link SentimentAnalysisJob} objects. * @throws IOException If the response has a status code > 399. */ public List<SentimentAnalysisJob> getListOfJobs() throws IOException { return getListOfJobs(null, null); } /** * This method sends a GET request to the /jobs/{id} endpoint and returns a {@link SentimentAnalysisJob} * object. * * @param id The ID of the job to return an object for. * @return A {@link SentimentAnalysisJob} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. */ public SentimentAnalysisJob getJobDetails(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Job ID must be provided"); } return apiInterface.getJobDetails(id).execute().body(); } /** * This method sends a DELETE request to the /jobs/{id} endpoint. * * @param id The Id of the job to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. * @see <a * href="https://docs.rev.ai/api/sentiment-analysis/reference/#operation/DeleteSentimentAnalysisJobById">https://docs.rev.ai/api/sentiment-analysis/reference/#operation/DeleteSentimentAnalysisJobById</a> */ public void deleteJob(String id) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } apiInterface.deleteJob(id).execute(); } /** * The method sends a GET request to the /jobs/{id}/result endpoint and returns a {@link * SentimentAnalysisResult} object. * * @param id The ID of the job to return a result for. * @return SentimentAnalysisResult The result object. * @throws IOException If the response has a status code > 399. * @see SentimentAnalysisResult */ public SentimentAnalysisResult getResultObject(String id, Sentiment filterFor) throws IOException { Map<String, Object> options = new HashMap<>(); options.put("filter_for", filterFor.getSentiment()); return apiInterface.getResultObject(id, options).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/result endpoint and returns a {@link * SentimentAnalysisResult} object. * * @param id The ID of the job to return a result for. * @return SentimentAnalysisResult The result object. * @throws IOException If the response has a status code > 399. * @see SentimentAnalysisResult */ public SentimentAnalysisResult getResultObject(String id) throws IOException { Map<String, Object> options = new HashMap<>(); return apiInterface.getResultObject(id, options).execute().body(); } /** * The method sends a POST request to the /jobs endpoint, starts a sentiment analysis job for the * provided text and returns a {@link SentimentAnalysisJob} object. * * @param text Text to have sentiments detected on it. * @param options The sentiment analysis options associated with this job. * @return SentimentAnalysisJob A representation of the sentiment analysis job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the text is null. * @see SentimentAnalysisJob * @see <a * href="https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob">https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob</a> */ public SentimentAnalysisJob submitJobText(String text, SentimentAnalysisJobOptions options) throws IOException { if (text == null) { throw new IllegalArgumentException("Text must be provided"); } if (options == null) { options = new SentimentAnalysisJobOptions(); } options.setText(text); return apiInterface.submitJob(options).execute().body(); } /** * An overload of {@link SentimentAnalysisClient#submitJobText(String, SentimentAnalysisJobOptions)} without the additional * sentiment analysis options. * * @param text Text to have sentiments detected on it. * @return SentimentAnalysisJob A representation of the sentiment analysis job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the text is null. * @see SentimentAnalysisJob * @see SentimentAnalysisClient#submitJobText(String, SentimentAnalysisJobOptions) */ public SentimentAnalysisJob submitJobText(String text) throws IOException { return submitJobText(text, null); } /** * The method sends a POST request to the /jobs endpoint, starts a sentiment analysis job for the * provided RevAiTranscript and returns a {@link SentimentAnalysisJob} object. * * @param json RevAiTranscript to submit for sentiment analysis * @param options The sentiment analysis options associated with this job. * @return SentimentAnalysisJob A representation of the sentiment analysis job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the json is null. * @see SentimentAnalysisJob * @see <a * href="https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob">https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob</a> */ public SentimentAnalysisJob submitJobJson(RevAiTranscript json, SentimentAnalysisJobOptions options) throws IOException { if (json == null) { throw new IllegalArgumentException("Json must be provided"); } if (options == null) { options = new SentimentAnalysisJobOptions(); } options.setJson(json); return apiInterface.submitJob(options).execute().body(); } /** * An overload of {@link SentimentAnalysisClient#submitJobText(String, SentimentAnalysisJobOptions)} without the additional * sentiment analysis options. * * @param json RevAiTranscript to submit for sentiment analysis * @return SentimentAnalysisJob A representation of the sentiment analysis job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the json is null. * @see SentimentAnalysisJob * @see SentimentAnalysisClient#submitJobJson(RevAiTranscript, SentimentAnalysisJobOptions) */ public SentimentAnalysisJob submitJobJson(RevAiTranscript json) throws IOException { return submitJobJson(json, null); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/SentimentAnalysisInterface.java
package ai.rev.sentimentanalysis; import ai.rev.sentimentanalysis.models.SentimentAnalysisJob; import ai.rev.sentimentanalysis.models.SentimentAnalysisJobOptions; import ai.rev.sentimentanalysis.models.SentimentAnalysisResult; import okhttp3.MultipartBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.HeaderMap; import retrofit2.http.Headers; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.QueryMap; import java.util.List; import java.util.Map; /** * The SentimentAnalysisInterface is a type-safe Retrofit interface that presents all the endpoints that are made * to communicate with the Rev AI Sentiment Analysis API. */ public interface SentimentAnalysisInterface { String REV_SENTIMENT_CONTENT_TYPE = "application/vnd.rev.sentiment.v1.0+json"; @GET("jobs/{id}") Call<SentimentAnalysisJob> getJobDetails(@Path("id") String jobID); @GET("jobs") Call<List<SentimentAnalysisJob>> getListOfJobs(@QueryMap Map<String, String> options); @Headers("Accept: " + REV_SENTIMENT_CONTENT_TYPE) @GET("jobs/{id}/result") Call<SentimentAnalysisResult> getResultObject(@Path("id") String jobID, @QueryMap Map<String, Object> options); @POST("jobs") Call<SentimentAnalysisJob> submitJob(@Body SentimentAnalysisJobOptions options); @DELETE("jobs/{id}") Call<Void> deleteJob(@Path("id") String jobID); }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/models/Sentiment.java
package ai.rev.sentimentanalysis.models; import com.google.gson.annotations.SerializedName; /** Specifies constants that define possible sentiments from our API. */ public enum Sentiment { /** Positive sentiment. */ @SerializedName("positive") POSITIVE("positive"), /** Neutral sentiment. */ @SerializedName("neutral") NEUTRAL("neutral"), /** Negative sentiment. */ @SerializedName("negative") NEGATIVE("negative"); private String sentiment; Sentiment(String sentiment) { this.sentiment = sentiment; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getSentiment() { return sentiment; } @Override public String toString() { return "{" + "sentiment='" + sentiment + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/models/SentimentAnalysisJob.java
package ai.rev.sentimentanalysis.models; import ai.rev.speechtotext.models.asynchronous.RevAiJobType; import ai.rev.speechtotext.models.asynchronous.RevAiFailureType; import java.util.List; import com.google.gson.annotations.SerializedName; /** A Sentiment Analysis Job object provides all the information associated with a job submitted by the user. */ public class SentimentAnalysisJob { @SerializedName("id") private String jobId; @SerializedName("status") private SentimentAnalysisJobStatus jobStatus; @SerializedName("created_on") private String createdOn; @SerializedName("completed_on") private String completedOn; @SerializedName("callback_url") private String callbackUrl; @SerializedName("word_count") private Integer wordCount; @SerializedName("metadata") private String metadata; @SerializedName("type") private RevAiJobType type; @SerializedName("failure_details") private String failureDetails; @SerializedName("failure") private RevAiFailureType failure; @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; @SerializedName("language") private String language; /** * Returns a String that contains the job ID. * * @return A String that contains the job ID. */ public String getJobId() { return jobId; } /** * Sets the Job ID. * * @param jobId The String value to set as the job ID. */ public void setJobId(String jobId) { this.jobId = jobId; } /** * Returns the {@link SentimentAnalysisJobStatus} enumeration value. * * @return The {@link SentimentAnalysisJobStatus} enumeration value. * @see SentimentAnalysisJobStatus */ public SentimentAnalysisJobStatus getJobStatus() { return jobStatus; } /** * Sets the job status to the provided {@link SentimentAnalysisJobStatus} enumeration value. * * @param jobStatus The enumeration value to set as the job status. * @see SentimentAnalysisJobStatus */ public void setJobStatus(SentimentAnalysisJobStatus jobStatus) { this.jobStatus = jobStatus; } /** * Returns a String that contains the date and time the job was created on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was created on in ISO-8601 UTC form. */ public String getCreatedOn() { return createdOn; } /** * Sets the time and date the job was created on. * * @param createdOn The String value to set as the created on date and time. */ public void setCreatedOn(String createdOn) { this.createdOn = createdOn; } /** * Returns a String that contains the date and time the job was completed on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was completed on in ISO-8601 UTC form. */ public String getCompletedOn() { return completedOn; } /** * Set the date and time the job was completed on. * * @param completedOn The String value to set as the date and time the job was completed on. */ public void setCompletedOn(String completedOn) { this.completedOn = completedOn; } /** * Returns the callback url provided in the submission request. * * @return A String containing the callback url provided in the submission request. */ public String getCallbackUrl() { return callbackUrl; } /** * Sets the callback url. * * @param callbackUrl A String value to set as the callback url. */ public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the word count of the submission. * * @return A String containing the word count of the submission. */ public Integer getWordCount() { return wordCount; } /** * Sets the word count. * * @param wordCount An Integer value to set as the word count. */ public void setWordCount(Integer wordCount) { this.wordCount = wordCount; } /** * Returns the metadata provided in the submission request. * * @return A String containing the metadata provided in the submission request. */ public String getMetadata() { return metadata; } /** * Sets the metadata. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the {@link RevAiJobType} enumeration value. * * @return the enumeration value. * @see RevAiJobType */ public RevAiJobType getType() { return type; } /** * Sets the job type to the provided {@link RevAiJobType} enumeration. * * @param type The enumeration value to set as the job type. * @see RevAiJobType */ public void setType(RevAiJobType type) { this.type = type; } /** * Returns a detailed, human readable explanation of the failure. * * @return A detailed, human readable explanation of the failure. */ public String getFailureDetails() { return failureDetails; } /** * Sets the failure details to the provided value. * * @param failureDetails A String to set as the failure details. */ public void setFailureDetails(String failureDetails) { this.failureDetails = failureDetails; } /** * Returns the {@link RevAiFailureType} enumeration value. * * @return The {@link RevAiFailureType} enumeration value. * @see RevAiFailureType */ public RevAiFailureType getFailure() { return failure; } /** * Sets the failure to the provided {@link RevAiFailureType} enumeration. * * @param failure The enumeration value to set as the failure. * @see RevAiFailureType */ public void setFailure(RevAiFailureType failure) { this.failure = failure; } /** * Returns the duration in seconds before job is deleted * * @return The duration in seconds. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Sets the duration in seconds before job is deleted * * @param deleteAfterSeconds An Integer value to set as seconds before deletion. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } /** * Returns language of the job * * @return language of the job */ public String getLanguage() { return language; } /** * Sets the language for job * * @param language An String value to set for language */ public void setLanguage(String language) { this.language = language; } @Override public String toString() { return "{" + "jobID='" + jobId + '\'' + ", jobStatus=" + jobStatus + ", createdOn='" + createdOn + '\'' + ", completedOn='" + completedOn + '\'' + ", callbackUrl='" + callbackUrl + '\'' + ", wordCount='" + wordCount + '\'' + ", metadata='" + metadata + '\'' + ", type='" + type.getJobType() + '\'' + ", failureDetails='" + failureDetails + '\'' + ", failure='" + failure.getFailureType() + '\'' + ", language='" + language + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/models/SentimentAnalysisJobOptions.java
package ai.rev.sentimentanalysis.models; import ai.rev.speechtotext.models.CustomerUrlData; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import com.google.gson.annotations.SerializedName; import java.util.Map; /** * A SentimentAnalysisJobOptions object represents parameters that are submitted along a new job. * * @see <a * href="https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob">https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob</a> */ public class SentimentAnalysisJobOptions { /** * Plain text string to be sentiment analyzed. */ @SerializedName("text") private String text; /** * RevAiTranscript from an async speech to text job to be sentiment analyzed. */ @SerializedName("json") private RevAiTranscript json; /** * The callback url that Rev AI will send a POST to when the job has finished. * @deprecated Use notification_config instead */ @SerializedName("callback_url") @Deprecated private String callbackUrl; /** Object containing information on the callback url that Rev AI will send a POST to when the job has finished. */ @SerializedName("notification_config") private CustomerUrlData notificationConfig; /** * Optional information that can be provided. */ @SerializedName("metadata") private String metadata; /** * Optional number of seconds after job completion when job is auto-deleted. */ @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; /** * Returns the text. * * @return the text. */ public String getText() { return text; } /** * Specifies plain text that will have sentiment analysis run on it. * * @param text plain text to be sentiment analyzed. */ public void setText(String text) { this.text = text; } /** * Returns the json. * * @return the json. */ public RevAiTranscript getJson() { return json; } /** * Specifies a RevAiTranscript from the async api that will have sentiment analysis run on it * * @param json RevAiTranscript to be sentiment analyzed. */ public void setJson(RevAiTranscript json) { this.json = json; } /** * Returns the callback url. * * @return the callback url. * @deprecated Use notificationConfig and getNotificationConfig instead */ @Deprecated public String getCallbackUrl() { return callbackUrl; } /** * Specifies the callback url that Rev AI will POST to when job processing is complete. This * property is optional. * * @param callbackUrl The url to POST to when job processing is complete. * @deprecated Use setNotificationConfig instead */ @Deprecated public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the notification config object. * * @return the notification config. */ public CustomerUrlData getNotificationConfig() { return notificationConfig; } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. * @param authHeaders Optional parameter to authenticate access to the callback url */ public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) { this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders); } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. */ public void setNotificationConfig(String callbackUrl) { setNotificationConfig(callbackUrl, null); } /** * Returns the metadata. * * @return A String that contains the metadata. */ public String getMetadata() { return metadata; } /** * Optional metadata that is provided during job submission limited to 512 characters. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the value of deleteAfterSeconds. * * @return The deleteAfterSeconds value. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Specifies the number of seconds to be waited until the job is auto-deleted after its * completion. * * @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/models/SentimentAnalysisJobStatus.java
package ai.rev.sentimentanalysis.models; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Rev AI job statuses. */ public enum SentimentAnalysisJobStatus { /** The status when job has failed. */ @SerializedName("failed") FAILED("failed"), /** The status when job is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"), /** The status when job processing has been completed. */ @SerializedName("completed") COMPLETED("completed"); private String status; SentimentAnalysisJobStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/models/SentimentAnalysisResult.java
package ai.rev.sentimentanalysis.models; import java.util.List; import com.google.gson.annotations.SerializedName; /** A Sentiment Analysis Result object provides all the information associated with the result of a job. */ public class SentimentAnalysisResult { /** * Messages from the input text, ordered by appearance in the input. * Each part of the input will be represented in one of the messages */ @SerializedName("messages") private List<SentimentMessage> messages; /** * Get the messages of the result. * * @return The messages of the result */ public List<SentimentMessage> getMessages() { return messages; } /** * Set the messages of the result. * * @param messages the messages to be set for the result. */ public void setMessages(List<SentimentMessage> messages) { this.messages = messages; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/sentimentanalysis/models/SentimentMessage.java
package ai.rev.sentimentanalysis.models; import com.google.gson.annotations.SerializedName; /** * Represents a piece of the input which sentiment has been detected for. */ public class SentimentMessage { /** * Content of the input that makes up the message. */ @SerializedName("content") private String content; /** * Detected sentiment of the content. */ @SerializedName("sentiment") private Sentiment sentiment; /** * Score of the content. Lower score indicates a more negative sentiment * while a higher score indicates a more positive sentiment. Ranges -1 to 1. */ @SerializedName("score") private Double score; /** * Start timestamp of the content in the input if available. */ @SerializedName("ts") private Double startTimestamp; /** * End timestamp of the content in the input if available. */ @SerializedName("end_ts") private Double endTimestamp; /** * Character index at which the content started in the source transcript, * excludes invisible characters. */ @SerializedName("offset") private Integer offset; /** * Length of the content in characters, excludes invisible characters. */ @SerializedName("length") private Integer length; /** * Returns the content of the informant. * * @return the content of the informant. */ public String getContent() { return content; } /** * Sets the content of the informant. * * @param content content to be set. */ public void setContent(String content) { this.content = content; } /** * Returns the Sentiment of the informant. * * @return the Sentiment of the informant. */ public Sentiment getSentiment() { return sentiment; } /** * Sets the Sentiment of the informant. * * @param sentiment sentiment to be set. */ public void setSentiment(Sentiment sentiment) { this.sentiment = sentiment; } /** * Returns the score of the content. * * @return the score of the content. */ public Double getScore() { return score; } /** * Sets the score of the content. * * @param score the score of the content. */ public void setScore(Double score) { this.score = score; } /** * Returns the start timestamp of the content in the input. * * @return the start timestamp of the content in the input. */ public Double getStartTimestamp() { return startTimestamp; } /** * Sets the start timestamp of the content in the input. * * @param startTimestamp the start timestamp to be set. */ public void setStartTimestamp(Double startTimestamp) { this.startTimestamp = startTimestamp; } /** * Returns the end timestamp of the content in the input. * * @return the end timestamp of the content in the input. */ public Double getEndTimestamp() { return endTimestamp; } /** * Sets the end timestamp of the content in the input. * * @param endTimestamp the end timestamp to be set. */ public void setEndTimestamp(Double endTimestamp) { this.endTimestamp = endTimestamp; } /** * Returns the character index at which the content started in the input. * * @return the character index at which the content started in the input. */ public Integer getOffset() { return offset; } /** * Sets the character index at which the content started in the input * * @param offset the character index to be set */ public void setOffset(Integer offset) { this.offset = offset; } /** * Returns the character length of the content * * @return the character length of the content */ public Integer getLength() { return length; } /** * Sets the character length of the content * * @param length the character length to be set */ public void setLength(Integer length) { this.length = length; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/ApiClient.java
package ai.rev.speechtotext; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import ai.rev.helpers.ClientHelper; import ai.rev.helpers.RevAiApiDeploymentConfiguration; import ai.rev.speechtotext.models.asynchronous.RevAiAccount; import ai.rev.speechtotext.models.asynchronous.RevAiCaptionType; import ai.rev.speechtotext.models.asynchronous.RevAiJob; import ai.rev.speechtotext.models.asynchronous.RevAiJobOptions; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import ai.rev.speechtotext.models.asynchronous.Summary; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.RequestBody; import retrofit2.Retrofit; /** * The ApiClient object provides methods to send and retrieve information from all the Rev AI API * endpoints using the Retrofit HTTP client. */ public class ApiClient { private OkHttpClient client; /** Interface that ApiClient methods use to make requests */ public ApiInterface apiInterface; /** * Constructs the API client used to send HTTP requests to Rev AI. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @param baseUrl Optional url of the Rev AI API deployment to use, defaults to the US deployement, i.e. 'https://api.rev.ai', which can be referenced as RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl(). * @throws IllegalArgumentException If the access token is null or empty. */ public ApiClient(String accessToken, String baseUrl) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance( client, "speechtotext", "v1", baseUrl != null ? baseUrl : RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl() ); this.apiInterface = retrofit.create(ApiInterface.class); } /** * Constructs the API client used to send HTTP requests to Rev AI. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @param baseUrl Optional url of the Rev AI API deployment to use, defaults to the US deployement, i.e. 'https://api.rev.ai', which can be referenced as RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl(). * @throws IllegalArgumentException If the access token is null or empty. */ public ApiClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client, "speechtotext", "v1"); this.apiInterface = retrofit.create(ApiInterface.class); } /** Manually closes the connection when the code is running in a JVM */ public void closeConnection() { client.dispatcher().executorService().shutdown(); client.connectionPool().evictAll(); } /** * This method sends a GET request to the /account endpoint and returns an {@link RevAiAccount} * object. * * @return RevAiAccount The object containing basic Rev AI account information * @throws IOException If the response has a status code > 399. * @see RevAiAccount */ public RevAiAccount getAccount() throws IOException { return apiInterface.getAccount().execute().body(); } /** * This method sends a GET request to the /jobs endpoint and returns a list of {@link RevAiJob} * objects. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @param startingAfter The job ID at which the list begins. * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetListOfJobs">https://docs.rev.ai/api/asynchronous/reference/#operation/GetListOfJobs</a> */ public List<RevAiJob> getListOfJobs(Integer limit, String startingAfter) throws IOException { Map<String, String> options = new HashMap<>(); if (startingAfter != null) { options.put("starting_after", startingAfter); } if (limit != null) { options.put("limit", String.valueOf(limit)); } return apiInterface.getListOfJobs(options).execute().body(); } /** * Overload of {@link ApiClient#getListOfJobs(Integer, String)} without the optional startingAfter * parameter. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. */ public List<RevAiJob> getListOfJobs(Integer limit) throws IOException { return getListOfJobs(limit, null); } /** * Overload of {@link ApiClient#getListOfJobs(Integer, String)} without the optional limit * parameter. * * @param startingAfter The job ID at which the list begins. * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. */ public List<RevAiJob> getListOfJobs(String startingAfter) throws IOException { return getListOfJobs(null, startingAfter); } /** * Overload of {@link ApiClient#getListOfJobs(Integer, String)} without the optional limit and * startingAfter parameter. * * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. */ public List<RevAiJob> getListOfJobs() throws IOException { return getListOfJobs(null, null); } /** * This method sends a GET request to the /jobs/{id} endpoint and returns a {@link RevAiJob} * object. * * @param id The ID of the job to return an object for. * @return A {@link RevAiJob} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. */ public RevAiJob getJobDetails(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Job ID must be provided"); } return apiInterface.getJobDetails(id).execute().body(); } /** * This method sends a DELETE request to the /jobs/{id} endpoint. * * @param id The Id of the job to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/DeleteJobById">https://docs.rev.ai/api/asynchronous/reference/#operation/DeleteJobById</a> */ public void deleteJob(String id) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } apiInterface.deleteJob(id).execute(); } /** * The method sends a GET request to the /jobs/{id}/transcript endpoint and returns a {@link * RevAiTranscript} object. * * @param id The ID of the job to return a transcript for. * @return RevAiTranscript The transcript object. * @throws IOException If the response has a status code > 399. * @see RevAiTranscript */ public RevAiTranscript getTranscriptObject(String id) throws IOException { return apiInterface.getTranscriptObject(id).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/transcript/translation/{language} endpoint and returns translated transcript * as a String. * * @param id The ID of the job to return a transcript for. * @param language requested transcript language. * @return The transcript as a String in text format. * @throws IOException If the response has a status code > 399. */ public String getTranslatedTranscriptText(String id,String language) throws IOException { return apiInterface.getTranslatedTranscriptText(id,language).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/transcript/translation/{language} endpoint and returns a {@link * RevAiTranscript} object containing translated transcript. * * @param id The ID of the job to return a transcript for. * @param language requested transcript language. * @return RevAiTranscript The transcript object. * @throws IOException If the response has a status code > 399. * @see RevAiTranscript */ public RevAiTranscript getTranslatedTranscriptObject(String id, String language) throws IOException { return apiInterface.getTranslatedTranscriptObject(id,language).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/transcript endpoint and returns the transcript * as a String. * * @param id The ID of the job to return a transcript for. * @return The transcript as a String in text format. * @throws IOException If the response has a status code > 399. */ public String getTranscriptText(String id) throws IOException { return apiInterface.getTranscriptText(id).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/transcript/summary endpoint and returns the transcript summary * as a String. * * @param id The ID of the job to return a transcript summary for. * @return The transcript summary as a String in text format. * @throws IOException If the response has a status code > 399. */ public String getTranscriptSummaryText(String id) throws IOException { return apiInterface.getTranscriptSummaryText(id).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/transcript/summary endpoint and returns the transcript summary * as a {@link Summary} object. * * @param id The ID of the job to return a transcript summary for. * @return The transcript summary as a String in text format. * @throws IOException If the response has a status code > 399. */ public Summary getTranscriptSummaryObject(String id) throws IOException { return apiInterface.getTranscriptSummaryObject(id).execute().body(); } /** * Sends a POST request to the /jobs endpoint, starts an asynchronous job to transcribe * the media file located at the url provided and returns a {@link RevAiJob} object. * * @deprecated Use submitJobUrl with the sourceConfig job option rather than a separate mediaUrl argument * @param mediaUrl A direct download link to the media. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the media url is null. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ @Deprecated public RevAiJob submitJobUrl(String mediaUrl, RevAiJobOptions options) throws IOException { if (mediaUrl == null) { throw new IllegalArgumentException("Media url must be provided"); } if (options == null) { options = new RevAiJobOptions(); } options.setMediaUrl(mediaUrl); return apiInterface.submitJobUrl(options).execute().body(); } /** * An overload of {@link ApiClient#submitJobUrl(String, RevAiJobOptions)} without the additional * transcription options. * * @param mediaUrl A direct download link to the media. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see ApiClient#submitJobUrl(String, RevAiJobOptions) */ public RevAiJob submitJobUrl(String mediaUrl) throws IOException { RevAiJobOptions options = new RevAiJobOptions(); options.setSourceConfig(mediaUrl); return submitJobUrl(options); } /** * Sends a POST request to the /jobs endpoint, starts an asynchronous job to transcribe * the media file located at the url provided, and returns a {@link RevAiJob} object. * * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobUrl(RevAiJobOptions options) throws IOException { return apiInterface.submitJobUrl(options).execute().body(); } /** * The method sends multipart/form request to the /jobs endpoint, starts an asynchronous job to * transcribe the local media file provided and returns a {@link RevAiJob} object. * * @param filePath A local path to the file on the computer. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the file path is null. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(String filePath, RevAiJobOptions options) throws IOException { if (filePath == null) { throw new IllegalArgumentException("File path must be provided"); } if (options == null) { options = new RevAiJobOptions(); } File file = new File(filePath); return submitMultipartRequest( new FileInputStream(file.getAbsoluteFile()), file.getName(), options); } /** * An overload of {@link ApiClient#submitJobLocalFile(String, RevAiJobOptions)} without the * additional transcription options. * * @param filePath A local path to the file on the computer. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see ApiClient#submitJobLocalFile(String, RevAiJobOptions) */ public RevAiJob submitJobLocalFile(String filePath) throws IOException { return submitJobLocalFile(filePath, null); } /** * The method sends a POST request to the /jobs endpoint, starts an asynchronous job to transcribe * the media file provided by InputStream and returns a {@link RevAiJob} object. * * @param inputStream An InputStream of the media file. * @param fileName The name of the file being streamed. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the InputStream provided is null. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile( InputStream inputStream, String fileName, RevAiJobOptions options) throws IOException { if (inputStream == null) { throw new IllegalArgumentException("File stream must be provided"); } if (options == null) { options = new RevAiJobOptions(); } if (fileName == null) { fileName = "audio_file"; } return submitMultipartRequest(inputStream, fileName, options); } /** * An overload of {@link ApiClient#submitJobLocalFile(InputStream, String, RevAiJobOptions)} * without the optional filename and transcription options. * * @param inputStream An InputStream of the media file. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(InputStream inputStream) throws IOException { return submitJobLocalFile(inputStream, null, null); } /** * An overload of {@link ApiClient#submitJobLocalFile(InputStream, String, RevAiJobOptions)} * without the additional transcription options. * * @param inputStream An InputStream of the media file. * @param fileName The name of the file being streamed. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(InputStream inputStream, String fileName) throws IOException { return submitJobLocalFile(inputStream, fileName, null); } /** * An overload of {@link ApiClient#submitJobLocalFile(InputStream, String, RevAiJobOptions)} * without the optional filename. * * @param inputStream An InputStream of the media file. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(InputStream inputStream, RevAiJobOptions options) throws IOException { return submitJobLocalFile(inputStream, null, options); } /** * The method sends a GET request to the /jobs/{id}/captions endpoint and returns captions for the * provided job ID in the form of an {@link InputStream}. * * @param id The ID of the job to return captions for. * @param captionType An enumeration of the desired caption type. Default is SRT. * @param channelId Identifies the audio channel of the file to output captions for. Default is * null. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions">https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions</a> */ public InputStream getCaptions(String id, RevAiCaptionType captionType, Integer channelId) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } Map<String, String> query = new HashMap<>(); if (channelId != null) { query.put("speaker_channel", channelId.toString()); } if (captionType == null) { captionType = RevAiCaptionType.SRT; } Map<String, String> contentHeader = new HashMap<>(); contentHeader.put("Accept", captionType.getContentType()); return apiInterface.getCaptionText(id, query, contentHeader).execute().body().byteStream(); } /** * The method sends a GET request to the /jobs/{id}/captions/translation/{language} endpoint and returns translated captions for the * provided job ID in the form of an {@link InputStream}. * * @param id The ID of the job to return captions for. * @param language requested translation language. * @param captionType An enumeration of the desired caption type. Default is SRT. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions">https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions</a> */ public InputStream getTranslatedCaptions(String id, String language, RevAiCaptionType captionType) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } Map<String, String> query = new HashMap<>(); if (captionType == null) { captionType = RevAiCaptionType.SRT; } Map<String, String> contentHeader = new HashMap<>(); contentHeader.put("Accept", captionType.getContentType()); return apiInterface.getTranslatedCaptionText(id, language, query, contentHeader).execute().body().byteStream(); } /** * An overload of {@link ApiClient#getCaptions(String, RevAiCaptionType, Integer)} without the * optional channel ID. * * @param id The ID of the job to return captions for. * @param captionType An enumeration of the desired caption type. Default is SRT * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions">https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions</a> */ public InputStream getCaptions(String id, RevAiCaptionType captionType) throws IOException { return getCaptions(id, captionType, null); } /** * An overload of {@link ApiClient#getCaptions(String, RevAiCaptionType, Integer)} without the * optional caption type. * * @param id The ID of the job to return captions for. * @param channelId Identifies the audio channel of the file to output captions for. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions">https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions</a> */ public InputStream getCaptions(String id, Integer channelId) throws IOException { return getCaptions(id, null, channelId); } /** * An overload of {@link ApiClient#getCaptions(String, RevAiCaptionType, Integer)} without the * optional caption type and channel ID. * * @param id The ID of the job to return captions for. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions">https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions</a> */ public InputStream getCaptions(String id) throws IOException { return getCaptions(id, null, null); } private RevAiJob submitMultipartRequest( InputStream inputStream, String fileName, RevAiJobOptions options) throws IOException { RequestBody fileRequest = FileStreamRequestBody.create(inputStream, MediaType.parse("audio/*")); MultipartBody.Part filePart = MultipartBody.Part.createFormData("media", fileName, fileRequest); return apiInterface.submitJobLocalFile(filePart, options).execute().body(); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/ApiInterface.java
package ai.rev.speechtotext; import ai.rev.speechtotext.models.asynchronous.*; import okhttp3.MultipartBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.HeaderMap; import retrofit2.http.Headers; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.QueryMap; import java.util.List; import java.util.Map; /** * The ApiInterface is a type-safe Retrofit interface that presents all the endpoints that are made * to communicate with the Rev AI async API. */ public interface ApiInterface { String REV_JSON_CONTENT_TYPE = "application/vnd.rev.transcript.v1.0+json"; String REV_TEXT_CONTENT_TYPE = "text/plain"; @GET("account") Call<RevAiAccount> getAccount(); @GET("jobs/{id}") Call<RevAiJob> getJobDetails(@Path("id") String jobID); @GET("jobs") Call<List<RevAiJob>> getListOfJobs(@QueryMap Map<String, String> options); @Headers("Accept: " + REV_JSON_CONTENT_TYPE) @GET("jobs/{id}/transcript") Call<RevAiTranscript> getTranscriptObject(@Path("id") String jobID); @Headers("Accept: " + REV_TEXT_CONTENT_TYPE) @GET("jobs/{id}/transcript") Call<String> getTranscriptText(@Path("id") String jobID); @Headers("Accept: " + REV_JSON_CONTENT_TYPE) @GET("jobs/{id}/transcript/translation/{language}") Call<RevAiTranscript> getTranslatedTranscriptObject(@Path("id") String jobID, @Path("language") String language); @Headers("Accept: " + REV_TEXT_CONTENT_TYPE) @GET("jobs/{id}/transcript/translation/{language}") Call<String> getTranslatedTranscriptText(@Path("id") String jobID, @Path("language") String language); @Headers("Accept: " + REV_TEXT_CONTENT_TYPE) @GET("jobs/{id}/transcript/summary") Call<String> getTranscriptSummaryText(@Path("id") String jobID); @Headers("Accept: application/json") @GET("jobs/{id}/transcript/summary") Call<Summary> getTranscriptSummaryObject(@Path("id") String jobID); @POST("jobs") Call<RevAiJob> submitJobUrl(@Body RevAiJobOptions options); @DELETE("jobs/{id}") Call<Void> deleteJob(@Path("id") String jobID); @Multipart @POST("jobs") Call<RevAiJob> submitJobLocalFile( @Part MultipartBody.Part file, @Part("options") RevAiJobOptions options); @GET("jobs/{id}/captions") Call<ResponseBody> getCaptionText( @Path("id") String jobID, @QueryMap Map<String, String> query, @HeaderMap Map<String, String> contentType); @GET("jobs/{id}/captions/translation/{language}") Call<ResponseBody> getTranslatedCaptionText( @Path("id") String jobID, @Path("language") String language, @QueryMap Map<String, String> query, @HeaderMap Map<String, String> contentType); }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/CustomVocabulariesClient.java
package ai.rev.speechtotext; import ai.rev.helpers.ClientHelper; import ai.rev.speechtotext.models.vocabulary.CustomVocabularyInformation; import ai.rev.speechtotext.models.vocabulary.CustomVocabularySubmission; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import java.io.IOException; import java.util.List; /** * The CustomVocabularyClient object provides methods to interact with the Custom Vocabulary Api. */ public class CustomVocabulariesClient { private OkHttpClient client; /** Interface that CustomVocabularyClient methods use to make requests */ public CustomVocabularyApiInterface customVocabularyApiInterface; /** * Constructs the custom vocabulary client used to create custom vocabularies for streaming. The * user access token can be generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @throws IllegalArgumentException If the access token is null or empty. */ public CustomVocabulariesClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client, "speechtotext", "v1"); this.customVocabularyApiInterface = retrofit.create(CustomVocabularyApiInterface.class); } /** * This method makes a POST request to the /vocabularies endpoint and returns a {@link * CustomVocabularyInformation} object that provides details about the custom vocabulary * submission and its progress. * * @param submission An object that contains the custom vocabularies and optional parameters * @return A {@link CustomVocabularyInformation} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the list of custom vocabularies is null or empty. * @see CustomVocabularyInformation */ public CustomVocabularyInformation submitCustomVocabularies(CustomVocabularySubmission submission) throws IOException { if (submission.getCustomVocabularies() == null || submission.getCustomVocabularies().isEmpty()) { throw new IllegalArgumentException("Custom vocabularies must be provided"); } return customVocabularyApiInterface.submitCustomVocabularies(submission).execute().body(); } /** * This method sends a GET request to the /vocabularies endpoint and returns a list of {@link * CustomVocabularyInformation} objects. * * @return A list of {@link CustomVocabularyInformation} objects. * @throws IOException If the response has a status code > 399. * @see CustomVocabularyInformation */ public List<CustomVocabularyInformation> getListOfCustomVocabularyInformation() throws IOException { return customVocabularyApiInterface.getListOfCustomVocabularyInformation().execute().body(); } /** * This method sends a GET request to the /vocabularies/{id} endpoint and returns a {@link * CustomVocabularyInformation} object. * * @param id The Id of the custom vocabulary to return an object for. * @return A {@link CustomVocabularyInformation} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the custom vocabulary Id is null. * @see CustomVocabularyInformation */ public CustomVocabularyInformation getCustomVocabularyInformation(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Custom vocabulary Id must be provided"); } return customVocabularyApiInterface.getCustomVocabularyInformation(id).execute().body(); } /** * This method sends a DELETE request to the /vocabularies/{id} endpoint. * * @param id The Id of the custom vocabulary to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job Id is null. * @see <a * href="https://docs.rev.ai/api/custom-vocabulary/reference/#operation/DeleteCustomVocabulary">https://docs.rev.ai/api/custom-vocabulary/reference/#operation/DeleteCustomVocabulary</a> */ public void deleteCustomVocabulary(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Custom vocabulary Id must be provided"); } customVocabularyApiInterface.deleteCustomVocabulary(id).execute().body(); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/CustomVocabularyApiInterface.java
package ai.rev.speechtotext; import ai.rev.speechtotext.models.vocabulary.CustomVocabularyInformation; import ai.rev.speechtotext.models.vocabulary.CustomVocabularySubmission; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import java.util.List; /** * The CustomVocabularyApiInterface is a type-safe Retrofit interface that presents all the * endpoints that are made to communicate with the Rev AI custom vocabulary API. */ public interface CustomVocabularyApiInterface { @POST("vocabularies") Call<CustomVocabularyInformation> submitCustomVocabularies( @Body CustomVocabularySubmission options); @GET("vocabularies") Call<List<CustomVocabularyInformation>> getListOfCustomVocabularyInformation(); @GET("vocabularies/{id}") Call<CustomVocabularyInformation> getCustomVocabularyInformation(@Path("id") String jobId); @DELETE("vocabularies/{id}") Call<Void> deleteCustomVocabulary(@Path("id") String jobId); }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/FileStreamRequestBody.java
package ai.rev.speechtotext; import okhttp3.MediaType; import okhttp3.RequestBody; import okhttp3.internal.Util; import okio.BufferedSink; import okio.Okio; import okio.Source; import java.io.IOException; import java.io.InputStream; /** Customized request body used for submitting local file jobs. */ public class FileStreamRequestBody { public static RequestBody create(final InputStream inputStream, final MediaType mediaType) { return new RequestBody() { @Override public MediaType contentType() { return mediaType; } @Override public void writeTo(BufferedSink sink) throws IOException { Source source = null; try { source = Okio.source(inputStream); sink.writeAll(source); } finally { Util.closeQuietly(source); } } }; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/RevAiWebSocketListener.java
package ai.rev.speechtotext; import ai.rev.speechtotext.models.streaming.ConnectedMessage; import ai.rev.speechtotext.models.streaming.Hypothesis; import okhttp3.Response; /** Listens for events over the WebSocket connection to Rev AI */ public interface RevAiWebSocketListener { /** * Supplies the connection message received from Rev AI. * * @param message a String in JSON format that contains the message type and job ID. * @see <a * href="https://docs.rev.ai/api/streaming/responses/">https://docs.rev.ai/api/streaming/responses/</a */ void onConnected(ConnectedMessage message); /** * Supplies the Hypothesis returned from Rev AI. * * @param hypothesis the partial or final hypothesis of the audio. * @see Hypothesis */ void onHypothesis(Hypothesis hypothesis); /** * Supplies the error and response received during a WebSocket ErrorEvent. * * @param t the error thrown. * @param response the WebSocket response to the error. */ void onError(Throwable t, Response response); /** * Supplies the close code and close reason received during a WebSocket CloseEvent. * * @param code the close code. * @param reason the close reason. */ void onClose(int code, String reason); /** * Supplies the response received during the handshake. * * @param response the handshake response. */ void onOpen(Response response); }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/StreamingClient.java
package ai.rev.speechtotext; import ai.rev.helpers.SDKHelper; import ai.rev.helpers.ApiInterceptor; import ai.rev.helpers.ErrorInterceptor; import ai.rev.speechtotext.models.streaming.ConnectedMessage; import ai.rev.speechtotext.models.streaming.Hypothesis; import ai.rev.speechtotext.models.streaming.SessionConfig; import ai.rev.speechtotext.models.streaming.StreamContentType; import com.google.gson.Gson; import com.google.gson.JsonObject; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; public class StreamingClient { private String accessToken; private OkHttpClient client; private WebSocket webSocket; private String scheme; private String host; private Integer port; /** * Constructs the streaming client that is used to establish a WebSocket connection with the * Rev AI server and stream audio data. The user access token can be generated on the website at * https://www.rev.ai/access_token. * * @param accessToken Rev AI authorization token. */ public StreamingClient(String accessToken) { this.accessToken = accessToken; this.client = setClient(); } /** * This method sets the URL scheme to be used in the WebSocket connect request * * @param scheme URL scheme. */ public void setScheme(String scheme) { switch (scheme.toLowerCase()) { case "wss": case "https": this.scheme = "https"; break; case "ws": case "http": this.scheme = "http"; break; default: throw new IllegalArgumentException("Invalid scheme: " + scheme); } } /** * This methods sets the URL host name. By default the host name is api.rev.ai. * * @param host URL host name. */ public void setHost(String host) { this.host = host; } /** * This method sets a port number to be used in the WebSocket connect request. * * @param port the port used to connect to */ public void setPort(int port) { this.port = port; } /** * Sends an HTTP request and upon authorization is upgraded to a WebSocket connection. Use {@link * RevAiWebSocketListener} to handle web socket events. To establish a successful connection a * valid StreamContentType must be provided. * * <p>Providing metadata is optional but helps to identify the stream. * * <p>Providing a {@link SessionConfig} is optional. Use this object to enable the profanity * filter and provide a custom vocabulary id. * * @param revAiWebSocketListener the listener used to capture WebSocket events. * @param streamContentType content-type query parameter. * @param metadata used to identify the stream. * @param sessionConfig object containing the filter profanity setting and custom vocabulary id * @see RevAiWebSocketListener * @see StreamContentType * @see SessionConfig */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata, SessionConfig sessionConfig) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(metadata, streamContentType, sessionConfig); createWebSocketConnection(url, listener); } /** * Overload of {@link StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, * SessionConfig)} without the optional metadata and sessionConfig. * * @see StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, SessionConfig) */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(null, streamContentType, null); createWebSocketConnection(url, listener); } /** * Overload of {@link StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, * SessionConfig)} without the optional sessionConfig. * * @see StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, SessionConfig) */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(metadata, streamContentType, null); createWebSocketConnection(url, listener); } /** * Overload of {@link StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, * SessionConfig)} without the optional metadata. * * @see StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, SessionConfig) */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, SessionConfig sessionConfig) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(null, streamContentType, sessionConfig); createWebSocketConnection(url, listener); } /** * Sends data over WebSocket in the form of a ByteString * * @param byteString Audio data in the form of a ByteString */ public void sendAudioData(ByteString byteString) { webSocket.send(byteString); } /** Will close the WebSocket connection by informing the server that it's the End of Stream */ public void close() { webSocket.send("EOS"); } private void createWebSocketConnection(String url, Listener listener) { Request request = new Request.Builder().url(url).build(); webSocket = client.newWebSocket(request, listener); } private String buildURL( String metadata, StreamContentType streamContentType, SessionConfig sessionConfig) { HttpUrl.Builder urlBuilder = new HttpUrl.Builder(); if (scheme != null) { urlBuilder.scheme(scheme); } else { urlBuilder.scheme("https"); } if (host != null) { urlBuilder.host(host); } else { urlBuilder.host("api.rev.ai"); } if (port != null) { urlBuilder.port(port); } urlBuilder.addPathSegments("speechtotext/v1/stream"); urlBuilder.addQueryParameter("access_token", accessToken); if (metadata != null) { urlBuilder.addQueryParameter("metadata", metadata); } if (sessionConfig != null) { if (sessionConfig.getCustomVocabularyId() != null) { urlBuilder.addQueryParameter("custom_vocabulary_id", sessionConfig.getCustomVocabularyId()); } if (sessionConfig.getFilterProfanity() != null) { urlBuilder.addQueryParameter( "filter_profanity", String.valueOf(sessionConfig.getFilterProfanity())); } if (sessionConfig.getRemoveDisfluencies() != null) { urlBuilder.addQueryParameter( "remove_disfluencies", String.valueOf(sessionConfig.getRemoveDisfluencies())); } if (sessionConfig.getDeleteAfterSeconds() != null) { urlBuilder.addQueryParameter( "delete_after_seconds", String.valueOf(sessionConfig.getDeleteAfterSeconds())); } if (sessionConfig.getDetailedPartials() != null) { urlBuilder.addQueryParameter( "detailed_partials", String.valueOf(sessionConfig.getDetailedPartials())); } if (sessionConfig.getStartTs() != null) { urlBuilder.addQueryParameter("start_ts", String.valueOf(sessionConfig.getStartTs())); } if (sessionConfig.getTranscriber() != null) { urlBuilder.addQueryParameter("transcriber", sessionConfig.getTranscriber()); } if (sessionConfig.getLanguage() != null) { urlBuilder.addQueryParameter("language", sessionConfig.getLanguage()); } if (sessionConfig.getSkipPostprocessing() != null) { urlBuilder.addQueryParameter( "skip_postprocessing", String.valueOf(sessionConfig.getSkipPostprocessing())); } } return urlBuilder.build().toString() + "&content_type=" + streamContentType.buildContentString(); } private OkHttpClient setClient() { return new OkHttpClient.Builder() .addNetworkInterceptor(new ApiInterceptor(accessToken, SDKHelper.getSdkVersion())) .addNetworkInterceptor(new ErrorInterceptor()) .build(); } private static class Listener extends WebSocketListener { private Gson gson = new Gson(); private RevAiWebSocketListener revAiWebsocketListener; public Listener(RevAiWebSocketListener revAiWebsocketListener) { this.revAiWebsocketListener = revAiWebsocketListener; } @Override public void onOpen(WebSocket webSocket, Response response) { revAiWebsocketListener.onOpen(response); } @Override public void onMessage(WebSocket webSocket, String text) { JsonObject jsonObject = gson.fromJson(text, JsonObject.class); String type = jsonObject.get("type").getAsString(); if (type.equals("connected")) { revAiWebsocketListener.onConnected(gson.fromJson(text, ConnectedMessage.class)); } else if (type.equals("partial") || type.equals("final")) { revAiWebsocketListener.onHypothesis(gson.fromJson(text, Hypothesis.class)); } } @Override public void onClosing(WebSocket webSocket, int code, String reason) { revAiWebsocketListener.onClose(code, reason); } @Override public void onClosed(WebSocket webSocket, int code, String reason) { revAiWebsocketListener.onClose(code, reason); } @Override public void onFailure(WebSocket webSocket, Throwable t, Response response) { revAiWebsocketListener.onError(t, response); } } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/CustomerUrlData.java
package ai.rev.speechtotext.models; import com.google.gson.annotations.SerializedName; import java.util.Map; public class CustomerUrlData { /** * Customer provided url */ @SerializedName("url") private String url; /** * Authentication headers to access the url * Only authorization is currently supported * Example: * Map<String, String> authHeaders = new HashMap<>(); * authHeaders.put("Authorization", "Bearer <token>"); * " */ @SerializedName("auth_headers") private Map<String, String> authHeaders; public CustomerUrlData(String url, Map<String, String> authHeaders) { this.url = url; this.authHeaders = authHeaders; } public void setUrl(String url) { this.url = url; } public void setAuthHeaders(Map<String, String> authHeaders) { this.authHeaders = authHeaders; } public String getUrl() { return url; } public Map<String, String> getAuthHeaders() { return authHeaders; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/Element.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * An Element object presents all the information the models inferred from a single interval of * audio. */ public class Element { @SerializedName("ts") private Double startTimestamp; @SerializedName("end_ts") private Double endTimestamp; @SerializedName("type") private String type; @SerializedName("value") private String value; @SerializedName("confidence") private Double confidence; /** * Returns the starting timestamp of this audio interval. * * @return The starting timestamp of this audio interval. */ public Double getStartTimestamp() { return startTimestamp; } /** * Sets the starting timestamp for this audio interval. * * @param startTimestamp The timestamp to set as the starting timestamp. */ public void setStartTimestamp(Double startTimestamp) { this.startTimestamp = startTimestamp; } /** * Returns the end timestamp for this audio interval. * * @return The end timestamp for this audio interval. */ public Double getEndTimestamp() { return endTimestamp; } /** * Sets the end timestamp for this audio interval. * * @param endTimestamp The timestamp to set as the end timestamp. */ public void setEndTimestamp(Double endTimestamp) { this.endTimestamp = endTimestamp; } /** * Returns the type of transcript element contained within this audio interval. * * @return The type of transcript element contained within this audio interval. */ public String getType() { return type; } /** * Sets the type to the String provided * * @param type the String value to set as the type. */ public void setType(String type) { this.type = type; } /** * Returns the value of the transcript element. * * @return The value of the transcript element. */ public String getValue() { return value; } /** * Sets the value of the transcript element to the String provided. * * @param value The String to set as the value. */ public void setValue(String value) { this.value = value; } /** * Returns the confidence score of the value provided in this transcript element. * * @return The confidence score of the value provided in this transcript element. */ public Double getConfidence() { return confidence; } /** * Sets the confidence score to the Double provided. * * @param confidence The Double to set the confidence score to. */ public void setConfidence(Double confidence) { this.confidence = confidence; } @Override public String toString() { return "{" + "startTimestamp=" + startTimestamp + ", endTimestamp=" + endTimestamp + ", type='" + type + '\'' + ", value='" + value + '\'' + ", confidence=" + confidence + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/Monologue.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; import java.util.List; /** * A Monologue object presents information about a segment of a transcript owned by an individual * speaker. */ public class Monologue { @SerializedName("speaker") private Integer speaker; @SerializedName("speaker_info") private SpeakerInfo speakerInfo; @SerializedName("elements") private List<Element> elements; /** * Returns the speaker number for this monologue. * * @return The speaker number for this monologue. */ public Integer getSpeaker() { return speaker; } /** * Sets the speaker number for this monologue. * * @param speaker The number to set the speaker to. */ public void setSpeaker(Integer speaker) { this.speaker = speaker; } /** * Returns the speaker info for this monologue. * * @return The speaker info for this monologue. */ public SpeakerInfo getSpeakerInfo() { return speakerInfo; } /** * Sets the speaker info for this monologue. * * @param speakerInfo Info about the speaker for this monologue. */ public void setSpeakerInfo(SpeakerInfo speakerInfo) { this.speakerInfo = speakerInfo; } /** * Returns a list of {@link Element} objects. * * @return A list of {@link Element} objects. * @see Element */ public List<Element> getElements() { return elements; } /** * Sets elements to the list of {@link Element} objects provided. * * @param elements The list of {@link Element} objects to set as the elements. * @see Element */ public void setElements(List<Element> elements) { this.elements = elements; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiAccount.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * The RevAiAccount object provides basic information about a Rev AI account associated with a valid * access token. * * @see <a href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetAccount">https://docs.rev.ai/api/asynchronous/reference/#operation/GetAccount</a> */ public class RevAiAccount { @SerializedName("email") private String email; @SerializedName("balance_seconds") private Integer balanceSeconds; /** * Returns a String containing the account email. * * @return A String containing the account email. */ public String getEmail() { return this.email; } /** * Sets the email value. * * @param email The String value to set as the {@link RevAiAccount#email}. */ public void setEmail(String email) { this.email = email; } /** * Returns the remaining number of credits in seconds that can be used on the account. * * @return The number of seconds remaining on the account. */ public Integer getBalanceSeconds() { return this.balanceSeconds; } /** * Sets the balanceSeconds value. This cannot be used to affect the actual number of credits * remaining. * * @param balanceSeconds The Integer value to set as the {@link RevAiAccount#balanceSeconds}. */ public void setBalanceSeconds(Integer balanceSeconds) { this.balanceSeconds = balanceSeconds; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiCaptionType.java
package ai.rev.speechtotext.models.asynchronous; /** Specifies constants that define support caption formats. */ public enum RevAiCaptionType { /** The SubRip caption file format. */ SRT("application/x-subrip"), /** The WebVTT caption file format. */ VTT("text/vtt"); private String captionType; RevAiCaptionType(String captionType) { this.captionType = captionType; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getContentType() { return captionType; } @Override public String toString() { return "{" + "captionType='" + captionType + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiFailureType.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Rev AI failure types. */ public enum RevAiFailureType { /** The failure used when the media provided in the submission request fails to download. */ @SerializedName("download_failure") DOWNLOAD_FAILURE("download_failure"), /** The failure used when the media provided doesn't contain any audio. */ @SerializedName("empty_media") EMPTY_MEDIA("empty_media"), /** The failure used when the account does not have enough credits remaining. */ @SerializedName("insufficient_balance") INSUFFICIENT_BALANCE("insufficient_balance"), /** The failure used when there is a processing error. */ @SerializedName("internal_processing") INTERNAL_PROCESSING("internal_processing"), /** The failure used when the file submitted is not a valid or supported media file. */ @SerializedName("invalid_media") INVALID_MEDIA("invalid_media"), /** The failure used when the account has reached or exceeded its invoicing limit. */ @SerializedName("invoicing_limit_exceeded") INVOICING_LIMIT_EXCEEDED("invoicing_limit_exceeded"), /** The failure used when an error occurs during transcription and prevents job completion. */ @SerializedName("transcription") TRANSCRIPTION("transcription"); private String failureType; RevAiFailureType(String failureType) { this.failureType = failureType; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getFailureType() { return failureType; } @Override public String toString() { return "{" + "failureType='" + failureType + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiJob.java
package ai.rev.speechtotext.models.asynchronous; import java.util.List; import com.google.gson.annotations.SerializedName; /** A RevAi Job object provides all the information associated with a job submitted by the user. */ public class RevAiJob { @SerializedName("id") private String jobId; @SerializedName("status") private RevAiJobStatus jobStatus; @SerializedName("created_on") private String createdOn; @SerializedName("completed_on") private String completedOn; @SerializedName("callback_url") private String callbackUrl; @SerializedName("duration_seconds") private Double durationSeconds; @SerializedName("media_url") private String mediaUrl; @SerializedName("metadata") private String metadata; @SerializedName("name") private String name; @SerializedName("type") private RevAiJobType type; @SerializedName("failure_details") private String failureDetails; @SerializedName("failure") private RevAiFailureType failure; @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; @SerializedName("skip_diarization") private Boolean skipDiarization; @SerializedName("skip_punctuation") private Boolean skipPunctuation; @SerializedName("remove_disfluencies") private Boolean removeDisfluencies; @SerializedName("filter_profanity") private Boolean filterProfanity; @SerializedName("custom_vocabulary_id") private String customVocabularyId; @SerializedName("speaker_channels_count") private Integer speakerChannelsCount; @SerializedName("language") private String language; @SerializedName("transcriber") private String transcriber; @SerializedName("verbatim") private Boolean verbatim; @SerializedName("rush") private Boolean rush; @SerializedName("segments_to_transcribe") private List<SegmentToTranscribe> segmentsToTranscribe; @SerializedName("summarization") private Summarization summarization; @SerializedName("translation") private Translation translation; /** * Returns a String that contains the job ID. * * @return A String that contains the job ID. */ public String getJobId() { return jobId; } /** * Sets the Job ID. * * @param jobId The String value to set as the job ID. */ public void setJobId(String jobId) { this.jobId = jobId; } /** * Returns the {@link RevAiJobStatus} enumeration value. * * @return The {@link RevAiJobStatus} enumeration value. * @see RevAiJobStatus */ public RevAiJobStatus getJobStatus() { return jobStatus; } /** * Sets the job status to the provided {@link RevAiJobStatus} enumeration value. * * @param jobStatus The enumeration value to set as the job status. * @see RevAiJobStatus */ public void setJobStatus(RevAiJobStatus jobStatus) { this.jobStatus = jobStatus; } /** * Returns a String that contains the date and time the job was created on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was created on in ISO-8601 UTC form. */ public String getCreatedOn() { return createdOn; } /** * Sets the time and date the job was created on. * * @param createdOn The String value to set as the created on date and time. */ public void setCreatedOn(String createdOn) { this.createdOn = createdOn; } /** * Returns a String that contains the date and time the job was completed on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was completed on in ISO-8601 UTC form. */ public String getCompletedOn() { return completedOn; } /** * Set the date and time the job was completed on. * * @param completedOn The String value to set as the date and time the job was completed on. */ public void setCompletedOn(String completedOn) { this.completedOn = completedOn; } /** * Returns the callback url provided in the submission request. * * @return A String containing the callback url provided in the submission request. */ public String getCallbackUrl() { return callbackUrl; } /** * Sets the callback url. * * @param callbackUrl A String value to set as the callback url. */ public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the audio duration of the file in seconds. * * @return The audio duration of the file in seconds. */ public Double getDurationSeconds() { return durationSeconds; } /** * Sets the audio duration. * * @param durationSeconds A Double value to set as audio duration. */ public void setDurationSeconds(Double durationSeconds) { this.durationSeconds = durationSeconds; } /** * Returns the media url provided in the submission request. * * @return A String containing the media url provided in the submission request. */ public String getMediaUrl() { return mediaUrl; } /** * Sets the media url. * * @param mediaUrl A String value to set as the media url. */ public void setMediaUrl(String mediaUrl) { this.mediaUrl = mediaUrl; } /** * Returns the metadata provided in the submission request. * * @return A String containing the metadata provided in the submission request. */ public String getMetadata() { return metadata; } /** * Sets the metadata. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the name of the file provided in the submission request. * * @return A String that contains the name of the file provided in the submission request. */ public String getName() { return name; } /** * Sets the file name. * * @param name A String to set as the file name. */ public void setName(String name) { this.name = name; } /** * Returns the {@link RevAiJobType} enumeration value. * * @return the enumeration value. * @see RevAiJobType */ public RevAiJobType getType() { return type; } /** * Sets the job type to the provided {@link RevAiJobType} enumeration. * * @param type The enumeration value to set as the job type. * @see RevAiJobType */ public void setType(RevAiJobType type) { this.type = type; } /** * Returns a detailed, human readable explanation of the failure. * * @return A detailed, human readable explanation of the failure. */ public String getFailureDetails() { return failureDetails; } /** * Sets the failure details to the provided value. * * @param failureDetails A String to set as the failure details. */ public void setFailureDetails(String failureDetails) { this.failureDetails = failureDetails; } /** * Returns the {@link RevAiFailureType} enumeration value. * * @return The {@link RevAiFailureType} enumeration value. * @see RevAiFailureType */ public RevAiFailureType getFailure() { return failure; } /** * Sets the failure to the provided {@link RevAiFailureType} enumeration. * * @param failure The enumeration value to set as the failure. * @see RevAiFailureType */ public void setFailure(RevAiFailureType failure) { this.failure = failure; } /** * Returns the duration in seconds before job is deleted * * @return The duration in seconds. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Sets the duration in seconds before job is deleted * * @param deleteAfterSeconds An Integer value to set as seconds before deletion. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } /** * Returns value of skip diarization for job * * @return Whether job is skipping diarization */ public Boolean getSkipDiarization() { return skipDiarization; } /** * Sets skip diarization option for job * * @param skipDiarization An Boolean value to set for skipping diarization */ public void setSkipDiarization(Boolean skipDiarization) { this.skipDiarization = skipDiarization; } /** * Returns value of skip punctuation for job * * @return Whether job is skipping punctuation */ public Boolean getSkipPunctuation() { return skipPunctuation; } /** * Sets skip punctuation option for job * * @param skipPunctuation An Boolean value to set for skipping punctuation */ public void setSkipPunctuation(Boolean skipPunctuation) { this.skipPunctuation = skipPunctuation; } /** * Returns value of remove disfluencies for job * * @return Whether job is removing disfluencies */ public Boolean getRemoveDisfluencies() { return removeDisfluencies; } /** * Sets remove disfluencies option for job * * @param removeDisfluencies An Boolean value to set for remove disfluencies */ public void setRemoveDisfluencies(Boolean removeDisfluencies) { this.removeDisfluencies = removeDisfluencies; } /** * Returns value of filter profanity for job * * @return Whether job is filtering profanity */ public Boolean getFilterProfanity() { return filterProfanity; } /** * Sets filter profanity option for job * * @param filterProfanity An Boolean value to set for filter profanity */ public void setFilterProfanity(Boolean filterProfanity) { this.filterProfanity = filterProfanity; } /** * Returns custom vocabulary id (if specified) associated to the job * * @return User-supplied custom vocabulary ID */ public String getCustomVocabularyId() { return customVocabularyId; } /** * Sets the user-supplied custom vocabulary ID for job * * @param customVocabularyId An String value to set for custom vocabulary ID */ public void setCustomVocabularyId(String customVocabularyId) { this.customVocabularyId = customVocabularyId; } /** * Returns number of speaker channels (if specified) for job * * @return Total number of unique speaker channels */ public Integer getSpeakerChannelsCount() { return speakerChannelsCount; } /** * Sets speaker channels count for job * * @param speakerChannelsCount An Integer value to set for speaker channels count */ public void setSpeakerChannelsCount(Integer speakerChannelsCount) { this.speakerChannelsCount = speakerChannelsCount; } /** * Returns language of the job * * @return language of the job */ public String getLanguage() { return language; } /** * Sets the language for job * * @param language An String value to set for language */ public void setLanguage(String language) { this.language = language; } /** * Returns transcriber used for the job * * @return transcriber used for the job */ public String getTranscriber() { return transcriber; } /** * Sets the transcriber used for job * * @param transcriber An String value to set for transcriber */ public void setTranscriber(String transcriber) { this.transcriber = transcriber; } /** * Returns value of verbatim for job transcribed by human * * @return Whether job transcribed by human is verbatim */ public Boolean getVerbatim() { return verbatim; } /** * Sets verbatim for job transcribed by human * * @param verbatim An Boolean value to set for verbatim */ public void setVerbatim(Boolean verbatim) { this.verbatim = verbatim; } /** * Returns value of rush for job transcribed by human * * @return Whether job transcribed by human has rush */ public Boolean getRush() { return rush; } /** * Sets rush option for job transcribed by human * * @param rush An Boolean value to set for rush */ public void setRush(Boolean rush) { this.rush = rush; } /** * Returns segments to transcribe for job transcribed by human * * @return List of segments to be transcribed */ public List<SegmentToTranscribe> getSegmentsToTranscribe() { return segmentsToTranscribe; } /** * Sets segments to be transcribed for job transcribed by human * * @param segmentsToTranscribe List of segments to be transcribed */ public void setSegmentsToTranscribe(List<SegmentToTranscribe> segmentsToTranscribe) { this.segmentsToTranscribe = segmentsToTranscribe; } /** * Returns summarization options for the job * * @return Summarization options for the job */ public Summarization getSummarization() { return summarization; } /** * Sets summarization options for the job */ public void setSummarization(Summarization summarization) { this.summarization = summarization; } /** * Returns translation options for the job * * @return Translation options for the job */ public Translation getTranslation() { return translation; } /** * Sets translation options for the job */ public void setTranslation(Translation translation) { this.translation = translation; } @Override public String toString() { return "{" + "jobID='" + jobId + '\'' + ", jobStatus=" + jobStatus + ", createdOn='" + createdOn + '\'' + ", completedOn='" + completedOn + '\'' + ", callbackUrl='" + callbackUrl + '\'' + ", durationSeconds=" + durationSeconds + ", mediaUrl='" + mediaUrl + '\'' + ", metadata='" + metadata + '\'' + ", name='" + name + '\'' + ", type='" + type.getJobType() + '\'' + ", failureDetails='" + failureDetails + '\'' + ", failure='" + getFailureTypeString(failure) + '\'' + ", deleteAfterSeconds='" + deleteAfterSeconds + '\'' + ", skipDiarization='" + skipDiarization + '\'' + ", removeDisfluencies='" + removeDisfluencies + '\'' + ", filterProfanity='" + filterProfanity + '\'' + ", customVocabularyId='" + customVocabularyId + '\'' + ", speakerChannelsCount='" + speakerChannelsCount + '\'' + ", language='" + language + '\'' + ", transcriber='" + transcriber + '\'' + ", verbatim='" + verbatim + '\'' + ", rush='" + rush + '\'' + ", segmentsToTranscribe='" + segmentsToTranscribe + '\'' + ", summarization='" + summarization + '\'' + ", translation='" + translation + '\'' + '}'; } private static String getFailureTypeString(RevAiFailureType failure) { if(failure == null) return ""; return failure.getFailureType(); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiJobOptions.java
package ai.rev.speechtotext.models.asynchronous; import ai.rev.speechtotext.models.CustomerUrlData; import ai.rev.speechtotext.models.vocabulary.CustomVocabulary; import com.google.gson.annotations.SerializedName; import java.util.List; import java.util.Map; /** * A RevAiJobOptions object represents parameters that are submitted along a new job. * * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public class RevAiJobOptions { /** The media url where the file can be downloaded. * @deprecated Use source_config instead */ @SerializedName("media_url") @Deprecated private String mediaUrl; /** Object containing source media file information. */ @SerializedName("source_config") private CustomerUrlData sourceConfig; /** The callback url that Rev AI will send a POST to when the job has finished. * @deprecated Use notification_config instead */ @SerializedName("callback_url") @Deprecated private String callbackUrl; /** Object containing information on the callback url that Rev AI will send a POST to when the job has finished. */ @SerializedName("notification_config") private CustomerUrlData notificationConfig; /** Optional parameter for the speech engine to skip diarization. */ @SerializedName("skip_diarization") private Boolean skipDiarization; /** Optional parameter for the speech engine to skip punctuation. */ @SerializedName("skip_punctuation") private Boolean skipPunctuation; /** Optional parameter for the speech engine to skip all postprocessing */ @SerializedName("skip_postprocessing") private Boolean skipPostprocessing; /** * Optional parameter to process each audio channel separately. Account will be charged the file * duration multiplied by the number of specified channels. */ @SerializedName("speaker_channels_count") private Integer speakerChannelsCount; /** Optional parameter for the id of a pre-computed custom vocabulary to be used */ @SerializedName("custom_vocabulary_id") private String customVocabularyId; /** Optional array of {@link CustomVocabulary} objects. */ @SerializedName("custom_vocabularies") private List<CustomVocabulary> customVocabularies; /** * Optional information that can be provided. */ @SerializedName("metadata") private String metadata; /** * Optional parameter to filter profanity in the transcript */ @SerializedName("filter_profanity") private Boolean filterProfanity; /** * Optional parameter to remove disfluencies (ums, ahs) in the transcript */ @SerializedName("remove_disfluencies") private Boolean removeDisfluencies; /** * Optional number of seconds after job completion when job is auto-deleted */ @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; /** * Optional language parameter using a supported ISO 639-1 2-letter or ISO 639-3 (3-letter) language code * as defined in the API reference */ @SerializedName("language") private String language; /** * Specifies the type of transcriber to use to transcribe the media file */ @SerializedName("transcriber") private String transcriber; /** * Optional and only available with transcriber "human". * Whether transcriber will transcribe every syllable. */ @SerializedName("verbatim") private Boolean verbatim; /** * Optional and only available with transcriber "human". * Whether job is given higher priority by human transcriber for higher price. */ @SerializedName("rush") private Boolean rush; /** * Optional and only available with transcriber "human". * Whether job is mocked and no real transcription actually happens. */ @SerializedName("test_mode") private Boolean testMode; /** * Optional and only available with transcriber "human". * Sections of the transcript that should be transcribed instead of the whole file. */ @SerializedName("segments_to_transcribe") private List<SegmentToTranscribe> segmentsToTranscribe; /** * Optional and only available with transcriber "human". * Specifies a list of names for the speakers in an audio file. */ @SerializedName("speaker_names") private List<SpeakerName> speakerNames; @SerializedName("summarization_config") private SummarizationOptions summarizationOptions; @SerializedName("translation_config") private TranslationOptions translationOptions; /** * Returns the media url. * * @return The media url. * @deprecated Set sourceConfig and use getSourceConfig instead */ @Deprecated public String getMediaUrl() { return mediaUrl; } /** * Specifies the url where the media can be downloaded. * * @param mediaUrl The direct download url to the file. * @deprecated Use setSourceConfig instead */ @Deprecated public void setMediaUrl(String mediaUrl) { this.mediaUrl = mediaUrl; } /** * Returns the source config object. * * @return the source config. */ public CustomerUrlData getSourceConfig() { return this.sourceConfig; } /** * Specifies the url and any optional auth headers to access the source media download url. * * @param sourceMediaUrl The direct download url to the file. * @param sourceAuth The auth headers to the source media download url. */ public void setSourceConfig(String sourceMediaUrl, Map<String, String> sourceAuth) { this.sourceConfig = new CustomerUrlData(sourceMediaUrl, sourceAuth); } /** * Specifies the source media download url. * * @param sourceMediaUrl The direct download url to the file. */ public void setSourceConfig(String sourceMediaUrl) { this.sourceConfig = new CustomerUrlData(sourceMediaUrl, null); } /** * Returns the callback url. * * @return the callback url. * @deprecated Use notificationConfig and getNotificationConfig instead */ @Deprecated public String getCallbackUrl() { return callbackUrl; } /** * Specifies the callback url that Rev AI will POST to when job processing is complete. This * property is optional. * * @param callbackUrl The url to POST to when job processing is complete. * @deprecated Use setNotificationConfig instead */ @Deprecated public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the notification config object. * * @return the notification config. */ public CustomerUrlData getNotificationConfig() { return notificationConfig; } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. * @param authHeaders Optional parameter to authenticate access to the callback url */ public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) { this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders); } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. */ public void setNotificationConfig(String callbackUrl) { setNotificationConfig(callbackUrl, null); } /** * Returns the value of the skip diarization Boolean. * * @return The skip diarization value. */ public Boolean getSkipDiarization() { return skipDiarization; } /** * Specifies if speaker diarization will be skipped by the speech engine. This property is * optional and defaults to false. * * @param skipDiarization The value of the Boolean. */ public void setSkipDiarization(Boolean skipDiarization) { this.skipDiarization = skipDiarization; } /** * Returns the value of the skip punctuation Boolean. * * @return The skip punctuation value. */ public Boolean getSkipPunctuation() { return skipPunctuation; } /** * Specifies if the "punct" elements will be skipped by the speech engine. This property is * optional and defaults to false. * * @param skipPunctuation The value of the Boolean. */ public void setSkipPunctuation(Boolean skipPunctuation) { this.skipPunctuation = skipPunctuation; } /** * Returns the value of the skip postprocessing Boolean. * * @return The skip postprocessing value. */ public Boolean getSkipPostprocessing() { return skipPostprocessing; } /** * Specifies if all postprocessing (capitalization, punctuation, ITN) will be skipped by the speech engine. This property is * optional and defaults to false. * * @param skipPostprocessing The value of the Boolean. */ public void setSkipPostprocessing(Boolean skipPostprocessing) { this.skipPostprocessing = skipPostprocessing; } /** * Returns the speaker channel count. * * @return The speaker channel count. */ public Integer getSpeakerChannelsCount() { return speakerChannelsCount; } /** * Specifies the number of speaker channels in the audio. Each speaker channel is processed * separately. When set the account will be charged the file * duration multiplied by the number * of specified channels. This property is optional and defaults to null. * * @param speakerChannelsCount The number of separate speaker channels in the audio. */ public void setSpeakerChannelsCount(Integer speakerChannelsCount) { this.speakerChannelsCount = speakerChannelsCount; } /** * Returns the custom vocabulary ID. * * @return The custom vocabulary ID. */ public String getCustomVocabularyId() { return customVocabularyId; } /** * Specifies the ID of the custom vocabulary the speech engine should use while processing audio * samples. Custom vocabularies are submitted prior to usage in the stream and assigned an Id. * * @param customVocabularyId The ID of the custom vocabulary. */ public void setCustomVocabularyId(String customVocabularyId) { this.customVocabularyId = customVocabularyId; } /** * Returns a list of {@link CustomVocabulary} objects. * * @return A list of {@link CustomVocabulary} objects. * @see CustomVocabulary */ public List<CustomVocabulary> getCustomVocabularies() { return customVocabularies; } /** * Provides the custom vocabularies to be used by the speech engine when processing the * transcript. List size is limited to 50 items. Providing custom vocabularies is optional. * * @param customVocabularies A list of custom vocabularies. * @see CustomVocabulary */ public void setCustomVocabularies(List<CustomVocabulary> customVocabularies) { this.customVocabularies = customVocabularies; } /** * Returns the metadata. * * @return A String that contains the metadata. */ public String getMetadata() { return metadata; } /** * Optional metadata that is provided during job submission limited to 512 characters. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the value of the filterProfanity Boolean * * @return The filter profanity value. */ public Boolean getFilterProfanity() { return filterProfanity; } /** * Specifies whether or not the speech engine should filter profanity in the output. Setting the * profanity filter is optional. * * @param filterProfanity The option to filter profanity. */ public void setFilterProfanity(Boolean filterProfanity) { this.filterProfanity = filterProfanity; } /** * Returns the value of the removeDisfluencies Boolean * * @return The removeDisfluencies value. */ public Boolean getRemoveDisfluencies() { return removeDisfluencies; } /** * Specifies whether or not the speech engine should remove disfluencies in the output. Setting * the option to remove disfluencies is optional. * * @param removeDisfluencies The option to remove disfluencies. */ public void setRemoveDisfluencies(Boolean removeDisfluencies) { this.removeDisfluencies = removeDisfluencies; } /** * Returns the value of deleteAfterSeconds. * * @return The deleteAfterSeconds value. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Specifies the number of seconds to be waited until the job is auto-deleted after its * completion. * * @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } /** * Returns the value of language. * * @return the language value. */ public String getLanguage() { return language; } /** * Specifies language for ASR system using ISO 639-1 2-letter language code. * * @param language ISO 639-1 2-letter language code of desired ASR language. */ public void setLanguage(String language) { this.language = language; } /** * Specifies the type of transcriber to use to transcribe the media file * * @return the name of the transcriber type */ public String getTranscriber() { return transcriber; } /** * Specifies the type of transcriber to use to transcribe the media file * * @param transcriber the name of the transcriber type */ public void setTranscriber(String transcriber) { this.transcriber = transcriber; } /** * Returns the value of verbatim * * @return Whether verbatim is true or false */ public Boolean getVerbatim() { return verbatim; } /** * Sets whether transcriber will transcribe every syllable including disfluencies. This * property is optional but can only be used with "human" transcriber. * Defaults to false. * * @param verbatim Whether to transcribe every syllable */ public void setVerbatim(Boolean verbatim) { this.verbatim = verbatim; } /** * Returns the value of rush * * @return Whether rush is true or false */ public Boolean getRush() { return rush; } /** * Sets whether job is given higher priority by human transcriber to be worked on sooner in * exchange for a higher price. This property is optional but can only be used with "human" transcriber. * Defaults to false. * * @param rush Whether to give higher priority to the job */ public void setRush(Boolean rush) { this.rush = rush; } /** * Returns the value of testMode * * @return Whether testMode is true or false */ public Boolean getTestMode() { return testMode; } /** * Sets whether job is a mocked job which will return a mock transcript. * This property is optional but can only be used with "human" transcriber. * Defaults to false. * * @param testMode Whether to set job to be test mode */ public void setTestMode(Boolean testMode) { this.testMode = testMode; } /** * Returns the segments in media to transcribe * * @return Segments to transcribe for the job */ public List<SegmentToTranscribe> getSegmentsToTranscribe() { return segmentsToTranscribe; } /** * Specifies specific segments of the media to transcribe. * This property is optional but can only be used with "human" transcriber. * * @param segmentsToTranscribe List of segments to transcribe */ public void setSegmentsToTranscribe(List<SegmentToTranscribe> segmentsToTranscribe) { this.segmentsToTranscribe = segmentsToTranscribe; } /** * Returns the list of speaker names * * @return List of speaker names */ public List<SpeakerName> getSpeakerNames() { return speakerNames; } /** * Specifies the list of speaker names in an audio file * This property is optional but can only be used with "human" transcriber. * * @param speakerNames List of speaker names */ public void setSpeakerNames(List<SpeakerName> speakerNames) { this.speakerNames = speakerNames; } /** * Returns summarization options * * @return Summarization options */ public SummarizationOptions getSummarizationOptions() { return summarizationOptions; } /** * Specifies summarization options. * * @param summarizationOptions Summarization options */ public void setSummarizationOptions(SummarizationOptions summarizationOptions) { this.summarizationOptions = summarizationOptions; } /** * Returns translation options. * * @return Translation options */ public TranslationOptions getTranslationOptions() { return translationOptions; } /** * Specifies translation options. * * @param translationOptions Translation options */ public void setTranslationOptions(TranslationOptions translationOptions) { this.translationOptions = translationOptions; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiJobStatus.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Rev AI job statuses. */ public enum RevAiJobStatus { /** The status when transcription has failed. */ @SerializedName("failed") FAILED("failed"), /** The status when transcription of the file is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"), /** The status when the file has been transcribed. */ @SerializedName("transcribed") TRANSCRIBED("transcribed"); private String status; RevAiJobStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiJobType.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Rev AI job types. */ public enum RevAiJobType { /** The type used for asynchronous jobs. */ @SerializedName("async") ASYNC("async"), /** The type used for streaming jobs. */ @SerializedName("stream") STREAM("stream"), /** The type used for topic extraction jobs. */ @SerializedName("topic_extraction") TOPICEXTRACTION("topic_extraction"), /** The Type used for sentiment analysis jobs. */ @SerializedName("sentiment_analysis") SENTIMENTANALYSIS("sentiment_analysis"), /** The Type used for language id jobs. */ @SerializedName("language_id") LANGUAGEID("language_id"); private String jobType; RevAiJobType(String type) { this.jobType = type; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getJobType() { return jobType; } @Override public String toString() { return "{" + "type='" + jobType + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/RevAiTranscript.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; import java.util.List; /** A RevAiTranscript object presents a list of monologues as the transcript of a specific job. */ public class RevAiTranscript { @SerializedName("monologues") private List<Monologue> monologues; /** * Returns a list on {@link Monologue} objects. * * @return a list on {@link Monologue} objects. * @see Monologue */ public List<Monologue> getMonologues() { return monologues; } /** * Sets the monologues to the list of monologues provided. * * @param monologues the list of monologues to set the monologues to. * @see Monologue */ public void setMonologues(List<Monologue> monologues) { this.monologues = monologues; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SegmentToTranscribe.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A Segment object represents a segment of transcript that needs to be transcribed. * Used for speech-to-text jobs submitted to be transcribed by a human. * */ public class SegmentToTranscribe { @SerializedName("start") private Double startTimestamp; @SerializedName("end") private Double endTimestamp; /** * Returns the starting timestamp of the segment to transcribe. * * @return The starting timestamp of the segment. */ public Double getStartTimestamp() { return startTimestamp; } /** * Sets the starting timestamp for the segment to transcribe. * * @param startTimestamp The timestamp to set as the starting timestamp. */ public void setStartTimestamp(Double startTimestamp) { this.startTimestamp = startTimestamp; } /** * Returns the end timestamp for the segment to transcribe. * * @return The end timestamp of the segment. */ public Double getEndTimestamp() { return endTimestamp; } /** * Sets the end timestamp for the segment to transcribe. * * @param endTimestamp The timestamp to set as the end timestamp. */ public void setEndTimestamp(Double endTimestamp) { this.endTimestamp = endTimestamp; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SpeakerInfo.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A SpeakerInfo object represents the information related to the speaker in a transcript * Used for speech-to-text jobs submitted to be transcribed by a human. * */ public class SpeakerInfo { @SerializedName("id") private String id; @SerializedName("display_name") private String displayName; /** * Returns the id of the speaker * * @return the id of the speaker */ public String getIdName() { return id; } /** * Sets the id of the speaker * * @param displayName the displayed name of the speaker */ public void setId(String id) { this.id = id; } /** * Returns the displayed name of the speaker * * @return the displayed name of the speaker */ public String getDisplayName() { return displayName; } /** * Sets the displayed name of the speaker * * @param displayName the displayed name of the speaker */ public void setDisplayName(String displayName) { this.displayName = displayName; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SpeakerName.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A object representing information provided about a speaker * Used for speech-to-text jobs submitted to be transcribed by a human. * */ public class SpeakerName { @SerializedName("display_name") private String displayName; /** * Returns the displayed name of the speaker * * @return the displayed name of the speaker */ public String getDisplayName() { return displayName; } /** * Sets the displayed name of the speaker * * @param displayName the displayed name of the speaker */ public void setDisplayName(String displayName) { this.displayName = displayName; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/Summarization.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A Summarization Job object provides all the information associated with a summarization job * submitted by the user. */ public class Summarization { /** User defined prompt. */ @SerializedName("prompt") private String prompt; /** * Summarization model. * * @see TranslationModel */ @SerializedName("model") private TranslationModel model; /** Formatting options. Default is Paragraph. */ @SerializedName("type") private SummarizationFormattingOptions type; @SerializedName("status") private SummarizationJobStatus jobStatus; @SerializedName("completed_on") private String completedOn; @SerializedName("failure") private String failure; /** * Returns the {@link SummarizationJobStatus} enumeration value. * * @return The {@link SummarizationJobStatus} enumeration value. * @see SummarizationJobStatus */ public SummarizationJobStatus getJobStatus() { return jobStatus; } /** * Returns custom prompt used for the summarization job. * * @return Custom prompt used for the summarization job. */ public String getPrompt() { return prompt; } /** * Returns backend model used for the summarization job. * * @return Backend model used for the summarization job. * @see TranslationModel */ public TranslationModel getModel() { return model; } /** * Returns summary formatting options requested for the summarization job. * * @return Summary formatting options requested for the summarization job. * @see SummarizationFormattingOptions */ public SummarizationFormattingOptions getType() { return type; } /** * Returns a String that contains the date and time the job was completed on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was completed on in ISO-8601 UTC form. */ public String getCompletedOn() { return completedOn; } /** * Returns failure details. * * @return Failure details. */ public String getFailure() { return failure; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SummarizationFormattingOptions.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Summarization formatting options. */ public enum SummarizationFormattingOptions { /** Paragraph formatting */ @SerializedName("paragraph") PARAGRAPH("paragraph"), /** Bullet points formatting */ @SerializedName("bullets") BULLETS("bullets"); private final String formatting; SummarizationFormattingOptions(String formatting) { this.formatting = formatting; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getFormatting() { return formatting; } @Override public String toString() { return "{" + "formatting='" + formatting + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SummarizationJobStatus.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Summarization job statuses. */ public enum SummarizationJobStatus { /** The status when transcription has failed. */ @SerializedName("failed") FAILED("failed"), /** The status when transcription of the file is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"), /** The status when the file has been transcribed. */ @SerializedName("completed") COMPLETED("completed"); private String status; SummarizationJobStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SummarizationModel.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Supported model types for summarization. */ public enum SummarizationModel { @SerializedName("standard") STANDARD("standard"), @SerializedName("premium") PREMIUM("premium"); private final String model; SummarizationModel(String model) { this.model = model; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getModel() { return model; } @Override public String toString() { return "{" + "model='" + model + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/SummarizationOptions.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A SummarizationOptions object represents summarization parameters that are submitted along a new * job. * * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public class SummarizationOptions { /** User defined prompt. */ @SerializedName("prompt") private String prompt; /** Standard or Premium AI backend. */ @SerializedName("model") private SummarizationModel model; /** Formatting options. Default is Paragraph. */ @SerializedName("type") private SummarizationFormattingOptions type; /** * Returns custom prompt used for the summarization job. * * @return Custom prompt used for the summarization job. */ public String getPrompt() { return prompt; } /** * Sets custom prompt to use for the summarization job. * * @param prompt Custom prompt to use for the summarization job. */ public SummarizationOptions setPrompt(String prompt) { this.prompt = prompt; return this; } /** * Returns backend model used for the summarization job. * * @return Backend model used for the summarization job. * @see TranslationModel */ public SummarizationModel getModel() { return model; } /** * Sets backend model used for the summarization job. * * @param model Backend model used for the summarization job. * @see SummarizationModel */ public SummarizationOptions setModel(SummarizationModel model) { this.model = model; return this; } /** * Returns summary formatting options requested for the summarization job. * * @return Summary formatting options requested for the summarization job. * @see SummarizationFormattingOptions */ public SummarizationFormattingOptions getType() { return type; } /** * Sets summary formatting options requested for the summarization job. * * @param type Summary formatting options requested for the summarization job. * @see SummarizationFormattingOptions */ public SummarizationOptions setType(SummarizationFormattingOptions type) { this.type = type; return this; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/Summary.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; import java.util.List; /** * A Summary object represents summarization job results provided either as paragraph summary of * bullet points, depending on the requested format. * * @see SummarizationOptions */ public class Summary { @SerializedName("summary") private String summary; @SerializedName("bullet_points") private List<String> bulletPoints; /** * Returns paragraph summary if it was requested as PARAGRAPH * * @see SummarizationFormattingOptions */ public String getSummary() { return summary; } /** * Returns bullet points summary if it was requested as BULLETS * * @see SummarizationFormattingOptions */ public List<String> getBulletPoints() { return bulletPoints; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/Translation.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; import java.util.List; /** * A Translation object represents translation job(s) results. * * @see TranslationLanguage */ public class Translation { @SerializedName("target_languages") private List<TranslationLanguage> targetLanguages; @SerializedName("completed_on") private String completedOn; /** * Returns translation job(s) parameters * * @return Translation job(s) parameters * @see TranslationLanguage */ public List<TranslationLanguage> getTargetLanguages() { return targetLanguages; } /** * Returns a String that contains the date and time the job was completed on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was completed on in ISO-8601 UTC form. */ public String getCompletedOn() { return completedOn; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/TranslationJobStatus.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Translation job statuses. */ public enum TranslationJobStatus { /** The status when transcription has failed. */ @SerializedName("failed") FAILED("failed"), /** The status when transcription of the file is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"), /** The status when the file has been transcribed. */ @SerializedName("completed") COMPLETED("completed"); private final String status; TranslationJobStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/TranslationLanguage.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A TranslationLanguage object represents translation job results for a specific language. * * @see Translation */ public class TranslationLanguage { /** Standard or Premium AI backend. */ @SerializedName("model") private TranslationModel model; @SerializedName("language") private String language; @SerializedName("status") private TranslationJobStatus jobStatus; @SerializedName("failure") private String failure; /** * Returns backend model used for the summarization job. * * @return Backend model used for the summarization job. * @see TranslationModel */ public TranslationModel getModel() { return model; } /** * Returns translation language. * * @return Translation language. */ public String getLanguage() { return language; } /** * Returns the {@link TranslationJobStatus} enumeration value. * * @return The {@link TranslationJobStatus} enumeration value. * @see TranslationJobStatus */ public TranslationJobStatus getJobStatus() { return jobStatus; } /** * Returns failure details. * * @return Failure details. */ public String getFailure() { return failure; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/TranslationLanguageOptions.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * A TranslationLanguageOptions object represents translation parameters for a specific language that are submitted along a new * job. * * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public class TranslationLanguageOptions { /** Standard or Premium AI backend. */ @SerializedName("model") private TranslationModel model; @SerializedName("language") private final String language; /** * Returns backend model used for the summarization job. * * @return Backend model used for the summarization job. * @see TranslationModel */ public TranslationModel getModel() { return model; } /** * Sets backend model to use for the summarization job. * * @param model Backend model to use for the summarization job * @see TranslationModel */ public TranslationLanguageOptions setModel(TranslationModel model) { this.model = model; return this; } /** * Returns translation language. * * @return Translation language. */ public String getLanguage() { return language; } /** * Creates TranslationLanguageOptions object. * * @param language Translation language. */ public TranslationLanguageOptions(String language) { this.language = language; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/TranslationModel.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Supported model types for translation. */ public enum TranslationModel { @SerializedName("standard") STANDARD("standard"), @SerializedName("premium") PREMIUM("premium"); private final String model; TranslationModel(String model) { this.model = model; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getModel() { return model; } @Override public String toString() { return "{" + "model='" + model + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/asynchronous/TranslationOptions.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; import java.util.List; /** * A TranslationOptions object represents translation parameters that are submitted along a new job. * * @see <a * href="https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob">https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob</a> */ public class TranslationOptions { @SerializedName("target_languages") private final List<TranslationLanguageOptions> targetLanguages; /** * Returns a list of language specific parameters * * @return List of language specific parameters */ public List<TranslationLanguageOptions> getTargetLanguages() { return targetLanguages; } /** * Creates TranslationOptions object. * * @param targetLanguages a list of language specific parameters. */ public TranslationOptions(List<TranslationLanguageOptions> targetLanguages) { this.targetLanguages = targetLanguages; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/streaming/ConnectedMessage.java
package ai.rev.speechtotext.models.streaming; import com.google.gson.annotations.SerializedName; /** Represents the connected message sent from Rev AI and contains the id of the stream */ public class ConnectedMessage extends StreamingResponseMessage { @SerializedName("id") private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } @Override public String toString() { return "{" + "type='" + getType() + '\'' + ", id='" + id + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/streaming/Hypothesis.java
package ai.rev.speechtotext.models.streaming; import ai.rev.speechtotext.models.asynchronous.Element; import com.google.gson.annotations.SerializedName; import java.util.Arrays; /** * Represents the message returned over WebSocket containing the transcription of audio data. * * @see <a * href="https://docs.rev.ai/api/streaming/responses/">https://docs.rev.ai/api/streaming/responses/</a> */ public class Hypothesis extends StreamingResponseMessage { @SerializedName("ts") private Double ts; @SerializedName("end_ts") private Double endTs; @SerializedName("elements") private Element[] elements; /** * Returns the starting timestamp of a transcribed audio sample. * * @return The starting timestamp of a transcribed audio sample. */ public Double getTs() { return ts; } /** * Sets the starting timestamp. * * @param ts The starting timestamp. */ public void setTs(Double ts) { this.ts = ts; } /** * Returns the ending timestamp of a transcribed audio sample. * * @return The ending timestamp of a transcribed audio sample. */ public Double getEndTs() { return endTs; } /** * Sets the ending timestamp. * * @param endTs The ending timestamp. */ public void setEndTs(Double endTs) { this.endTs = endTs; } /** * Returns a list of {@link Element} objects. * * @return A list of {@link Element} objects. * @see Element */ public Element[] getElements() { return elements; } /** * Sets elements to the list of {@link Element} objects provided. * * @param elements The list of {@link Element} objects to set as the elements. * @see Element */ public void setElements(Element[] elements) { this.elements = elements; } @Override public String toString() { return "{" + "type='" + getType() + '\'' + ", ts=" + ts + ", endTs=" + endTs + ", elements=" + Arrays.toString(elements) + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/streaming/MessageType.java
package ai.rev.speechtotext.models.streaming; import com.google.gson.annotations.SerializedName; /** Specifies constants that define the WebSocket message type. */ public enum MessageType { /** The type of message sent when the WebSocket connects. */ @SerializedName("connected") CONNECTED("connected"), /** The type of message sent when the WebSocket returns a partial hypotheses. */ @SerializedName("partial") PARTIAL("partial"), /** The type of message sent when the WebSocket returns a final hypotheses. */ @SerializedName("final") FINAL("final"); private String messageType; MessageType(String messageType) { this.messageType = messageType; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getMessageType() { return messageType; } @Override public String toString() { return "{" + "messageType='" + messageType + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/streaming/SessionConfig.java
package ai.rev.speechtotext.models.streaming; /** The SessionConfig represents additional streaming options that can be provided. */ public class SessionConfig { private String metaData; private Boolean filterProfanity; private String customVocabularyId; private Boolean removeDisfluencies; private Integer deleteAfterSeconds; private Boolean detailedPartials; private Double startTs; private String transcriber; private String language; private Boolean skipPostprocessing; /** * Returns the metadata. * * @return The metadata. */ public String getMetaData() { return metaData; } /** * Specifies the metadata to be used in the submission request to /jobs. * * @param metaData The metadata to send with the request. */ public void setMetaData(String metaData) { this.metaData = metaData; } /** * Returns the value of the filter profanity option. * * @return The value of the filter profanity option. */ public Boolean getFilterProfanity() { return filterProfanity; } /** * Specifies whether or not the speech engine should filter profanity in the output. Setting the * profanity filter is optional. * * @param filterProfanity The option to filter profanity. * @see <a * href="https://docs.rev.ai/api/streaming/requests/#profanity-filter">https://docs.rev.ai/api/streaming/requests/#profanity-filter</a> */ public void setFilterProfanity(Boolean filterProfanity) { this.filterProfanity = filterProfanity; } /** * Returns the custom vocabulary ID. * * @return The custom vocabulary ID. */ public String getCustomVocabularyId() { return customVocabularyId; } /** * Specifies the ID of the custom vocabulary the speech engine should use while processing audio * samples. Custom vocabularies are submitted prior to usage in the stream and assigned an Id. * * @param customVocabularyId The ID of the custom vocabulary. */ public void setCustomVocabularyId(String customVocabularyId) { this.customVocabularyId = customVocabularyId; } /** * Returns the value of the remove disfluencies option. * * @return The value of the remove disfluencies option. */ public Boolean getRemoveDisfluencies() { return removeDisfluencies; } /** * Specifies whether or not the speech engine should remove disfluencies in the output. Setting * the option to remove disfluencies is optional. * * @param removeDisfluencies The option to filter profanity. * @see <a href="https://docs.rev.ai/api/streaming/requests/#disfluencies"> * https://docs.rev.ai/api/streaming/requests/#disfluencies * </a> */ public void setRemoveDisfluencies(Boolean removeDisfluencies) { this.removeDisfluencies = removeDisfluencies; } /** * Returns the value of deleteAfterSeconds. * * @return The deleteAfterSeconds value. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Specifies the number of seconds to be waited until the job is auto-deleted after its * completion. * * @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } /** * Returns the value of detailed partials option * * @return The value of the detailed partials option. */ public Boolean getDetailedPartials() { return detailedPartials; } /** * Specifies whether or not to return detailed partials. Setting the option is optional. * * @param detailedPartials The option to enable detailed partials. * @see <a href="https://docs.rev.ai/api/streaming/requests/#detailed-partials"> * https://docs.rev.ai/api/streaming/requests/#detailed-partials * </a> */ public void setDetailedPartials(Boolean detailedPartials) { this.detailedPartials = detailedPartials; } /** * Returns the value of startTs. * * @return The startTs value. */ public Double getStartTs() { return startTs; } /** * Specifies the number of seconds to offset all hypotheses timings. * * @param startTs The number of seconds to offset all hypotheses timings. */ public void setStartTs(Double startTs) { this.startTs = startTs; } /** * Returns the value of transcriber. * * @return The transcriber value. */ public String getTranscriber() { return transcriber; } /** * Specifies the type of transcriber to use to transcribe the media. * * @param transcriber The type of transcriber to use to transcribe the media. */ public void setTranscriber(String transcriber) { this.transcriber = transcriber; } /** * Returns the value of language. * * @return The language value. */ public String getLanguage() { return language; } /** * Specifies the language to use for the streaming job. * * @param language The language to use for the streaming job. */ public void setLanguage(String language) { this.language = language; } /** * Returns the value of the skip postprocessing Boolean. * * @return The skip postprocessing value. */ public Boolean getSkipPostprocessing() { return skipPostprocessing; } /** * Specifies if all postprocessing (capitalization, punctuation, ITN) will be skipped by the speech engine. This property is * optional and defaults to false. * * @param skipPostprocessing The value of the Boolean. */ public void setSkipPostprocessing(Boolean skipPostprocessing) { this.skipPostprocessing = skipPostprocessing; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/streaming/StreamContentType.java
package ai.rev.speechtotext.models.streaming; import java.util.ArrayList; import java.util.List; /** * The StreamContentType describes the format of the audio being sent over the WebSocket. * * @see <a * href="https://docs.rev.ai/api/streaming/requests/#content-type">https://docs.rev.ai/api/streaming/requests/#content-type</a> */ public class StreamContentType { private String contentType; private String layout; private Integer rate; private String format; private Integer channels; public StreamContentType() {} /** * Returns the content type. * * @return The content type. */ public String getContentType() { return contentType; } /** * Specifies the content type of the audio. * * @param contentType The type of audio. * @see <a * href="https://docs.rev.ai/api/streaming/requests/#content-type">https://docs.rev.ai/api/streaming/requests/#content-type</a> */ public void setContentType(String contentType) { this.contentType = contentType; } /** * Returns the channel layout. * * @return The channel layout. */ public String getLayout() { return layout; } /** * Specifies the layout of channels within the buffer. * * @param layout The channel layout. * @see <a * href="https://docs.rev.ai/api/streaming/requests/#content-type">https://docs.rev.ai/api/streaming/requests/#content-type</a> */ public void setLayout(String layout) { this.layout = layout; } /** * Returns the audio sample rate. * * @return The audio sample rate. */ public Integer getRate() { return rate; } /** * Specifies the sample rate of the audio. * * @param rate The sample rate of the audio. * @see <a * href="https://docs.rev.ai/api/streaming/requests/#content-type">https://docs.rev.ai/api/streaming/requests/#content-type</a> */ public void setRate(Integer rate) { this.rate = rate; } /** * Returns the format of the audio samples. * * @return The format of the audio samples. */ public String getFormat() { return format; } /** * Specifies the format of the audio samples. * * @param format The format of the audio samples. * @see <a * href="https://docs.rev.ai/api/streaming/requests/#content-type">https://docs.rev.ai/api/streaming/requests/#content-type</a> * @see <a * href="https://gstreamer.freedesktop.org/documentation/additional/design/mediatype-audio-raw.html?gi-language=c#formats">Valid * formats</a> */ public void setFormat(String format) { this.format = format; } /** * Returns the number of channels. * * @return The number of channels. */ public Integer getChannels() { return channels; } /** * Specifies the number of audio channels that the audio samples contain. * * @param channels the number of audio channels in the audio. * @see <a * href="https://docs.rev.ai/api/streaming/requests/#content-type">https://docs.rev.ai/api/streaming/requests/#content-type</a> */ public void setChannels(Integer channels) { this.channels = channels; } /** * Returns the content string compiled from the {@link StreamContentType} properties to be used in * the query parameter for the request to the /stream endpoint. * * @return The content string used as the query parameter. */ public String buildContentString() { List<String> content = getListFromContentType(); String empty = ""; if (content.size() == 0) { return empty; } else { return createContentTypeParameter(content); } } private List<String> getListFromContentType() { List<String> content = new ArrayList<>(); if (getContentType() != null) { content.add(getContentType()); } if (getLayout() != null) { content.add("layout" + "=" + getLayout()); } if (getRate() != null) { content.add("rate" + "=" + getRate()); } if (getFormat() != null) { content.add("format" + "=" + getFormat()); } if (getChannels() != null) { content.add("channels" + "=" + getChannels()); } return content; } private String createContentTypeParameter(List<String> content) { return String.join(";", content); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/streaming/StreamingResponseMessage.java
package ai.rev.speechtotext.models.streaming; import com.google.gson.annotations.SerializedName; /** * A parent class that can be used to serialize and deserialize the "type" in the WebSocket * messages. */ public class StreamingResponseMessage { @SerializedName("type") private MessageType type; /** * Returns the {@link MessageType} enumeration value. * * @return The enumeration value. */ public MessageType getType() { return type; } /** * Specifies the WebSocket message type. * * @param type The WebSocket message type. */ public void setType(MessageType type) { this.type = type; } @Override public String toString() { return "{" + "'type'='" + type + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/vocabulary/CustomVocabulary.java
package ai.rev.speechtotext.models.vocabulary; import java.util.List; /** * A CustomVocabulary object provides all the custom phrases that are submitted along with a job. */ public class CustomVocabulary { private List<String> phrases; /** * Creates a new custom vocabulary with a list of phrases limited to alphabetic characters and * spaces. List size cannot exceed 20000 items. * * @param phrases A list of strings limited to alphabetic characters and spaces. */ public CustomVocabulary(List<String> phrases) { this.phrases = phrases; } /** * Returns a list of phrases * * @return A list of phrases */ public List<String> getPhrases() { return phrases; } /** * Sets the list of phrases to be used in the custom vocabulary. Phrases are limited to alphabetic * characters and spaces. List size cannot exceed 20000 items. * * @param phrases The list of strings to set as the custom vocabulary phrases. */ public void setPhrases(List<String> phrases) { this.phrases = phrases; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/vocabulary/CustomVocabularyFailureType.java
package ai.rev.speechtotext.models.vocabulary; import com.google.gson.annotations.SerializedName; public enum CustomVocabularyFailureType { /** The failure used when there is a processing error. */ @SerializedName("internal_processing") INTERNAL_PROCESSING("internal_processing"); private String failureType; CustomVocabularyFailureType(String failureType) { this.failureType = failureType; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getFailureType() { return failureType; } @Override public String toString() { return "{" + "failureType='" + failureType + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/vocabulary/CustomVocabularyInformation.java
package ai.rev.speechtotext.models.vocabulary; import com.google.gson.annotations.SerializedName; public class CustomVocabularyInformation { @SerializedName("id") private String id; @SerializedName("status") private CustomVocabularyStatus status; @SerializedName("created_on") private String createdOn; @SerializedName("completed_on") private String completedOn; @SerializedName("metadata") private String metadata; @SerializedName("callback_url") private String callbackUrl; @SerializedName("failure") private CustomVocabularyFailureType failure; @SerializedName("failure_detail") private String failureDetail; /** * Returns a String that contains the Custom Vocabulary Id. * * @return A String that contains the Custom Vocabulary Id. */ public String getId() { return id; } /** * Sets the custom vocabulary Id to the provided value. * * @param id The String value to set as the custom vocabulary Id. */ public void setId(String id) { this.id = id; } /** * Returns the {@link CustomVocabularyStatus} enumeration value. * * @return The {@link CustomVocabularyStatus} enumeration value. */ public CustomVocabularyStatus getStatus() { return status; } /** * Sets the status to the provided {@link CustomVocabularyStatus} enumeration value. * * @param status The enumeration value to set as the custom vocabulary status. */ public void setStatus(CustomVocabularyStatus status) { this.status = status; } /** * Returns a String that contains the date and time the custom vocabulary was created on in * ISO-8601 UTC form. * * @return A String that contains the date and time the custom vocabulary was created on in * ISO-8601 UTC form. */ public String getCreatedOn() { return createdOn; } /** * Sets the time and date the custom vocabulary was created on. * * @param createdOn The String value to set as the created on date and time. */ public void setCreatedOn(String createdOn) { this.createdOn = createdOn; } /** * Returns a String that contains the date and time the custom vocabulary was completed on in * ISO-8601 UTC form. * * @return A String that contains the date and time the custom vocabulary was completed on. */ public String getCompletedOn() { return completedOn; } /** * Sets the date and time the custom vocabulary was completed on. * * @param completedOn The String value to set as the date and time the job was completed on. */ public void setCompletedOn(String completedOn) { this.completedOn = completedOn; } /** * Returns the metadata provided in the submission request. * * @return A String containing the metadata provided in the submission request. */ public String getMetadata() { return metadata; } /** * Sets the metadata. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the callback url provided in the submission request. * * @return A String containing the callback url provided in the submission request. */ public String getCallbackUrl() { return callbackUrl; } /** * Sets the callback url. * * @param callbackUrl A String value to set as the callback url. */ public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the {@link CustomVocabularyFailureType} enumeration value. * * @return The {@link CustomVocabularyFailureType} enumeration value. */ public CustomVocabularyFailureType getFailure() { return failure; } /** * Sets the failure details to the provided value. * * @param failure A String to set as the failure details. */ public void setFailure(CustomVocabularyFailureType failure) { this.failure = failure; } /** * Returns a detailed, human readable explanation of the failure. * * @return A detailed, human readable explanation of the failure. */ public String getFailureDetail() { return failureDetail; } /** * Sets the failure detail to the provided value. * * @param failureDetail A String to set as the failure detail. */ public void setFailureDetail(String failureDetail) { this.failureDetail = failureDetail; } @Override public String toString() { return "{" + "id='" + id + '\'' + ", status=" + status + ", createdOn='" + createdOn + '\'' + ", callbackUrl='" + callbackUrl + '\'' + ", failure=" + failure + ", failureDetail='" + failureDetail + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/vocabulary/CustomVocabularyStatus.java
package ai.rev.speechtotext.models.vocabulary; import com.google.gson.annotations.SerializedName; public enum CustomVocabularyStatus { /** The status when custom vocabulary has been processed and completed. */ @SerializedName("complete") COMPLETE("complete"), /** The status when the custom vocabulary job has failed. */ @SerializedName("failed") FAILED("failed"), /** The status when the custom vocabulary job is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"); private String status; CustomVocabularyStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/speechtotext/models/vocabulary/CustomVocabularySubmission.java
package ai.rev.speechtotext.models.vocabulary; import ai.rev.speechtotext.models.CustomerUrlData; import com.google.gson.annotations.SerializedName; import java.util.List; import java.util.Map; public class CustomVocabularySubmission { /** Optional information that can be provided. */ @SerializedName("metadata") private String metadata; /** * Optional callback url that Rev AI will send a POST to when the job has finished. * @deprecated Use notification_config instead */ @SerializedName("callback_url") @Deprecated private String callbackUrl; /** Optional parameter for information on the callback url that Rev AI will send a POST to when the job has finished. */ @SerializedName("notification_config") private CustomerUrlData notificationConfig; /** Array of {@link CustomVocabulary} objects. */ @SerializedName("custom_vocabularies") private List<CustomVocabulary> customVocabularies; /** * Returns the metadata. * * @return A String that contains the metadata. */ public String getMetadata() { return metadata; } /** * Optional metadata that is provided during custom vocabulary submission limited to 512 * characters. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the callback url. * * @return the callback url. * @deprecated Set the notificationConfig option with setNotificationConfig, then use getNotificationConfig instead */ @Deprecated public String getCallbackUrl() { return callbackUrl; } /** * Specifies the callback url that Rev AI will POST to when custom vocabulary processing is * complete. This property is optional. * * @param callbackUrl The url to POST to when custom vocabulary processing is complete. * @deprecated Use setNotificationConfig instead */ @Deprecated public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the notification config. * * @return the notification config. */ public CustomerUrlData getNotificationConfig() { return notificationConfig; } /** * Specifies the callback url that Rev AI will POST to when custom vocabulary processing is * complete and the auth headers to use when calling the url * This property is optional. * * @param callbackUrl The url to POST to when custom vocabulary processing is complete. * @param authHeaders Optional parameter to authenticate access to the callback url */ public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) { this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders); } /** * Specifies the callback url that Rev AI will POST to when custom vocabulary processing is * complete * This property is optional. * * @param callbackUrl The url to POST to when custom vocabulary processing is complete. */ public void setNotificationConfig(String callbackUrl) { this.notificationConfig = new CustomerUrlData(callbackUrl, null); } /** * Returns a list of {@link CustomVocabulary} objects. * * @return A list of {@link CustomVocabulary} objects. * @see CustomVocabulary */ public List<CustomVocabulary> getCustomVocabularies() { return customVocabularies; } /** * Provides the custom vocabularies to be used by the speech engine when processing the stream. * List size is limited to 50 items. * * @param customVocabularies A list of custom vocabularies. * @see CustomVocabulary */ public void setCustomVocabularies(List<CustomVocabulary> customVocabularies) { this.customVocabularies = customVocabularies; } @Override public String toString() { return "{" + "metadata='" + metadata + '\'' + ", callbackUrl='" + callbackUrl + '\'' + ", customVocabularies=" + customVocabularies + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/TopicExtractionClient.java
package ai.rev.topicextraction; import ai.rev.helpers.ClientHelper; import ai.rev.topicextraction.models.TopicExtractionJob; import ai.rev.topicextraction.models.TopicExtractionJobOptions; import ai.rev.topicextraction.models.TopicExtractionResult; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The TopicExtractionClient object provides methods to send and retrieve information from all the * Rev AI Topic Extraction API endpoints using the Retrofit HTTP client. */ public class TopicExtractionClient { private OkHttpClient client; /** Interface that TopicExtractionClient methods use to make requests */ public TopicExtractionInterface apiInterface; /** * Constructs the API client used to send HTTP requests to Rev AI. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev AI authorization token associate with the account. * @throws IllegalArgumentException If the access token is null or empty. */ public TopicExtractionClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client, "topic_extraction", "v1"); this.apiInterface = retrofit.create(TopicExtractionInterface.class); } /** Manually closes the connection when the code is running in a JVM */ public void closeConnection() { client.dispatcher().executorService().shutdown(); client.connectionPool().evictAll(); } /** * This method sends a GET request to the /jobs endpoint and returns a list of {@link TopicExtractionJob} * objects. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @param startingAfter The job ID at which the list begins. * @return A list of {@link TopicExtractionJob} objects. * @throws IOException If the response has a status code > 399. * @see TopicExtractionJob * @see <a * href="https://docs.rev.ai/api/topic-extraction/reference/#operation/GetListOfTopicExtractionJobs">https://docs.rev.ai/api/topic-extraction/reference/#operation/GetListOfTopicExtractionJobs</a> */ public List<TopicExtractionJob> getListOfJobs(Integer limit, String startingAfter) throws IOException { Map<String, String> options = new HashMap<>(); if (startingAfter != null) { options.put("starting_after", startingAfter); } if (limit != null) { options.put("limit", String.valueOf(limit)); } return apiInterface.getListOfJobs(options).execute().body(); } /** * Overload of {@link TopicExtractionClient#getListOfJobs(Integer, String)} without the optional startingAfter * parameter. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @return A list of {@link TopicExtractionJob} objects. * @throws IOException If the response has a status code > 399. */ public List<TopicExtractionJob> getListOfJobs(Integer limit) throws IOException { return getListOfJobs(limit, null); } /** * Overload of {@link TopicExtractionClient#getListOfJobs(Integer, String)} without the optional limit * parameter. * * @param startingAfter The job ID at which the list begins. * @return A list of {@link TopicExtractionJob} objects. * @throws IOException If the response has a status code > 399. */ public List<TopicExtractionJob> getListOfJobs(String startingAfter) throws IOException { return getListOfJobs(null, startingAfter); } /** * Overload of {@link TopicExtractionClient#getListOfJobs(Integer, String)} without the optional limit and * startingAfter parameter. * * @return A list of {@link TopicExtractionJob} objects. * @throws IOException If the response has a status code > 399. */ public List<TopicExtractionJob> getListOfJobs() throws IOException { return getListOfJobs(null, null); } /** * This method sends a GET request to the /jobs/{id} endpoint and returns a {@link TopicExtractionJob} * object. * * @param id The ID of the job to return an object for. * @return A {@link TopicExtractionJob} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. */ public TopicExtractionJob getJobDetails(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Job ID must be provided"); } return apiInterface.getJobDetails(id).execute().body(); } /** * This method sends a DELETE request to the /jobs/{id} endpoint. * * @param id The Id of the job to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. * @see <a * href="https://docs.rev.ai/api/topic-extraction/reference/#operation/DeleteTopicExtractionJobById">https://docs.rev.ai/api/topic-extraction/reference/#operation/DeleteTopicExtractionJobById</a> */ public void deleteJob(String id) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } apiInterface.deleteJob(id).execute(); } /** * The method sends a GET request to the /jobs/{id}/result endpoint and returns a {@link * TopicExtractionResult} object. * * @param id The ID of the job to return a result for. * @return TopicExtractionResult The result object. * @throws IOException If the response has a status code > 399. * @see TopicExtractionResult */ public TopicExtractionResult getResultObject(String id, Double threshold) throws IOException { Map<String, Object> options = new HashMap<>(); options.put("threshold", threshold); return apiInterface.getResultObject(id, options).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/result endpoint and returns a {@link * TopicExtractionResult} object. * * @param id The ID of the job to return a result for. * @return TopicExtractionResult The result object. * @throws IOException If the response has a status code > 399. * @see TopicExtractionResult */ public TopicExtractionResult getResultObject(String id) throws IOException { Map<String, Object> options = new HashMap<>(); return apiInterface.getResultObject(id, options).execute().body(); } /** * The method sends a POST request to the /jobs endpoint, starts a topic extraction job for the * provided text and returns a {@link TopicExtractionJob} object. * * @param text Text to have topics extracted from it. * @param options The topic extraction options associated with this job. * @return TopicExtractionJob A representation of the topic extraction job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the text is null. * @see TopicExtractionJob * @see <a * href="https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob">https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob</a> */ public TopicExtractionJob submitJobText(String text, TopicExtractionJobOptions options) throws IOException { if (text == null) { throw new IllegalArgumentException("Text must be provided"); } if (options == null) { options = new TopicExtractionJobOptions(); } options.setText(text); return apiInterface.submitJob(options).execute().body(); } /** * An overload of {@link TopicExtractionClient#submitJobText(String, TopicExtractionJobOptions)} without the additional * topic extraction options. * * @param text Text to have topics extracted from it. * @return TopicExtractionJob A representation of the topic extraction job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the text is null. * @see TopicExtractionJob * @see TopicExtractionClient#submitJobText(String, TopicExtractionJobOptions) */ public TopicExtractionJob submitJobText(String text) throws IOException { return submitJobText(text, null); } /** * The method sends a POST request to the /jobs endpoint, starts a topic extraction job for the * provided RevAiTranscript and returns a {@link TopicExtractionJob} object. * * @param json RevAiTranscript to submit for topic extraction * @param options The topic extraction options associated with this job. * @return TopicExtractionJob A representation of the topic extraction job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the json is null. * @see TopicExtractionJob * @see <a * href="https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob">https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob</a> */ public TopicExtractionJob submitJobJson(RevAiTranscript json, TopicExtractionJobOptions options) throws IOException { if (json == null) { throw new IllegalArgumentException("Json must be provided"); } if (options == null) { options = new TopicExtractionJobOptions(); } options.setJson(json); return apiInterface.submitJob(options).execute().body(); } /** * An overload of {@link TopicExtractionClient#submitJobText(String, TopicExtractionJobOptions)} without the additional * topic extraction options. * * @param json RevAiTranscript to submit for topic extraction * @return TopicExtractionJob A representation of the topic extraction job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the json is null. * @see TopicExtractionJob * @see TopicExtractionClient#submitJobJson(RevAiTranscript, TopicExtractionJobOptions) */ public TopicExtractionJob submitJobJson(RevAiTranscript json) throws IOException { return submitJobJson(json, null); } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/TopicExtractionInterface.java
package ai.rev.topicextraction; import ai.rev.topicextraction.models.TopicExtractionJob; import ai.rev.topicextraction.models.TopicExtractionJobOptions; import ai.rev.topicextraction.models.TopicExtractionResult; import okhttp3.MultipartBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.HeaderMap; import retrofit2.http.Headers; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.QueryMap; import java.util.List; import java.util.Map; /** * The TopicExtractionInterface is a type-safe Retrofit interface that presents all the endpoints that are made * to communicate with the Rev AI Topic Extraction API. */ public interface TopicExtractionInterface { String REV_TOPIC_CONTENT_TYPE = "application/vnd.rev.topic.v1.0+json"; @GET("jobs/{id}") Call<TopicExtractionJob> getJobDetails(@Path("id") String jobID); @GET("jobs") Call<List<TopicExtractionJob>> getListOfJobs(@QueryMap Map<String, String> options); @Headers("Accept: " + REV_TOPIC_CONTENT_TYPE) @GET("jobs/{id}/result") Call<TopicExtractionResult> getResultObject(@Path("id") String jobID, @QueryMap Map<String, Object> options); @POST("jobs") Call<TopicExtractionJob> submitJob(@Body TopicExtractionJobOptions options); @DELETE("jobs/{id}") Call<Void> deleteJob(@Path("id") String jobID); }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/models/Informant.java
package ai.rev.topicextraction.models; import com.google.gson.annotations.SerializedName; /** * Represents a piece of the input which informed a choice of a topic. */ public class Informant { /** * Content of the input that makes up the informant */ @SerializedName("content") private String content; /** * Start timestamp of the content in the input if available */ @SerializedName("ts") private Double startTimestamp; /** * End timestamp of the content in the input if available */ @SerializedName("end_ts") private Double endTimestamp; /** * Character index at which the content started in the source transcript, * excludes invisible characters. */ @SerializedName("offset") private Integer offset; /** * Length of the content in characters, excludes invisible characters. */ @SerializedName("length") private Integer length; /** * Returns the content of the informant * * @return the content of the informant */ public String getContent() { return content; } /** * Sets the content of the informant * * @param content content to be set */ public void setContent(String content) { this.content = content; } /** * Returns the start timestamp of the content in the input * * @return the start timestamp of the content in the input */ public Double getStartTimestamp() { return startTimestamp; } /** * Sets the start timestamp of the content in the input * * @param startTimestamp the start timestamp to be set */ public void setStartTimestamp(Double startTimestamp) { this.startTimestamp = startTimestamp; } /** * Returns the end timestamp of the content in the input * * @return the end timestamp of the content in the input */ public Double getEndTimestamp() { return endTimestamp; } /** * Sets the end timestamp of the content in the input * * @param endTimestamp the end timestamp to be set */ public void setEndTimestamp(Double endTimestamp) { this.endTimestamp = endTimestamp; } /** * Returns the character index at which the content started in the input * * @return the character index at which the content started in the input */ public Integer getOffset() { return offset; } /** * Sets the character index at which the content started in the input * * @param offset the character index to be set */ public void setOffset(Integer offset) { this.offset = offset; } /** * Returns the character length of the content * * @return the character length of the content */ public Integer getLength() { return length; } /** * Sets the character length of the content * * @param length the character length to be set */ public void setLength(Integer length) { this.length = length; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/models/Topic.java
package ai.rev.topicextraction.models; import com.google.gson.annotations.SerializedName; import java.util.List; /** * Represents a single topic in the input as well as all the information that comes with it. */ public class Topic { /** * Name of the topic, pulled directly from somewhere in the input text. */ @SerializedName("topic_name") private String topicName; /** * Score of the topic, between 0 and 1. Higher means it is more likely that this * is truly a topic. */ @SerializedName("score") private Double score; /** * Pieces of the input text which informed this choice of topic. */ @SerializedName("informants") private List<Informant> informants; /** * Returns the topic name. * * @return The topic name. */ public String getTopicName() { return topicName; } /** * Specifies the topic name. * * @param topicName the topic name. */ public void setTopicName(String topicName) { this.topicName = topicName; } /** * Returns the score. * * @return The score. */ public Double getScore() { return score; } /** * Specifies the score. * * @param score score of the topic. */ public void setScore(Double score) { this.score = score; } /** * Returns the informants. * * @return The list of informants. * @see Informant */ public List<Informant> getInformants() { return informants; } /** * Specifies the list of informants. * * @param informants the list of informants for the topic. */ public void setInformants(List<Informant> informants) { this.informants = informants; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/models/TopicExtractionJob.java
package ai.rev.topicextraction.models; import ai.rev.speechtotext.models.asynchronous.RevAiJobType; import ai.rev.speechtotext.models.asynchronous.RevAiFailureType; import java.util.List; import com.google.gson.annotations.SerializedName; /** A Topic Extraction Job object provides all the information associated with a job submitted by the user. */ public class TopicExtractionJob { @SerializedName("id") private String jobId; @SerializedName("status") private TopicExtractionJobStatus jobStatus; @SerializedName("created_on") private String createdOn; @SerializedName("completed_on") private String completedOn; @SerializedName("callback_url") private String callbackUrl; @SerializedName("word_count") private Integer wordCount; @SerializedName("metadata") private String metadata; @SerializedName("type") private RevAiJobType type; @SerializedName("failure_details") private String failureDetails; @SerializedName("failure") private RevAiFailureType failure; @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; @SerializedName("language") private String language; /** * Returns a String that contains the job ID. * * @return A String that contains the job ID. */ public String getJobId() { return jobId; } /** * Sets the Job ID. * * @param jobId The String value to set as the job ID. */ public void setJobId(String jobId) { this.jobId = jobId; } /** * Returns the {@link TopicExtractionJobStatus} enumeration value. * * @return The {@link TopicExtractionJobStatus} enumeration value. * @see TopicExtractionJobStatus */ public TopicExtractionJobStatus getJobStatus() { return jobStatus; } /** * Sets the job status to the provided {@link TopicExtractionJobStatus} enumeration value. * * @param jobStatus The enumeration value to set as the job status. * @see TopicExtractionJobStatus */ public void setJobStatus(TopicExtractionJobStatus jobStatus) { this.jobStatus = jobStatus; } /** * Returns a String that contains the date and time the job was created on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was created on in ISO-8601 UTC form. */ public String getCreatedOn() { return createdOn; } /** * Sets the time and date the job was created on. * * @param createdOn The String value to set as the created on date and time. */ public void setCreatedOn(String createdOn) { this.createdOn = createdOn; } /** * Returns a String that contains the date and time the job was completed on in ISO-8601 UTC form. * * @return A String that contains the date and time the job was completed on in ISO-8601 UTC form. */ public String getCompletedOn() { return completedOn; } /** * Set the date and time the job was completed on. * * @param completedOn The String value to set as the date and time the job was completed on. */ public void setCompletedOn(String completedOn) { this.completedOn = completedOn; } /** * Returns the callback url provided in the submission request. * * @return A String containing the callback url provided in the submission request. */ public String getCallbackUrl() { return callbackUrl; } /** * Sets the callback url. * * @param callbackUrl A String value to set as the callback url. */ public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the word count of the submission. * * @return A String containing the word count of the submission. */ public Integer getWordCount() { return wordCount; } /** * Sets the word count. * * @param wordCount An Integer value to set as the word count. */ public void setWordCount(Integer wordCount) { this.wordCount = wordCount; } /** * Returns the metadata provided in the submission request. * * @return A String containing the metadata provided in the submission request. */ public String getMetadata() { return metadata; } /** * Sets the metadata. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the {@link RevAiJobType} enumeration value. * * @return the enumeration value. * @see RevAiJobType */ public RevAiJobType getType() { return type; } /** * Sets the job type to the provided {@link RevAiJobType} enumeration. * * @param type The enumeration value to set as the job type. * @see RevAiJobType */ public void setType(RevAiJobType type) { this.type = type; } /** * Returns a detailed, human readable explanation of the failure. * * @return A detailed, human readable explanation of the failure. */ public String getFailureDetails() { return failureDetails; } /** * Sets the failure details to the provided value. * * @param failureDetails A String to set as the failure details. */ public void setFailureDetails(String failureDetails) { this.failureDetails = failureDetails; } /** * Returns the {@link RevAiFailureType} enumeration value. * * @return The {@link RevAiFailureType} enumeration value. * @see RevAiFailureType */ public RevAiFailureType getFailure() { return failure; } /** * Sets the failure to the provided {@link RevAiFailureType} enumeration. * * @param failure The enumeration value to set as the failure. * @see RevAiFailureType */ public void setFailure(RevAiFailureType failure) { this.failure = failure; } /** * Returns the duration in seconds before job is deleted * * @return The duration in seconds. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Sets the duration in seconds before job is deleted * * @param deleteAfterSeconds An Integer value to set as seconds before deletion. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } /** * Returns language of the job * * @return language of the job */ public String getLanguage() { return language; } /** * Sets the language for job * * @param language An String value to set for language */ public void setLanguage(String language) { this.language = language; } @Override public String toString() { return "{" + "jobID='" + jobId + '\'' + ", jobStatus=" + jobStatus + ", createdOn='" + createdOn + '\'' + ", completedOn='" + completedOn + '\'' + ", callbackUrl='" + callbackUrl + '\'' + ", wordCount='" + wordCount + '\'' + ", metadata='" + metadata + '\'' + ", type='" + type.getJobType() + '\'' + ", failureDetails='" + failureDetails + '\'' + ", failure='" + failure.getFailureType() + '\'' + ", language='" + language + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/models/TopicExtractionJobOptions.java
package ai.rev.topicextraction.models; import ai.rev.speechtotext.models.CustomerUrlData; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import com.google.gson.annotations.SerializedName; import java.util.Map; /** * A TopicExtractionJobOptions object represents parameters that are submitted along a new job. * * @see <a * href="https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob">https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob</a> */ public class TopicExtractionJobOptions { /** * Plain text string to be topic extracted. */ @SerializedName("text") private String text; /** * RevAiTranscript from an async speech to text job to be topic extracted */ @SerializedName("json") private RevAiTranscript json; /** * The callback url that Rev AI will send a POST to when the job has finished. * @deprecated Use notification_config instead */ @SerializedName("callback_url") @Deprecated private String callbackUrl; /** Object containing information on the callback url that Rev AI will send a POST to when the job has finished. */ @SerializedName("notification_config") private CustomerUrlData notificationConfig; /** * Optional information that can be provided. */ @SerializedName("metadata") private String metadata; /** * Optional number of seconds after job completion when job is auto-deleted */ @SerializedName("delete_after_seconds") private Integer deleteAfterSeconds; /** * Returns the text. * * @return the text. */ public String getText() { return text; } /** * Specifies plain text that will have topic extraction run on it * * @param text plain text to be topic extracted. */ public void setText(String text) { this.text = text; } /** * Returns the json. * * @return the json. */ public RevAiTranscript getJson() { return json; } /** * Specifies a RevAiTranscript from the async api that will have topic extraction run on it * * @param json RevAiTranscript to be topic extracted. */ public void setJson(RevAiTranscript json) { this.json = json; } /** * Returns the callback url. * * @return the callback url. * @deprecated Use notificationConfig and getNotificationConfig instead */ @Deprecated public String getCallbackUrl() { return callbackUrl; } /** * Specifies the callback url that Rev AI will POST to when job processing is complete. This * property is optional. * * @param callbackUrl The url to POST to when job processing is complete. * @deprecated Use setNotificationConfig instead */ @Deprecated public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } /** * Returns the notification config object. * * @return the notification config. */ public CustomerUrlData getNotificationConfig() { return notificationConfig; } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. * @param authHeaders Optional parameter to authenticate access to the callback url */ public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) { this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders); } /** * Optional property to specify the callback url that Rev AI will POST to when job processing is complete * * @param callbackUrl The url to POST to when job processing is complete. */ public void setNotificationConfig(String callbackUrl) { setNotificationConfig(callbackUrl, null); } /** * Returns the metadata. * * @return A String that contains the metadata. */ public String getMetadata() { return metadata; } /** * Optional metadata that is provided during job submission limited to 512 characters. * * @param metadata A String to set as the metadata. */ public void setMetadata(String metadata) { this.metadata = metadata; } /** * Returns the value of deleteAfterSeconds. * * @return The deleteAfterSeconds value. */ public Integer getDeleteAfterSeconds() { return deleteAfterSeconds; } /** * Specifies the number of seconds to be waited until the job is auto-deleted after its * completion. * * @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted. */ public void setDeleteAfterSeconds(Integer deleteAfterSeconds) { this.deleteAfterSeconds = deleteAfterSeconds; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/models/TopicExtractionJobStatus.java
package ai.rev.topicextraction.models; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Rev AI job statuses. */ public enum TopicExtractionJobStatus { /** The status when job has failed. */ @SerializedName("failed") FAILED("failed"), /** The status when job is in progress. */ @SerializedName("in_progress") IN_PROGRESS("in_progress"), /** The status when job processing has been completed. */ @SerializedName("completed") COMPLETED("completed"); private String status; TopicExtractionJobStatus(String status) { this.status = status; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getStatus() { return status; } @Override public String toString() { return "{" + "status='" + status + '\'' + '}'; } }
0
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction
java-sources/ai/rev/revai-java-sdk/2.5.0/ai/rev/topicextraction/models/TopicExtractionResult.java
package ai.rev.topicextraction.models; import java.util.List; import com.google.gson.annotations.SerializedName; /** A Topic Extraction Result object provides all the information associated with the result of a job. */ public class TopicExtractionResult { /** * Topics detected in the input text, ordered by score */ @SerializedName("topics") private List<Topic> topics; /** * Get the topics of the result. * * @return The topics of the result */ public List<Topic> getTopics() { return topics; } /** * Set the topics of the result. * * @param topics the topics to be set for the result. */ public void setTopics(List<Topic> topics) { this.topics = topics; } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/ApiClient.java
package ai.rev.speechtotext; import ai.rev.speechtotext.helpers.ClientHelper; import ai.rev.speechtotext.models.asynchronous.RevAiAccount; import ai.rev.speechtotext.models.asynchronous.RevAiCaptionType; import ai.rev.speechtotext.models.asynchronous.RevAiJob; import ai.rev.speechtotext.models.asynchronous.RevAiJobOptions; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.RequestBody; import retrofit2.Retrofit; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The ApiClient object provides methods to send and retrieve information from all the Rev.AI API * endpoints using the Retrofit HTTP client. */ public class ApiClient { private OkHttpClient client; /** Interface that ApiClient methods use to make requests */ public ApiInterface apiInterface; /** * Constructs the API client used to send HTTP requests to Rev.ai. The user access token can be * generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev.ai authorization token associate with the account. * @throws IllegalArgumentException If the access token is null or empty. */ public ApiClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client); this.apiInterface = retrofit.create(ApiInterface.class); } /** Manually closes the connection when the code is running in a JVM */ public void closeConnection() { client.dispatcher().executorService().shutdown(); client.connectionPool().evictAll(); } /** * This method sends a GET request to the /account endpoint and returns an {@link RevAiAccount} * object. * * @return RevAiAccount The object containing basic Rev.ai account information * @throws IOException If the response has a status code > 399. * @see RevAiAccount */ public RevAiAccount getAccount() throws IOException { return apiInterface.getAccount().execute().body(); } /** * This method sends a GET request to the /jobs endpoint and returns a list of {@link RevAiJob} * objects. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @param startingAfter The job ID at which the list begins. * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/GetListOfJobs">https://www.rev.ai/docs#operation/GetListOfJobs</a> */ public List<RevAiJob> getListOfJobs(Integer limit, String startingAfter) throws IOException { Map<String, String> options = new HashMap<>(); if (startingAfter != null) { options.put("starting_after", startingAfter); } if (limit != null) { options.put("limit", String.valueOf(limit)); } return apiInterface.getListOfJobs(options).execute().body(); } /** * Overload of {@link ApiClient#getListOfJobs(Integer, String)} without the optional startingAfter * parameter. * * @param limit The maximum number of jobs to return. The default is 100, max is 1000. * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. */ public List<RevAiJob> getListOfJobs(Integer limit) throws IOException { return getListOfJobs(limit, null); } /** * Overload of {@link ApiClient#getListOfJobs(Integer, String)} without the optional limit * parameter. * * @param startingAfter The job ID at which the list begins. * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. */ public List<RevAiJob> getListOfJobs(String startingAfter) throws IOException { return getListOfJobs(null, startingAfter); } /** * Overload of {@link ApiClient#getListOfJobs(Integer, String)} without the optional limit and * startingAfter parameter. * * @return A list of {@link RevAiJob} objects. * @throws IOException If the response has a status code > 399. */ public List<RevAiJob> getListOfJobs() throws IOException { return getListOfJobs(null, null); } /** * This method sends a GET request to the /jobs/{id} endpoint and returns a {@link RevAiJob} * object. * * @param id The ID of the job to return an object for. * @return A {@link RevAiJob} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. */ public RevAiJob getJobDetails(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Job ID must be provided"); } return apiInterface.getJobDetails(id).execute().body(); } /** * This method sends a DELETE request to the /jobs/{id} endpoint. * * @param id The Id of the job to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID is null. * @see <a * href="https://www.rev.ai/docs#operation/DeleteJobById">https://www.rev.ai/docs#operation/DeleteJobById</a> */ public void deleteJob(String id) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } apiInterface.deleteJob(id).execute(); } /** * The method sends a GET request to the /jobs/{id}/transcript endpoint and returns a {@link * RevAiTranscript} object. * * @param id The ID of the job to return a transcript for. * @return RevAiTranscript The transcript object. * @throws IOException If the response has a status code > 399. * @see RevAiTranscript */ public RevAiTranscript getTranscriptObject(String id) throws IOException { return apiInterface.getTranscriptObject(id).execute().body(); } /** * The method sends a GET request to the /jobs/{id}/transcript endpoint and returns the transcript * as a String. * * @param id The ID of the job to return a transcript for. * @return The transcript as a String in text format. * @throws IOException If the response has a status code > 399. */ public String getTranscriptText(String id) throws IOException { return apiInterface.getTranscriptText(id).execute().body(); } /** * The method sends a POST request to the /jobs endpoint, starts an asynchronous job to transcribe * the media file located at the url provided and returns a {@link RevAiJob} object. * * @param mediaUrl A direct download link to the media. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException if the media url is null. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/SubmitTranscriptionJob">https://www.rev.ai/docs#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobUrl(String mediaUrl, RevAiJobOptions options) throws IOException { if (mediaUrl == null) { throw new IllegalArgumentException("Media url must be provided"); } if (options == null) { options = new RevAiJobOptions(); } options.setMediaUrl(mediaUrl); return apiInterface.submitJobUrl(options).execute().body(); } /** * An overload of {@link ApiClient#submitJobUrl(String, RevAiJobOptions)} without the additional * transcription options. * * @param mediaUrl A direct download link to the media. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see ApiClient#submitJobUrl(String, RevAiJobOptions) */ public RevAiJob submitJobUrl(String mediaUrl) throws IOException { return submitJobUrl(mediaUrl, null); } /** * The method sends multipart/form request to the /jobs endpoint, starts an asynchronous job to * transcribe the local media file provided and returns a {@link RevAiJob} object. * * @param filePath A local path to the file on the computer. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the file path is null. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/SubmitTranscriptionJob">https://www.rev.ai/docs#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(String filePath, RevAiJobOptions options) throws IOException { if (filePath == null) { throw new IllegalArgumentException("File path must be provided"); } if (options == null) { options = new RevAiJobOptions(); } File file = new File(filePath); return submitMultipartRequest( new FileInputStream(file.getAbsoluteFile()), file.getName(), options); } /** * An overload of {@link ApiClient#submitJobLocalFile(String, RevAiJobOptions)} without the * additional transcription options. * * @param filePath A local path to the file on the computer. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see ApiClient#submitJobLocalFile(String, RevAiJobOptions) */ public RevAiJob submitJobLocalFile(String filePath) throws IOException { return submitJobLocalFile(filePath, null); } /** * The method sends a POST request to the /jobs endpoint, starts an asynchronous job to transcribe * the media file provided by InputStream and returns a {@link RevAiJob} object. * * @param inputStream An InputStream of the media file. * @param fileName The name of the file being streamed. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the InputStream provided is null. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/SubmitTranscriptionJob">https://www.rev.ai/docs#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile( InputStream inputStream, String fileName, RevAiJobOptions options) throws IOException { if (inputStream == null) { throw new IllegalArgumentException("File stream must be provided"); } if (options == null) { options = new RevAiJobOptions(); } if (fileName == null) { fileName = "audio_file"; } return submitMultipartRequest(inputStream, fileName, options); } /** * An overload of {@link ApiClient#submitJobLocalFile(InputStream, String, RevAiJobOptions)} * without the optional filename and transcription options. * * @param inputStream An InputStream of the media file. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/SubmitTranscriptionJob">https://www.rev.ai/docs#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(InputStream inputStream) throws IOException { return submitJobLocalFile(inputStream, null, null); } /** * An overload of {@link ApiClient#submitJobLocalFile(InputStream, String, RevAiJobOptions)} * without the additional transcription options. * * @param inputStream An InputStream of the media file. * @param fileName The name of the file being streamed. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/SubmitTranscriptionJob">https://www.rev.ai/docs#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(InputStream inputStream, String fileName) throws IOException { return submitJobLocalFile(inputStream, fileName, null); } /** * An overload of {@link ApiClient#submitJobLocalFile(InputStream, String, RevAiJobOptions)} * without the optional filename. * * @param inputStream An InputStream of the media file. * @param options The transcription options associated with this job. * @return RevAiJob A representation of the transcription job. * @throws IOException If the response has a status code > 399. * @see RevAiJob * @see <a * href="https://www.rev.ai/docs#operation/SubmitTranscriptionJob">https://www.rev.ai/docs#operation/SubmitTranscriptionJob</a> */ public RevAiJob submitJobLocalFile(InputStream inputStream, RevAiJobOptions options) throws IOException { return submitJobLocalFile(inputStream, null, options); } /** * The method sends a GET request to the /jobs/{id}/captions endpoint and returns captions for the * provided job ID in the form of an InputStream. * * @param id The ID of the job to return captions for. * @param captionType An enumeration of the desired caption type. Default is SRT. * @param channelId Identifies the audio channel of the file to output captions for. Default is * null. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://www.rev.ai/docs#operation/GetCaptions">https://www.rev.ai/docs#operation/GetCaptions</a> */ public InputStream getCaptions(String id, RevAiCaptionType captionType, Integer channelId) throws IOException { if (id == null) { throw new IllegalArgumentException("Job ID must be provided"); } Map<String, String> query = new HashMap<>(); if (channelId != null) { query.put("speaker_channel", channelId.toString()); } if (captionType == null) { captionType = RevAiCaptionType.SRT; } Map<String, String> contentHeader = new HashMap<>(); contentHeader.put("Accept", captionType.getContentType()); return apiInterface.getCaptionText(id, query, contentHeader).execute().body().byteStream(); } /** * An overload of {@link ApiClient#getCaptions(String, RevAiCaptionType, Integer)} without the * optional channel ID. * * @param id The ID of the job to return captions for. * @param captionType An enumeration of the desired caption type. Default is SRT * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://www.rev.ai/docs#operation/GetCaptions">https://www.rev.ai/docs#operation/GetCaptions</a> */ public InputStream getCaptions(String id, RevAiCaptionType captionType) throws IOException { return getCaptions(id, captionType, null); } /** * An overload of {@link ApiClient#getCaptions(String, RevAiCaptionType, Integer)} without the * optional caption type. * * @param id The ID of the job to return captions for. * @param channelId Identifies the audio channel of the file to output captions for. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://www.rev.ai/docs#operation/GetCaptions">https://www.rev.ai/docs#operation/GetCaptions</a> */ public InputStream getCaptions(String id, Integer channelId) throws IOException { return getCaptions(id, null, channelId); } /** * An overload of {@link ApiClient#getCaptions(String, RevAiCaptionType, Integer)} without the * optional caption type and channel ID. * * @param id The ID of the job to return captions for. * @return InputStream A stream of bytes that represents the caption output. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job ID provided is null. * @see <a * href="https://www.rev.ai/docs#operation/GetCaptions">https://www.rev.ai/docs#operation/GetCaptions</a> */ public InputStream getCaptions(String id) throws IOException { return getCaptions(id, null, null); } private RevAiJob submitMultipartRequest( InputStream inputStream, String fileName, RevAiJobOptions options) throws IOException { RequestBody fileRequest = FileStreamRequestBody.create(inputStream, MediaType.parse("audio/*")); MultipartBody.Part filePart = MultipartBody.Part.createFormData("media", fileName, fileRequest); return apiInterface.submitJobLocalFile(filePart, options).execute().body(); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/ApiInterceptor.java
package ai.rev.speechtotext; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import java.io.IOException; /** * An ApiInterceptor object appends authorization information to all API calls and is used to check * the status of the request for debugging purposes. */ public class ApiInterceptor implements Interceptor { private String accessToken; private String sdkVersion; public ApiInterceptor(String accessToken, String sdkVersion) { this.accessToken = accessToken; this.sdkVersion = sdkVersion; } @Override public Response intercept(Chain chain) throws IOException { Request request = chain .request() .newBuilder() .addHeader("Authorization", String.format("Bearer %s", accessToken)) .addHeader("User-Agent", String.format("RevAi-JavaSDK/%s", sdkVersion)) .build(); return chain.proceed(request); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/ApiInterface.java
package ai.rev.speechtotext; import ai.rev.speechtotext.models.asynchronous.RevAiAccount; import ai.rev.speechtotext.models.asynchronous.RevAiJob; import ai.rev.speechtotext.models.asynchronous.RevAiJobOptions; import ai.rev.speechtotext.models.asynchronous.RevAiTranscript; import okhttp3.MultipartBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.HeaderMap; import retrofit2.http.Headers; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; import retrofit2.http.Path; import retrofit2.http.QueryMap; import java.util.List; import java.util.Map; /** * The ApiInterface is a type-safe Retrofit interface that presents all the endpoints that are made * to communicate with the Rev.AI async API. */ public interface ApiInterface { String REV_JSON_CONTENT_TYPE = "application/vnd.rev.transcript.v1.0+json"; String REV_TEXT_CONTENT_TYPE = "text/plain"; @GET("account") Call<RevAiAccount> getAccount(); @GET("jobs/{id}") Call<RevAiJob> getJobDetails(@Path("id") String jobID); @GET("jobs") Call<List<RevAiJob>> getListOfJobs(@QueryMap Map<String, String> options); @Headers("Accept: " + REV_JSON_CONTENT_TYPE) @GET("jobs/{id}/transcript") Call<RevAiTranscript> getTranscriptObject(@Path("id") String jobID); @Headers("Accept: " + REV_TEXT_CONTENT_TYPE) @GET("jobs/{id}/transcript") Call<String> getTranscriptText(@Path("id") String jobID); @POST("jobs") Call<RevAiJob> submitJobUrl(@Body RevAiJobOptions options); @DELETE("jobs/{id}") Call<Void> deleteJob(@Path("id") String jobID); @Multipart @POST("jobs") Call<RevAiJob> submitJobLocalFile( @Part MultipartBody.Part file, @Part("options") RevAiJobOptions options); @GET("jobs/{id}/captions") Call<ResponseBody> getCaptionText( @Path("id") String jobID, @QueryMap Map<String, String> query, @HeaderMap Map<String, String> contentType); }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/CustomVocabulariesClient.java
package ai.rev.speechtotext; import ai.rev.speechtotext.helpers.ClientHelper; import ai.rev.speechtotext.models.vocabulary.CustomVocabularyInformation; import ai.rev.speechtotext.models.vocabulary.CustomVocabularySubmission; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import java.io.IOException; import java.util.List; /** * The CustomVocabularyClient object provides methods to interact with the Custom Vocabulary Api. */ public class CustomVocabulariesClient { private OkHttpClient client; /** Interface that CustomVocabularyClient methods use to make requests */ public CustomVocabularyApiInterface customVocabularyApiInterface; /** * Constructs the custom vocabulary client used to create custom vocabularies for streaming. The * user access token can be generated on the website at <a * href="https://www.rev.ai/access_token">https://www.rev.ai/access_token</a>. * * @param accessToken Rev.ai authorization token associate with the account. * @throws IllegalArgumentException If the access token is null or empty. */ public CustomVocabulariesClient(String accessToken) { if (accessToken == null || accessToken.isEmpty()) { throw new IllegalArgumentException("Access token must be provided"); } this.client = ClientHelper.createOkHttpClient(accessToken); Retrofit retrofit = ClientHelper.createRetrofitInstance(client); this.customVocabularyApiInterface = retrofit.create(CustomVocabularyApiInterface.class); } /** * This method makes a POST request to the /vocabularies endpoint and returns a {@link * CustomVocabularyInformation} object that provides details about the custom vocabulary * submission and its progress. * * @param submission An object that contains the custom vocabularies as well as optional metadata * and callback url * @return A {@link CustomVocabularyInformation} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the list of custom vocabularies is null or empty. * @see CustomVocabularyInformation */ public CustomVocabularyInformation submitCustomVocabularies(CustomVocabularySubmission submission) throws IOException { if (submission.getCustomVocabularies() == null || submission.getCustomVocabularies().isEmpty()) { throw new IllegalArgumentException("Custom vocabularies must be provided"); } return customVocabularyApiInterface.submitCustomVocabularies(submission).execute().body(); } /** * This method sends a GET request to the /vocabularies endpoint and returns a list of {@link * CustomVocabularyInformation} objects. * * @return A list of {@link CustomVocabularyInformation} objects. * @throws IOException If the response has a status code > 399. * @see CustomVocabularyInformation */ public List<CustomVocabularyInformation> getListOfCustomVocabularyInformation() throws IOException { return customVocabularyApiInterface.getListOfCustomVocabularyInformation().execute().body(); } /** * This method sends a GET request to the /vocabularies/{id} endpoint and returns a {@link * CustomVocabularyInformation} object. * * @param id The Id of the custom vocabulary to return an object for. * @return A {@link CustomVocabularyInformation} object. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the custom vocabulary Id is null. * @see CustomVocabularyInformation */ public CustomVocabularyInformation getCustomVocabularyInformation(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Custom vocabulary Id must be provided"); } return customVocabularyApiInterface.getCustomVocabularyInformation(id).execute().body(); } /** * This method sends a DELETE request to the /vocabularies/{id} endpoint. * * @param id The Id of the custom vocabulary to be deleted. * @throws IOException If the response has a status code > 399. * @throws IllegalArgumentException If the job Id is null. * @see <a * href="https://www.rev.ai/docs/streaming#operation/DeleteCustomVocabulary">https://www.rev.ai/docs/streaming#operation/DeleteCustomVocabulary</a> */ public void deleteCustomVocabulary(String id) throws IOException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Custom vocabulary Id must be provided"); } customVocabularyApiInterface.deleteCustomVocabulary(id).execute().body(); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/CustomVocabularyApiInterface.java
package ai.rev.speechtotext; import ai.rev.speechtotext.models.vocabulary.CustomVocabularyInformation; import ai.rev.speechtotext.models.vocabulary.CustomVocabularySubmission; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; import java.util.List; /** * The CustomVocabularyApiInterface is a type-safe Retrofit interface that presents all the * endpoints that are made to communicate with the Rev.ai custom vocabulary API. */ public interface CustomVocabularyApiInterface { @POST("vocabularies") Call<CustomVocabularyInformation> submitCustomVocabularies( @Body CustomVocabularySubmission options); @GET("vocabularies") Call<List<CustomVocabularyInformation>> getListOfCustomVocabularyInformation(); @GET("vocabularies/{id}") Call<CustomVocabularyInformation> getCustomVocabularyInformation(@Path("id") String jobId); @DELETE("vocabularies/{id}") Call<Void> deleteCustomVocabulary(@Path("id") String jobId); }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/ErrorInterceptor.java
package ai.rev.speechtotext; import ai.rev.speechtotext.exceptions.AuthorizationException; import ai.rev.speechtotext.exceptions.ForbiddenStateException; import ai.rev.speechtotext.exceptions.InvalidHeaderException; import ai.rev.speechtotext.exceptions.InvalidParameterException; import ai.rev.speechtotext.exceptions.ResourceNotFoundException; import ai.rev.speechtotext.exceptions.RevAiApiException; import ai.rev.speechtotext.exceptions.ThrottlingLimitException; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import org.json.JSONObject; import java.io.IOException; /** The ErrorInterceptor class is used to intercept all responses with erroneous response codes. */ public class ErrorInterceptor implements Interceptor { public ErrorInterceptor() {} @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); Response response = chain.proceed(request); int responseCode = response.code(); if (responseCode > 399) { JSONObject errorResponse = new JSONObject(response.body().string()); switch (responseCode) { case 401: throw new AuthorizationException(errorResponse); case 400: throw new InvalidParameterException(errorResponse); case 404: throw new ResourceNotFoundException(errorResponse); case 406: throw new InvalidHeaderException(errorResponse); case 409: throw new ForbiddenStateException(errorResponse); case 429: throw new ThrottlingLimitException(errorResponse); default: throw new RevAiApiException("Unexpected API Error", errorResponse, responseCode); } } else { return response; } } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/MockInterceptor.java
package ai.rev.speechtotext; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import java.io.IOException; /** A MockInterceptor object is used to mock the responses for testing purposes. */ public class MockInterceptor implements Interceptor { private String sampleResponse; private MediaType mediaType; private Integer responseCode; public Request request; public MockInterceptor(MediaType mediaType, Integer responseCode) { this.mediaType = mediaType; this.responseCode = responseCode; } @Override public Response intercept(Chain chain) throws IOException { request = chain.request(); return chain .proceed(chain.request()) .newBuilder() .code(responseCode) .protocol(Protocol.HTTP_2) .message("mock interceptor") .body(ResponseBody.create(sampleResponse, mediaType)) .addHeader("content-type", "application/json") .build(); } public String getSampleResponse() { return sampleResponse; } public void setSampleResponse(String sampleResponse) { this.sampleResponse = sampleResponse; } public Request getRequest() { return request; } public void setRequest(Request request) { this.request = request; } public MediaType getMediaType() { return mediaType; } public void setMediaType(MediaType mediaType) { this.mediaType = mediaType; } public Integer getResponseCode() { return responseCode; } public void setResponseCode(Integer responseCode) { this.responseCode = responseCode; } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/RevAiWebSocketListener.java
package ai.rev.speechtotext; import ai.rev.speechtotext.models.streaming.ConnectedMessage; import ai.rev.speechtotext.models.streaming.Hypothesis; import okhttp3.Response; /** Listens for events over the WebSocket connection to Rev.ai */ public interface RevAiWebSocketListener { /** * Supplies the connection message received from Rev.ai. * * @param message a String in JSON format that contains the message type and job ID. * @see <a * href="https://www.rev.ai/docs/streaming#section/Rev.ai-to-Client-Response">https://www.rev.ai/docs/streaming#section/Rev.ai-to-Client-Response</a */ void onConnected(ConnectedMessage message); /** * Supplies the Hypothesis returned from Rev.ai. * * @param hypothesis the partial or final hypothesis of the audio. * @see Hypothesis */ void onHypothesis(Hypothesis hypothesis); /** * Supplies the error and response received during a WebSocket ErrorEvent. * * @param t the error thrown. * @param response the WebSocket response to the error. */ void onError(Throwable t, Response response); /** * Supplies the close code and close reason received during a WebSocket CloseEvent. * * @param code the close code. * @param reason the close reason. */ void onClose(int code, String reason); /** * Supplies the response received during the handshake. * * @param response the handshake response. */ void onOpen(Response response); }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/StreamingClient.java
package ai.rev.speechtotext; import ai.rev.speechtotext.helpers.SDKHelper; import ai.rev.speechtotext.models.streaming.ConnectedMessage; import ai.rev.speechtotext.models.streaming.Hypothesis; import ai.rev.speechtotext.models.streaming.SessionConfig; import ai.rev.speechtotext.models.streaming.StreamContentType; import com.google.gson.Gson; import com.google.gson.JsonObject; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.WebSocket; import okhttp3.WebSocketListener; import okio.ByteString; public class StreamingClient { private String accessToken; private OkHttpClient client; private WebSocket webSocket; private String scheme; private String host; private Integer port; /** * Constructs the streaming client that is used to establish a WebSocket connection with the * Rev.ai server and stream audio data. The user access token can be generated on the website at * https://www.rev.ai/access_token. * * @param accessToken Rev.ai authorization token. */ public StreamingClient(String accessToken) { this.accessToken = accessToken; this.client = setClient(); } /** * This method sets the URL scheme to be used in the WebSocket connect request * * @param scheme URL scheme. */ public void setScheme(String scheme) { switch (scheme.toLowerCase()) { case "wss": case "https": this.scheme = "https"; break; case "ws": case "http": this.scheme = "http"; break; default: throw new IllegalArgumentException("Invalid scheme: " + scheme); } } /** * This methods sets the URL host name. By default the host name is api.rev.ai. * * @param host URL host name. */ public void setHost(String host) { this.host = host; } /** * This method sets a port number to be used in the WebSocket connect request. * * @param port the port used to connect to */ public void setPort(int port) { this.port = port; } /** * Sends an HTTP request and upon authorization is upgraded to a WebSocket connection. Use {@link * RevAiWebSocketListener} to handle web socket events. To establish a successful connection a * valid StreamContentType must be provided. * * <p>Providing metadata is optional but helps to identify the stream. * * <p>Providing a {@link SessionConfig} is optional. Use this object to enable the profanity * filter and provide a custom vocabulary id. * * @param revAiWebSocketListener the listener used to capture WebSocket events. * @param streamContentType content-type query parameter. * @param metadata used to identify the stream. * @param sessionConfig object containing the filter profanity setting and custom vocabulary id * @see RevAiWebSocketListener * @see StreamContentType * @see SessionConfig */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata, SessionConfig sessionConfig) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(metadata, streamContentType, sessionConfig); createWebSocketConnection(url, listener); } /** * Overload of {@link StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, * SessionConfig)} without the optional metadata and sessionConfig. * * @see StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, SessionConfig) */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(null, streamContentType, null); createWebSocketConnection(url, listener); } /** * Overload of {@link StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, * SessionConfig)} without the optional sessionConfig. * * @see StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, SessionConfig) */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(metadata, streamContentType, null); createWebSocketConnection(url, listener); } /** * Overload of {@link StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, * SessionConfig)} without the optional metadata. * * @see StreamingClient#connect(RevAiWebSocketListener, StreamContentType, String, SessionConfig) */ public void connect( RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, SessionConfig sessionConfig) { Listener listener = new Listener(revAiWebSocketListener); String url = buildURL(null, streamContentType, sessionConfig); createWebSocketConnection(url, listener); } /** * Sends data over WebSocket in the form of a ByteString * * @param byteString Audio data in the form of a ByteString */ public void sendAudioData(ByteString byteString) { webSocket.send(byteString); } /** Will close the WebSocket connection by informing the server that it's the End of Stream */ public void close() { webSocket.send("EOS"); } private void createWebSocketConnection(String url, Listener listener) { Request request = new Request.Builder().url(url).build(); webSocket = client.newWebSocket(request, listener); } private String buildURL( String metadata, StreamContentType streamContentType, SessionConfig sessionConfig) { HttpUrl.Builder urlBuilder = new HttpUrl.Builder(); if (scheme != null) { urlBuilder.scheme(scheme); } else { urlBuilder.scheme("https"); } if (host != null) { urlBuilder.host(host); } else { urlBuilder.host("api.rev.ai"); } if (port != null) { urlBuilder.port(port); } urlBuilder.addPathSegments("speechtotext/v1/stream"); urlBuilder.addQueryParameter("access_token", accessToken); if (metadata != null) { urlBuilder.addQueryParameter("metadata", metadata); } if (sessionConfig != null) { if (sessionConfig.getCustomVocabularyId() != null) { urlBuilder.addQueryParameter("custom_vocabulary_id", sessionConfig.getCustomVocabularyId()); } if (sessionConfig.getFilterProfanity() != null) { urlBuilder.addQueryParameter( "filter_profanity", String.valueOf(sessionConfig.getFilterProfanity())); } if (sessionConfig.getRemoveDisfluencies() != null) { urlBuilder.addQueryParameter( "remove_disfluencies", String.valueOf(sessionConfig.getRemoveDisfluencies())); } if (sessionConfig.getDeleteAfterSeconds() != null) { urlBuilder.addQueryParameter( "delete_after_seconds", String.valueOf(sessionConfig.getDeleteAfterSeconds())); } if (sessionConfig.getDetailedPartials() != null) { urlBuilder.addQueryParameter( "detailed_partials", String.valueOf(sessionConfig.getDetailedPartials())); } if (sessionConfig.getStartTs() != null) { urlBuilder.addQueryParameter("start_ts", String.valueOf(sessionConfig.getStartTs())); } if (sessionConfig.getTranscriber() != null) { urlBuilder.addQueryParameter("transcriber", sessionConfig.getTranscriber()); } } return urlBuilder.build().toString() + "&content_type=" + streamContentType.buildContentString(); } private OkHttpClient setClient() { return new OkHttpClient.Builder() .addNetworkInterceptor(new ApiInterceptor(accessToken, SDKHelper.getSdkVersion())) .addNetworkInterceptor(new ErrorInterceptor()) .build(); } private static class Listener extends WebSocketListener { private Gson gson = new Gson(); private RevAiWebSocketListener revAiWebsocketListener; public Listener(RevAiWebSocketListener revAiWebsocketListener) { this.revAiWebsocketListener = revAiWebsocketListener; } @Override public void onOpen(WebSocket webSocket, Response response) { revAiWebsocketListener.onOpen(response); } @Override public void onMessage(WebSocket webSocket, String text) { JsonObject jsonObject = gson.fromJson(text, JsonObject.class); String type = jsonObject.get("type").getAsString(); if (type.equals("connected")) { revAiWebsocketListener.onConnected(gson.fromJson(text, ConnectedMessage.class)); } else if (type.equals("partial") || type.equals("final")) { revAiWebsocketListener.onHypothesis(gson.fromJson(text, Hypothesis.class)); } } @Override public void onClosing(WebSocket webSocket, int code, String reason) { revAiWebsocketListener.onClose(code, reason); } @Override public void onClosed(WebSocket webSocket, int code, String reason) { revAiWebsocketListener.onClose(code, reason); } @Override public void onFailure(WebSocket webSocket, Throwable t, Response response) { revAiWebsocketListener.onError(t, response); } } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/AuthorizationException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; /** * The AuthorizationException happens when an invalid token access is used to query the account * information endpoint. */ public class AuthorizationException extends RevAiApiException { public AuthorizationException(JSONObject errorResponse) { super("Authorization Exception", errorResponse, 401); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/ForbiddenStateException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; /** * The ForbiddenStateException occurs when a user attempts to retrieve the transcript or caption of * a unprocessed job. */ public class ForbiddenStateException extends RevAiApiException { public ForbiddenStateException(JSONObject errorResponse) { super("Forbidden State Exception", errorResponse, 409); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/InvalidHeaderException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; /** * The InvalidHeaderException occurs when a header that's passed along a query is not recognized by * the API. */ public class InvalidHeaderException extends RevAiApiException { public InvalidHeaderException(JSONObject errorResponse) { super("Invalid Header Exception", errorResponse, 406); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/InvalidParameterException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; /** * The InvalidParameterException occurs when a parameter that's passed along a query is not * recognized by the API. */ public class InvalidParameterException extends RevAiApiException { public InvalidParameterException(JSONObject errorResponse) { super("Invalid Parameter Exception ", errorResponse, 400); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/ResourceNotFoundException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; /** * The ResourceNotFoundException occurs when a job ID queried is not associated with a job submitted * by the user. */ public class ResourceNotFoundException extends RevAiApiException { public ResourceNotFoundException(JSONObject errorResponse) { super("Resource Not Found Exception", errorResponse, 404); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/RevAiApiException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; import java.io.IOException; /** * The RevAiApiException wraps standard Java IOException and enriches them with custom information. * You can use this code to retrieve details of exceptions when calling the Rev.AI API. */ public class RevAiApiException extends IOException { public RevAiApiException(String message, JSONObject errorResponse, int responseCode) { super(formatErrorDetails(message, errorResponse, responseCode)); } private static String formatErrorDetails( String message, JSONObject errorResponse, int responseCode) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(message); if (errorResponse.has("title")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Title: " + errorResponse.get("title")); } if (errorResponse.has("detail")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Detail: " + errorResponse.get("detail")); } if (errorResponse.has("type")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Type: " + errorResponse.get("type")); } if (errorResponse.has("status")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Status: " + errorResponse.get("status")); } if (errorResponse.has("parameters")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Parameters: " + errorResponse.get("parameters")); } if (errorResponse.has("allowed_values")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Allowed Values: " + errorResponse.get("allowed_values")); } if (errorResponse.has("current_value")) { stringBuilder.append(System.lineSeparator()); stringBuilder.append("Current Value: " + errorResponse.get("current_value")); } return stringBuilder.toString(); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/exceptions/ThrottlingLimitException.java
package ai.rev.speechtotext.exceptions; import org.json.JSONObject; /** * ThrottlingLimitException occurs when the number of queries within a given period reaches a * throttling limit. */ public class ThrottlingLimitException extends RevAiApiException { public ThrottlingLimitException(JSONObject errorResponse) { super("Throttling Limit Exception", errorResponse, 429); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/helpers/ClientHelper.java
package ai.rev.speechtotext.helpers; import ai.rev.speechtotext.ApiInterceptor; import ai.rev.speechtotext.ErrorInterceptor; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.scalars.ScalarsConverterFactory; public class ClientHelper { public static OkHttpClient createOkHttpClient(String accessToken) { return new OkHttpClient.Builder() .retryOnConnectionFailure(false) .addNetworkInterceptor(new ApiInterceptor(accessToken, SDKHelper.getSdkVersion())) .addNetworkInterceptor(new ErrorInterceptor()) .retryOnConnectionFailure(false) .build(); } public static Retrofit createRetrofitInstance(OkHttpClient client) { return new Retrofit.Builder() .baseUrl("https://api.rev.ai/speechtotext/v1/") .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/helpers/SDKHelper.java
package ai.rev.speechtotext.helpers; /** A helper class that provides methods for getting SDK information. */ public class SDKHelper { /** * Helper function that reads the current sdk version from pom.xml. * * @return The current SDK version. */ public static String getSdkVersion() { return SDKHelper.class.getPackage().getImplementationVersion(); } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/models
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/models/asynchronous/Monologue.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; import java.util.List; /** * A Monologue object presents information about a segment of a transcript owned by an individual * speaker. */ public class Monologue { @SerializedName("speaker") private Integer speaker; @SerializedName("elements") private List<Element> elements; /** * Returns the speaker number for this monologue. * * @return The speaker number for this monologue. */ public Integer getSpeaker() { return speaker; } /** * Sets the speaker number for this monologue. * * @param speaker The number to set the speaker to. */ public void setSpeaker(Integer speaker) { this.speaker = speaker; } /** * Returns a list of {@link Element} objects. * * @return A list of {@link Element} objects. * @see Element */ public List<Element> getElements() { return elements; } /** * Sets elements to the list of {@link Element} objects provided. * * @param elements The list of {@link Element} objects to set as the elements. * @see Element */ public void setElements(List<Element> elements) { this.elements = elements; } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/models
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/models/asynchronous/RevAiAccount.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** * The RevAiAccount object provides basic information about a Rev.ai account associated with a valid * access token. * * @see <a href="https://www.rev.ai/docs#tag/Account">https://www.rev.ai/docs#tag/Account</a> */ public class RevAiAccount { @SerializedName("email") private String email; @SerializedName("balance_seconds") private Integer balanceSeconds; /** * Returns a String containing the account email. * * @return A String containing the account email. */ public String getEmail() { return this.email; } /** * Sets the email value. * * @param email The String value to set as the {@link RevAiAccount#email}. */ public void setEmail(String email) { this.email = email; } /** * Returns the remaining number of credits in seconds that can be used on the account. * * @return The number of seconds remaining on the account. */ public Integer getBalanceSeconds() { return this.balanceSeconds; } /** * Sets the balanceSeconds value. This cannot be used to affect the actual number of credits * remaining. * * @param balanceSeconds The Integer value to set as the {@link RevAiAccount#balanceSeconds}. */ public void setBalanceSeconds(Integer balanceSeconds) { this.balanceSeconds = balanceSeconds; } }
0
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/models
java-sources/ai/rev/speechtotext/revai-java-sdk-speechtotext/1.4.0/ai/rev/speechtotext/models/asynchronous/RevAiFailureType.java
package ai.rev.speechtotext.models.asynchronous; import com.google.gson.annotations.SerializedName; /** Specifies constants that define Rev.ai failure types. */ public enum RevAiFailureType { /** The failure used when the media provided in the submission request fails to download. */ @SerializedName("download_failure") DOWNLOAD_FAILURE("download_failure"), /** The failure used when the media provided doesn't contain any audio. */ @SerializedName("empty_media") EMPTY_MEDIA("empty_media"), /** The failure used when the account does not have enough credits remaining. */ @SerializedName("insufficient_balance") INSUFFICIENT_BALANCE("insufficient_balance"), /** The failure used when there is a processing error. */ @SerializedName("internal_processing") INTERNAL_PROCESSING("internal_processing"), /** The failure used when the file submitted is not a valid or supported media file. */ @SerializedName("invalid_media") INVALID_MEDIA("invalid_media"), /** The failure used when the account has reached or exceeded its invoicing limit. */ @SerializedName("invoicing_limit_exceeded") INVOICING_LIMIT_EXCEEDED("invoicing_limit_exceeded"), /** The failure used when an error occurs during transcription and prevents job completion. */ @SerializedName("transcription") TRANSCRIPTION("transcription"); private String failureType; RevAiFailureType(String failureType) { this.failureType = failureType; } /** * Returns the String value of the enumeration. * * @return The String value of the enumeration. */ public String getFailureType() { return failureType; } @Override public String toString() { return "{" + "failureType='" + failureType + '\'' + '}'; } }