{"id":19554169,"url":"https://github.com/revdotcom/revai-java-sdk","last_synced_at":"2025-04-26T21:31:54.795Z","repository":{"id":37836101,"uuid":"232436321","full_name":"revdotcom/revai-java-sdk","owner":"revdotcom","description":"Rev.ai Java SDK","archived":false,"fork":false,"pushed_at":"2024-01-05T21:42:53.000Z","size":1200,"stargazers_count":16,"open_issues_count":2,"forks_count":0,"subscribers_count":35,"default_branch":"develop","last_synced_at":"2024-03-27T04:08:28.733Z","etag":null,"topics":["captions","java","rev","revai","sdk","speech-recognition","speech-to-text","transcription-job"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/revdotcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-07T23:23:52.000Z","updated_at":"2022-03-22T04:04:09.000Z","dependencies_parsed_at":"2024-01-04T17:46:47.533Z","dependency_job_id":"852d1562-579e-4443-80c8-4bf235b76e9a","html_url":"https://github.com/revdotcom/revai-java-sdk","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-java-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-java-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-java-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-java-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revdotcom","download_url":"https://codeload.github.com/revdotcom/revai-java-sdk/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224047632,"owners_count":17246863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captions","java","rev","revai","sdk","speech-recognition","speech-to-text","transcription-job"],"created_at":"2024-11-11T04:26:10.316Z","updated_at":"2025-04-26T21:31:54.783Z","avatar_url":"https://github.com/revdotcom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rev AI Java SDK\n\n[![Maven Central](https://img.shields.io/maven-central/v/ai.rev/revai-java-sdk)](https://mvnrepository.com/artifact/ai.rev/revai-java-sdk)\n[![Build Status](https://github.com/revdotcom/revai-java-sdk/workflows/Build/badge.svg?branch=develop)](https://github.com/revdotcom/revai-java-sdk/actions?query=workflow%3ABuild+branch%3Adevelop)\n\n## Documentation\n\nSee the [API docs](https://docs.rev.ai) for more information about the API.\n\n## Install the SDK\nThe recommended way to use the Rev AI Java SDK is to import it into the project using Maven.\n\n      \u003cdependency\u003e\n        \u003cgroupId\u003eai.rev\u003c/groupId\u003e\n        \u003cartifactId\u003erevai-java-sdk\u003c/artifactId\u003e\n        \u003cversion\u003e2.2.0\u003c/version\u003e\n      \u003c/dependency\u003e\n\n## Build and install locally from source\nOnce you've cloned the repo you can use Maven to build it locally and install it in your local Maven .m2 repository.\n\n    mvn install -DskipTests=true      \n\n## Support\n\nWe support Java 8 and 11.\n\n## Usage\n\nAll you need to get started is your Access Token, which can be generated on\nyour [Settings Page](https://www.rev.ai/access_token). Create a client with the\ngiven Access Token:\n\n```\n// Initialize your client with your Rev AI access token\nString accessToken = \"Your Access Token\";\n// Optionally set the Rev AI deployment base url to use\nString baseUrl = RevAiApiDeploymentConfiguration.getConfig(RevAiApiDeploymentConfiguration.RevAiApiDeployment.US).getBaseUrl();\nApiClient apiClient = new ApiClient(accessToken, baseUrl);\n```\n\n### Checking credits remaining\n\n```\nRevAiAccount revAiAccount = apiClient.getAccount();\n```\n\n### Submitting a job\n\nYou can submit a local file\n```\nString localPathToFile = \"./path/to/file.mp3\";\nRevAiJob revAiJob = apiClient.submitJobLocalFile(localPathToFile);\n```\n\nor submit via a public direct download url\n```\nString urlLinkToFile = \"https://www.rev.ai/FTC_Sample_1.mp3\";\nRevAiJob revAiJob = apiClient.submitJobUrl(urlLinkToFile);\n```\n\nor from FileInputStream, the filename is optional.\n```\nFile file = new File(\"./path/to/file.mp3\");\nFileInputStream fileInputStream;\ntry {\n  fileInputStream = new FileInputStream(file);\n} catch (FileNotFoundException e) {\n  throw new RuntimeException(\"Could not find file [\" + file.getName() + \"]\");\n}\nRevAiJob revAiJob = apiClient.submitJobLocalFile(fileInputStream, String fileName, RevAiJobOptions options);\n```\nYou can request transcript summary.\n```\nString urlLinkToFile = \"https://www.rev.ai/FTC_Sample_1.mp3\";\n\nRevAiJobOptions revAiJobOptions = new RevAiJobOptions();\nrevAiJobOptions.setSourceConfig(urlLinkToFile, null);\nrevAiJobOptions.setLanguage(\"en\");\nrevAiJobOptions.setSummarizationOptions(new SummarizationOptions().setModel(NlpModel.STANDARD));\n```\nYou can request transcript translation into up to five languages.\n```\nString urlLinkToFile = \"https://www.rev.ai/FTC_Sample_1.mp3\";\n\nRevAiJobOptions revAiJobOptions = new RevAiJobOptions();\nrevAiJobOptions.setSourceConfig(urlLinkToFile, null);\nrevAiJobOptions.setLanguage(\"en\");\nrevAiJobOptions.setTranslationOptions(new TranslationOptions(Arrays.asList(\n            new TranslationLanguageOptions(\"es\")\n                    .setModel(NlpModel.PREMIUM),\n            new TranslationLanguageOptions(\"de\"))\n    ));\n```\n\nYou can also submit a job to be handled by a human transcriber using our [Human Transcription](https://docs.rev.ai/api/asynchronous/transcribers/#human-transcription) option.\n```\nString urlLinkToFile = \"https://www.rev.ai/FTC_Sample_1.mp3\";\nRevAiJobOptions options = new RevAiJobOptions();\n\n// set to perform human transcription\noptions.setTranscriber(\"human\");\n\n// optional job options\noptions.setVerbatim(true);\noptions.setRush(false);\noptions.setTestMode(true);\n\n// optional segments to transcribe\nSegmentToTranscribe segment = new SegmentToTranscribe();\nsegment.setStartTimestamp(2.0);\nsegment.setEndTimestamp(100.5);\noptions.setSegmentsToTranscribe(List.of(segment));\n\n// optional speaker names \nSpeakerName speaker = new SpeakerName();\nspeaker.setDisplayName('Alan Mathison Turing');\noptions.setSpeakerNames(List.of(speaker));\n\nRevAiJob revAiJob = apiClient.submitJobUrl(urlLinkToFile, options);\n```\n\n`RevAiJob` objects contain job information as defined by the [documentation](https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob).\n\nIf you want to get fancy, all submit job methods have overrides that allow specifying\n[RevAiJobOptions](src/main/java/ai/rev/speechtotext/models/asynchronous/RevAiJobOptions.java) to configure job specific settings.\nIn RevAiJobOptions, you could include `metadata`,`notification_config`,\n`skip_diarization`, `skip_punctuation`, `speaker_channels_count`,`custom_vocabularies`,\n`filter_profanity`, `remove_disfluencies`, `delete_after_seconds`, and `language` as optional parameters.\n\nThe url submission option also supports authentication headers by using the `source_config` option.\n\nAll options are described in the request body of the\n[Submit Job](https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob) endpoint.\n\n### Checking your job's status\n\nYou can check the status of your transcription job using its `id`\n\n```\nRevAiJob newlyRefreshedRevAiJob = apiClient.getJobDetails(revAiJob.getJobId());\n```\n\n`RevAiJob` objects contain job information as defined by the [documentation](https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob).\n\n### Checking multiple files\n\nYou can retrieve a list of transcription jobs with optional parameters\n\n```\nList\u003cRevAiJob\u003e jobs = apiClient.getListOfJobs();\n\n// limit amount of retrieved jobs\nint numberOfJobsToReturn = 3;\nList\u003cRevAiJob\u003e jobs = apiClient.getListOfJobs(numberOfJobsToReturn);\n\n// get jobs starting after a certain job ID\nString jobId = \"Umx5c6F7pH7r\";\nList\u003cRevAiJob\u003e jobs = apiClient.getListOfJobs(jobId);\n```\n\n`jobs` will contain a list of RevAiJob objects, having all information normally found in a successful response\nfrom our [Get List of Jobs](https://docs.rev.ai/api/asynchronous/reference/#operation/GetListOfJobs) endpoint\n\n### Deleting a job\n\nYou can delete a transcription job using its `id`\n\n```\napiClient.deleteJob(revAiJob.getJobId());\n```\n\n All data related to the job, such as input media and transcript, will be permanently deleted.\n A job can only by deleted once it's completed (either with success or failure).\n\n\n### Getting your transcript\n\nOnce your file is transcribed, you can get your transcript in a few different forms:\n\n```\n// as plain text\nString transcriptText = apiClient.getTranscriptText(revAiJob.getJobId());\n\n// or as an object\nRevAiTranscript revAiTranscript = apiClient.getTranscriptObject(revAiJob.getJobId());\n\n// or if you requested transcript translation(s)\nRevAiTranscript revAiTranscript = apiClient.getTranslatedTranscriptObject(revAiJob.getJobId(), \"es\");\n```\n\nThe text output is a string containing just the text of your transcript. The object form of\nthe transcript contains all the information outlined in the response of the\n[Get Transcript](https://docs.rev.ai/api/asynchronous/reference/#operation/GetTranscriptById) endpoint when using\nthe json response schema.\n\n### Getting captions output\n\nAnother way to retrieve your file is captions output. We support both .srt and .vtt outputs.\nSee below for an example showing how you can get captions as a readable stream. If your job\nwas submitted with multiple speaker channels you are required to provide the id of the channel\nyou would like captioned.\n\n```\nInputStream inputStream = apiClient.getCaptions(revAiJob.getJobId(), RevAiCaptionType.SRT);\n\n// with speaker channels\nint channelId = 1;\nInputStream inputStream = apiClient.getCaptions(revAiJob.getJobId(), RevAiCaptionType.VTT, channelId);\n\n// or if you requested transcript translation(s)\nInputStream inputStream = apiClient.getTranslatedCaptions(revAiJob.getJobId(), \"es\", RevAiCaptionType.VTT);\n```\n\n### Getting transcript summary\n\nIf you requested transcript summary, you can retrieve it as plain text or structured object:\n\n```\n// as text\napiClient.getTranscriptSummaryText(job.id);\n\n// as object\napiClient.getTranscriptSummaryObject(job.id);\n\n```\n## Streaming Audio\n\nIn order to stream audio, you will need to setup a streaming client and the content type\nfor the audio you will be sending.\n\n```\nStreamContentType streamContentType = new StreamContentType();\n    streamContentType.setContentType(\"audio/x-raw\");\n    streamContentType.setLayout(\"interleaved\");\n    streamContentType.setFormat(\"S16LE\");\n    streamContentType.setRate(16000);\n    streamContentType.setChannels(1);\n\nStreamingClient streamingClient = new StreamingClient(\"Your Access Token\");\n```\n\nYou will need to create Listener that implements the RevAiWebSocketListener in order\nto handle WebSocket events.\n\n```java\npublic class Listener implements RevAiWebSocketListener {\n\n    @Override\n    public void onConnected(ConnectedMessage message) {\n        System.out.println(\"On Connected: \" + message);\n    }\n\n    @Override\n    public void onHypothesis(Hypothesis hypothesis) {\n        System.out.println(\"On Hypothesis: \" + hypothesis);\n    }\n\n    @Override\n    public void onError(Throwable t, Response response) {\n        System.out.println(\"On Error: \" + response.toString());\n    }\n\n    @Override\n    public void onClose(int code, String reason) {\n        System.out.println(\"On Close: [\" + code + \"] \" + reason);\n    }\n\n    @Override\n    public void onOpen(Response response) {\n        System.out.println(\"On Open: \" + response.toString());\n    }\n}\n```\n\nNow you will be able to connect and start the streaming session by calling the `streamingClient.connect()` method and passing in the Listener! You can supply an optional `SessionConfig` object, containing `metadata`, `filter_profanity`, `remove_disfluencies`, and `delete_after_seconds` as optional parameters, to the function in order to provide additional information for that session.\n\n```\nListener listener = new Listener();\n\nSessionConfig sessionConfig = new SessionConfig();\nsessionConfig.setMetaData(\"My first job\");\nsessionConfig.setFilterProfanity(true);\n\nstreamingClient.connect(clientListener, streamContentType, sessionConfig);\n```\n\nYou can stream data over the WebSocket in the form of a `ByteString` using the `streamingClient.sendAudioData()` method.\n\n```\nstreamingClient.sendAudioData(ByteString);\n```\n\nThe streaming connection will close when you call the method `streamingClient.close()` or if you go 15 seconds without sending any audio data.\n\n## Custom Vocabulary\n\nYou can submit any custom vocabularies independently through the CustomVocabulariesClient. Once the custom vocabulary has been submitted and processed, it is ready to be used in any async or streaming job.\n\nBelow you can see an example of how to create, submit, delete, check on the status and view the other associated information of your custom vocabulary.\n\n```\n// Initialize your client with your Rev AI access token\nString accessToken = \"Your Access Token\";\nCustomVocabulariesClient customVocabulariesClient = new CustomVocabulariesClient(accessToken);\n\n// Construct a CustomVocabulary object using your desired phrases\nList\u003cString\u003e phrases = Arrays.asList(\"Patrick Henry Winston\", \"Robert C Berwick\", \"Noam Chomsky\");\nCustomVocabulary customVocabulary = new CustomVocabulary(phrases);\n\n// Submit the CustomVocabulary\nCustomVocabularyInformation submittedVocabularyInformation = customVocabularyClient.submitCustomVocabularies(Collections.singletonList(customVocabulary));\n\n// View the custom vocabulary information\nCustomVocabularyInformation retrievedVocabularyInformation = customVocabularyClient.getCustomVocabularyInformation(submittedVocabulary.getId());\n\n// View list of custom vocabularies information\nList\u003cCustomVocabularyInformation\u003e customVocabulariesInformation = customVocabularyClient.getListOfCustomVocabularyInformation();\n\n// Delete a custom vocabulary by id\ncustomVocabularyClient.deleteCustomVocabulary(retrievedVocabularyInformation.getId());\n```\n\n## For Rev AI Java SDK Developers\n\nBefore contributing to the project please install the following\n* [IntelliJ IDE](https://www.jetbrains.com/idea/)\n* [google-java-format plugin](https://plugins.jetbrains.com/plugin/8527-google-java-format)\n\nBefore opening a pull-request\n* go to `Settings \u003e Plugins` and install google-java-format.\n* then `Settings \u003e google-java-format Settings` and click enable option.\n* please run the `Code \u003e Reformat Code` option in any classes that were touched to ensure the code is formatted correctly.\nYou can also right click on `src` folder and run `Reformat Code`.\n\nRun `mvn package` to build the code, run the unit tests and create the SDK jar.\n\nRun `mvn verify` to also run integration tests. They require the `REVAI_ACCESS_TOKEN` environment variable to be set to a valid Rev AI access token.\n\nTo save the `REVAI_ACCESS_TOKEN` to be available for Integration tests\n* go to `Run \u003e Edit Configurations` and add a new JUnit configuration if none exists yet.\n* for the new JUnit configuration, go to `Environmental Variables` and click on the browse option.\n* click `+` and add `TOKEN` under name and `REVAI_ACCESS_TOKEN` under value.\n\n### To Release a New Version\n1. Create Github tag\n2. Creat Github release\n3. The Github action to publish should kick off\n4. Remember to update SDK changelog documentation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevdotcom%2Frevai-java-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevdotcom%2Frevai-java-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevdotcom%2Frevai-java-sdk/lists"}