{"id":19554146,"url":"https://github.com/revdotcom/revai-node-sdk","last_synced_at":"2025-04-05T21:07:07.798Z","repository":{"id":38183962,"uuid":"165756366","full_name":"revdotcom/revai-node-sdk","owner":"revdotcom","description":"Node.js SDK for the Rev AI API","archived":false,"fork":false,"pushed_at":"2024-10-14T23:50:44.000Z","size":1534,"stargazers_count":22,"open_issues_count":3,"forks_count":14,"subscribers_count":39,"default_branch":"develop","last_synced_at":"2024-10-16T06:31:04.926Z","etag":null,"topics":["captions","nodejs","realtime","rev","revai","sdk","speech-recognition","speech-to-text"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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":"2019-01-15T00:21:53.000Z","updated_at":"2024-08-27T17:20:29.000Z","dependencies_parsed_at":"2023-02-14T02:16:07.089Z","dependency_job_id":"dfd1b441-90d5-40e1-9bea-029890ae9409","html_url":"https://github.com/revdotcom/revai-node-sdk","commit_stats":{"total_commits":181,"total_committers":28,"mean_commits":6.464285714285714,"dds":0.718232044198895,"last_synced_commit":"5f33b9f32a7fc2897791cb8cb94b098aa20f97ec"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-node-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-node-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-node-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-node-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revdotcom","download_url":"https://codeload.github.com/revdotcom/revai-node-sdk/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399874,"owners_count":20932876,"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","nodejs","realtime","rev","revai","sdk","speech-recognition","speech-to-text"],"created_at":"2024-11-11T04:26:04.643Z","updated_at":"2025-04-05T21:07:07.775Z","avatar_url":"https://github.com/revdotcom.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Rev AI Node SDK](https://docs.rev.ai/sdk/node/) \u0026middot; [![npm version](https://img.shields.io/npm/v/revai-node-sdk.svg?style=flat)](https://www.npmjs.com/package/revai-node-sdk) ![CI](https://github.com/revdotcom/revai-node-sdk/workflows/CI/badge.svg)\n\n## Documentation\n\nSee the [API docs](https://docs.rev.ai) for more information about the API.\n\n## Examples\n\nExamples can be found in the [`examples/`](https://github.com/revdotcom/revai-node-sdk/tree/develop/examples) directory\n\n## Installation\n\nTo install the package, run:\n\n    npm install revai-node-sdk\n\n## Support\n\nWe support Node 8, 10, 12, 14, 16 and 17.\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```javascript\nimport { RevAiApiClient, RevAiApiDeployment, RevAiApiDeploymentConfigMap } from 'revai-node-sdk';\n\n// Initialize your client with your Rev AI access token\nconst accessToken = \"\u003cACCESS_TOKEN\u003e\";\n\n// Optionally set the specific Rev AI deployment of your account, defaults to the US deployment.\n// Learn more about Rev AI's global deployments at https://docs.rev.ai/api/global-deployments.\nconst client = new RevAiApiClient({ token: accessToken, deploymentConfig: RevAiApiDeploymentConfigMap.get(RevAiApiDeployment.US) });\n```\n\n### Checking credits remaining\n\n```javascript\nconst accountInfo = await client.getAccount();\n```\n\n### Submitting a job\n\nOnce you've set up your client with your Access Token sending a file is easy!\n\n```javascript\n// You can submit a local file\nconst job = await client.submitJobLocalFile(\"./path/to/file.mp4\");\n\n// or submit via a public url\nconst jobOptions = { source_config: { url: \"https://www.rev.ai/FTC_Sample_1.mp3\" } }\nconst job = await client.submitJob(jobOptions);\n\n// or from audio data, the filename is optional\nconst stream = fs.createReadStream(\"./path/to/file.mp3\");\nconst job = await client.submitJobAudioData(stream, \"file.mp3\");\n```\n\nYou can request transcript summary.\n\n```javascript\nconst job = await client.submitJobLocalFile(\"./path/to/file.mp4\", {\n    language: \"en\",\n    summarization_config: {\n        type: 'bullets'\n    }\n});\n```\n\nYou can request transcript translation into up to five languages.\n\n```javascript\nconst job = await client.submitJobLocalFile(\"./path/to/file.mp4\", {\n    language: \"en\",\n    translation_config: {\n        target_languages: [{\n            language: 'es',\n            model: 'premium'\n        }]\n    }\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```javascript\nconst job = await client.submitJobLocalFile(\"./path/to/file.mp4\", {\n    transcriber: \"human\",\n    verbatim: false,\n    rush: false,\n    test_mode: true,\n    segments_to_transcribe: [{\n        start: 1.0,\n        end: 2.4\n    }],\n    speaker_names: [{\n        display_name: \"Augusta Ada Lovelace\"\n    },{\n        display_name: \"Alan Mathison Turing\"\n    }]\n});\n```\n\n`job` will contain all the information normally found in a successful response from our\n[Submit Job](https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob) endpoint.\n\nIf you want to get fancy, both send job methods can take a `RevAiJobOptions` object containing optional parameters.\nThese are described in the request body of the [Submit Job](https://docs.rev.ai/api/asynchronous/reference/#operation/SubmitTranscriptionJob) endpoint.\n\n### Submitting urls with authorization headers\n\nBoth the `source_config` and `notification_config` job options support using a customer-provided authorization header to access the URLs.\nThis optional argument should be in the format `{ \"Authorization\": \"TokenScheme TokenValue\" }`\n\nExample:\n```\nvar notificationConfig = { url: 'https://example.com', auth_headers: { \"Authorization\": \"Bearer \u003ctoken\u003e\" } };\n```\nFor more information see https://github.com/revdotcom/revai-node-sdk/blob/develop/examples/async_transcribe_media_from_url.js\n\n### Checking your job's status\n\nYou can check the status of your transcription job using its `id`\n\n```javascript\nconst jobDetails = await client.getJobDetails(job.id);\n```\n\n`jobDetails` will contain all information normally found in a successful response from\nour [Get Job](https://docs.rev.ai/api/asynchronous/reference/#operation/GetJobById) endpoint\n\n### Checking multiple files\n\nYou can retrieve a list of transcription jobs with optional parameters\n\n```javascript\nconst jobs = await client.getListOfJobs();\n\n// limit amount of retrieved jobs\nconst jobs = await client.getListOfJobs(3);\n\n// get jobs starting after a certain job id\nconst jobs = await client.getListOfJobs(undefined, 'Umx5c6F7pH7r');\n```\n\n`jobs` will contain a list of job details 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```javascript\nawait client.deleteJob(job.id);\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```javascript\n// as plain text\nconst transcriptText = await client.getTranscriptText(job.id);\n\n// or as an object\nconst transcriptObject = await client.getTranscriptObject(job.id);\n\n// or if you requested transcript translation(s)\nconst translatedTranscriptTest = await client.getTranslatedTranscriptText(job.id, 'es');\n```\n\nThe text output is a string containing just the text of your transcript. The object form of the transcript contains all the information outlined in the response of the [Get Transcript](https://docs.rev.ai/api/asynchronous/reference/#operation/GetTranscriptById) endpoint when using the json response schema.\n\nAny of these outputs can we retrieved as a stream for easy file writing:\n\n```javascript\nconst textStream = await client.getTranscriptTextStream(job.id);\nconst transcriptStream = await client.getTranscriptObjectStream(job.id);\n```\n\n### Getting captions output\n\nAnother way to retrieve your file is captions output. We support both .srt and .vtt outputs. See below for an example showing how you can get captions as a readable stream. If your job was submitted with multiple speaker channels you are required to provide the id of the channel you would like captioned.\n\n```javascript\nconst captionsStream = await client.getCaptions(job.id, CaptionType.SRT);\n\n// or if you requested transcript translation(s)\nconst translatedCaptionsStream = await client.getTranslatedCaptions(job.id, 'es');\n\n// with speaker channels\nconst channelId = 1;\nconst captionsStream = await client.getCaptions(job.id, CaptionType.VTT, channelId);\n```\n\n### Getting transcript summary\n\nIf you requested transcript summary, you can retrieve it as plain text or structured object:\n\n```javascript\n// as text\nconst transcriptSummaryText = await client.getTranscriptSummaryText(job.id);\n\n// as object\nconst transcriptSummaryJson = await client.getTranscriptSummaryObject(job.id);\n\n```\n\n## Streaming Audio\n\nIn order to stream audio, you will need to setup a streaming client and a media configuration for the audio you will be sending.\n\n```javascript\nimport { RevAiApiClient, RevAiApiDeployment, RevAiApiDeploymentConfigMap } from 'revai-node-sdk';\n\n // Initialize audio configuration for the streaming client\nconst audioConfig = new AudioConfig()\n\n// Optionally set the specific Rev AI deployment of your account, defaults to the US deployment.\n// Learn more about Rev AI's global deployments at https://docs.rev.ai/api/global-deployments.\nconst streamingClient = new RevAiStreamingClient({ token: \"\u003cACCESS_TOKEN\u003e\", deploymentConfig: RevAiApiDeploymentConfigMap.get(RevAiApiDeployment.US) }, audioConfig);\n```\n\nYou can set up event responses for your client's streaming sessions. This allows you to handle events such as the connection closing, failing, or successfully connecting!\nLook at the [examples](https://github.com/revdotcom/revai-node-sdk/tree/develop/examples) for more details.\n\n```javascript\nstreamingClient.on('close', (code, reason) =\u003e {\n    console.log(`Connection closed, ${code}: ${reason}`);\n});\n\nstreamingClient.on('connect', connectionMessage =\u003e {\n    console.log(`Connected with job id: ${connectionMessage.id}`);\n})\n```\n\nNow you will be able to start the streaming session by simply calling the `streamingClient.start()` method!\nYou can supply an optional `SessionConfig` object to the function as well in order to provide additional information for that session, such as metadata, or a custom vocabulary's ID to be used with your streaming session.\n\n```javascript\nconst sessionConfig = new SessionConfig(metadata='my metadata', customVocabularyID='myCustomVocabularyID');\n\nconst stream = streamingClient.start(sessionConfig);\n```\n\nYou can then stream data to this `stream` from a local file or other sources of your choosing and the session will end when the data stream to the `stream` session ends or when you would like to end it, by calling `streamingClient.end()`. For more details, take a look at our [examples](https://github.com/revdotcom/revai-node-sdk/tree/develop/examples).\n\n### Submitting custom vocabularies\n\nYou can now submit any custom vocabularies independently through the new CustomVocabularies client! The main benefit is that users of the SDK can now submit their custom vocabularies for preprocessing and then include these processed custom vocabularies in their streaming jobs.\n\nBelow you can see an example of how to create, submit and check on the status and other associated information of your submitted custom vocabulary!\n\nFor more information, check out our [examples](https://github.com/revdotcom/revai-node-sdk/tree/develop/examples).\n```javascript\nimport { RevAiCustomVocabulariesClient } from 'revai-node-sdk';\n\n// Initialize your client with your Rev AI access token\nconst accessToken = \"\u003cACCESS_TOKEN\u003e\";\nconst client = new RevAiCustomVocabulariesClient(accessToken);\n\n// Construct custom vocabularies object and submit it through the client\nconst customVocabularies = [{phrases: [\"Noam Chomsky\", \"Robert Berwick\", \"Patrick Winston\"]}];\nconst customVocabularySubmission = await client.submitCustomVocabularies(customVocabularies);\n\n// Get information regarding the custom vocabulary submission and its progress\nconst customVocabularyInformation = await client.getCustomVocabularyInformation(customVocabularySubmission.id)\n\n// Get a list of information on previously submitted custom vocabularies\nconst customVocabularyInformations = await client.getListOfCustomVocabularyInformations()\n\n// Delete a custom vocabulary\nawait client.deleteCustomVocabulary(customVocabularySubmission.id)\n```\n\n# For Rev AI Node SDK Developers\n\nAfter cloning and installing required npm modules, you should follow these practices when developing:\n\n1. Use the scripts defined in [package.json](https://github.com/revdotcom/revai-node-sdk/tree/develop/package.json) in this manner `npm run [command_name]`:\n    1. `lint` checks that you are not violating any code style standards. This ensures our code's style quality stays high improving readability and reducing room for errors.\n    2. `build` transpiles the Typescript into Javascript with the options specified in [tsconfig.json](https://github.com/revdotcom/revai-node-sdk/tree/develop/tsconfig.json)\n    3. `unit-test` runs our unit tests which live in the [unit test directory](https://github.com/revdotcom/revai-node-sdk/tree/develop/test/unit).\n    * Note that `integration-test` is currently configured to work with a certain account specified in our continuous integration build environment, as such for now you can check the automated continuous integration checks to pass the integration tests.\n    4. `build-examples` performs the same action as `build` and in addition, copies the `src` to the `node_modules` directory in `examples` such that you can test examples with local changes.\n2. Add any relevant test logic if you add or modify any features in the source code and check that the tests pass using the scripts mentioned above.\n3. Update the examples provided to illustrate any relevant changes you made, and check that they work properly with your changed local `revai-node-sdk`.\n    * One way to use your changed local package in the examples is to copy the output of the `build` script into the `examples/node_modules/revai-node-sdk`. On Unix, this can be simply done with the following command when in the root directory: `$ cp -r dist/src examples/node_modules/revai-node-sdk/`.\n4. Update the documentation to reflect any relevant changes and improve the development section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevdotcom%2Frevai-node-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevdotcom%2Frevai-node-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevdotcom%2Frevai-node-sdk/lists"}