{"id":19554132,"url":"https://github.com/revdotcom/revai-python-sdk","last_synced_at":"2025-04-05T04:08:40.801Z","repository":{"id":33114118,"uuid":"150805421","full_name":"revdotcom/revai-python-sdk","owner":"revdotcom","description":"Rev AI Python SDK","archived":false,"fork":false,"pushed_at":"2024-11-27T21:07:08.000Z","size":2062,"stargazers_count":37,"open_issues_count":9,"forks_count":12,"subscribers_count":40,"default_branch":"develop","last_synced_at":"2025-03-29T03:03:32.847Z","etag":null,"topics":["captions","python","realtime","rev","sdk","speech-recognition","speech-to-text","transcription-job"],"latest_commit_sha":null,"homepage":"https://docs.rev.ai","language":"Python","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":"HISTORY.rst","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":"2018-09-28T23:51:09.000Z","updated_at":"2025-01-11T21:33:09.000Z","dependencies_parsed_at":"2024-06-17T16:50:27.965Z","dependency_job_id":"ea6e6f47-7c8d-4ae4-8252-0b689830006b","html_url":"https://github.com/revdotcom/revai-python-sdk","commit_stats":{"total_commits":109,"total_committers":20,"mean_commits":5.45,"dds":0.8348623853211009,"last_synced_commit":"80466d21bc743cd1e5ed1aea9fcfa592393f916d"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-python-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-python-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-python-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revdotcom%2Frevai-python-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revdotcom","download_url":"https://codeload.github.com/revdotcom/revai-python-sdk/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284944,"owners_count":20913704,"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","python","realtime","rev","sdk","speech-recognition","speech-to-text","transcription-job"],"created_at":"2024-11-11T04:26:00.792Z","updated_at":"2025-04-05T04:08:40.778Z","avatar_url":"https://github.com/revdotcom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rev AI Python SDK\n\n[![CI](https://github.com/revdotcom/revai-python-sdk/actions/workflows/build_test.yml/badge.svg)](https://github.com/revdotcom/revai-python-sdk/actions/workflows/build_test.yml)\n\n## Documentation\n\nSee the [API docs](https://docs.rev.ai/sdk/python/) for more information about the API and\nmore python examples.\n\n## Installation\n\nYou don't need this source code unless you want to modify the package. If you just\nwant to use the package, just run:\n\n    pip install --upgrade rev_ai\n\nInstall from source with:\n\n    python setup.py install\n\n### Requirements\n\n- Python 3.8+\n\n## Usage\n\nAll you need to get started is your Access Token, which can be generated on\nyour [AccessToken Settings Page](https://www.rev.ai/access_token). Create a client with the\ngenerated Access Token:\n\n```python\nfrom rev_ai import apiclient, RevAiApiDeploymentConfigMap, RevAiApiDeployment\n\n# create your client\n# optionally configure the Rev AI deployment to use\nclient = apiclient.RevAiAPIClient(\"ACCESS TOKEN\", url=RevAiApiDeploymentConfigMap[RevAiApiDeployment.US]['base_url'])\n```\n\n### Sending a file\n\nOnce you've set up your client with your Access Token sending a file is easy!\n\n```python\n# you can send a local file\njob = client.submit_job_local_file(\"FILE PATH\")\n\n# or send a link to the file you want transcribed\njob = client.submit_job_url(\"https://example.com/file-to-transcribe.mp3\")\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 submit job methods take `metadata`,`notification_config`, \n`skip_diarization`, `skip_punctuation`, `speaker_channels_count`,`custom_vocabularies`,\n`filter_profanity`, `remove_disfluencies`, `delete_after_seconds`,`language`,\nand `custom_vocabulary_id` as optional parameters.\n\nThe url submission option also supports authentication headers by using the `source_config` option.\n\nYou can request transcript summary.\n\n```python\n# submitting a human transcription jobs\njob = client.submit_job_url(\"https://example.com/file-to-transcribe.mp3\",\n    language='en',\n    summarization_config=SummarizationOptions(\n        formatting_type=SummarizationFormattingOptions.BULLETS\n    ))\n```\n\nYou can request transcript translation into up to five languages.\n\n```javascript\njob = client.submit_job_url(\"https://example.com/file-to-transcribe.mp3\",\n    language='en',\n    translation_config=TranslationOptions(\n        target_languages: [\n            TranslationLanguageOptions(\"es\", TranslationModel.PREMIUM),\n            TranslationLanguageOptions(\"de\")\n        ]\n    ));\n```\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### Human Transcription\n\nIf you want transcription to be performed by a human, both methods allow you to submit human transcription jobs\nusing `transcriber=human` with `verbatim`, `rush`, `segments_to_transcribe` and `test_mode` as optional parameters.\nCheck out our documentation for [Human Transcription](https://docs.rev.ai/api/asynchronous/transcribers/#human-transcription) for more details.\n\n```python\n# submitting a human transcription jobs\njob = client.submit_job_url(\"https://example.com/file-to-transcribe.mp3\",\n    transcriber='human',\n    verbatim=False,\n    rush=False,\n    test_mode=True\n    segments_to_transcribe=[{\n        start: 2.0,\n        end: 4.5\n    }])\n```\n\n### Checking your file's status\n\nYou can check the status of your transcription job using its `id`\n\n```python\njob_details = client.get_job_details(job.id)\n```\n\n`job_details` 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```python\njobs = client.get_list_of_jobs()\n\n# limit amount of retrieved jobs\njobs = client.get_list_of_jobs(limits=3)\n\n# get jobs starting after a certain job id\njobs = client.get_list_of_jobs(starting_after='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```python\nclient.delete_job(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### Getting your transcript\n\nOnce your file is transcribed, you can get your transcript in a few different forms:\n\n```python\n# as text\ntranscript_text = client.get_transcript_text(job.id)\n\n# as json\ntranscript_json = client.get_transcript_json(job.id)\n\n# or as a python object\ntranscript_object = client.get_transcript_object(job.id)\n\n# or if you requested transcript translation(s)\ntranscript_object = client.get_translated_transcript_object(job.id,'es')\n```\n\nBoth the json and object forms contain all the formation outlined in the response\nof the [Get Transcript](https://docs.rev.ai/api/asynchronous/reference/#operation/GetTranscriptById) endpoint\nwhen using the json response schema. While the text output is a string containing\njust the text of your transcript\n\n### Getting transcript summary\n\nIf you requested transcript summary, you can retrieve it as plain text or structured object:\n\n```python\n# as text\nsummary = client.get_transcript_summary_text(job.id)\n\n# as json\nsummary = client.get_transcript_summary_json(job.id)\n\n# or as a python object\nsummary = client.get_transcript_summary_object(job.id)\n\n```\n### Getting captions output\n\nYou can also get captions output from the SDK. We offer both SRT and VTT caption formats.\nIf you submitted your job as speaker channel audio then you must also provide a `channel_id` to be captioned:\n\n```python\ncaptions = client.get_captions(job.id, content_type=CaptionType.SRT, channel_id=None)\n\n# or if you requested transcript translation(s)\ncaptions = client.get_translated_captions(job.id, 'es')\n\n```\n\n### Streamed outputs\n\nAny output format can be retrieved as a stream. In these cases we return the raw http response to you. The output can be retrieved via `response.content`, `response.iter_lines()` or `response.iter_content()`.\n\n```python\ntext_stream = client.get_transcript_text_as_stream(job.id)\n\njson_stream = client.get_transcript_json_as_stream(job.id)\n\ncaptions_stream = client.get_captions_as_stream(job.id)\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```python\nfrom rev_ai.streamingclient import RevAiStreamingClient\nfrom rev_ai.models import MediaConfig, RevAiApiDeploymentConfigMap, RevAiApiDeployment\n\n#on_error(error)\n#on_close(code, reason)\n#on_connected(id)\n\n# optionally configure the Rev AI deployment to use\nconfig = MediaConfig()\nstreaming_client = RevAiStreamingClient(\"ACCESS TOKEN\",\n                                        config,\n                                        on_error=ERRORFUNC,\n                                        on_close=CLOSEFUNC,\n                                        on_connected=CONNECTEDFUNC,\n                                        url=RevAiApiDeploymentConfigMap[RevAiApiDeployment.US]['base_websocket_url'])\n```\n\n`on_error`, `on_close`, and `on_connected` are optional parameters that are functions to be called when the websocket errors, closes, and connects respectively. The default `on_error` raises the error, `on_close` prints out the code and reason for closing, and `on_connected` prints out the job ID.\nIf passing in custom functions, make sure you provide the right parameters. See the sample code for the parameters.\n\nOnce you have a streaming client setup with a `MediaConfig` and access token, you can obtain a transcription generator of your audio. You can also use a custom vocabulary with your streaming job by supplying the optional `custom_vocabulary_id` when starting a connection!\n\nMore optional parameters can be supplied when starting a connection, these are `metadata`, `filter_profanity`, `remove_disfluencies`, `delete_after_seconds`, and `detailed_partials`. For a description of these optional parameters look at our [streaming documentation](https://docs.rev.ai/api/streaming/requests/#request-parameters).\n\n```python\nresponse_generator = streaming_client.start(AUDIO_GENERATOR, custom_vocabulary_id=\"CUSTOM VOCAB ID\")\n```\n\n`response_generator` is a generator object that yields the transcription results of the audio including partial and final transcriptions. The `start` method creates a thread sending audio pieces from the `AUDIO_GENERATOR` to our\n[streaming] endpoint.\n\nIf you want to end the connection early, you can!\n\n```python\nstreaming_client.end()\n```\n\nOtherwise, the connection will end when the server obtains an \"EOS\" message.\n\n### Submitting custom vocabularies\n\nIn addition to passing custom vocabularies as parameters in the async API client, you can create and submit your custom vocabularies independently and directly to the custom vocabularies API, as well as check on their progress.\n\nPrimarily, the custom vocabularies client allows you to submit and preprocess vocabularies for use with the streaming client, in order to have streaming jobs with custom vocabularies!\n\nIn this example you see how to construct custom vocabulary objects, submit them to the API, and check on their progress and metadata!\n\n```python\nfrom rev_ai import custom_vocabularies_client\nfrom rev_ai.models import CustomVocabulary\n\n# Create a client\nclient = custom_vocabularies_client.RevAiCustomVocabulariesClient(\"ACCESS TOKEN\")\n\n# Construct a CustomVocabulary object using your desired phrases\ncustom_vocabulary = CustomVocabulary([\"Patrick Henry Winston\", \"Robert C Berwick\", \"Noam Chomsky\"])\n\n# Submit the CustomVocabulary\ncustom_vocabularies_job = client.submit_custom_vocabularies([custom_vocabulary])\n\n# View the job's progress\njob_state = client.get_custom_vocabularies_information(custom_vocabularies_job['id'])\n\n# Get list of previously submitted custom vocabularies\ncustom_vocabularies_jobs = client.get_list_of_custom_vocabularies()\n\n# Delete the CustomVocabulary\nclient.delete_custom_vocabulary(custom_vocabularies_job['id'])\n```\n\nFor more details, check out the custom vocabularies example in our [examples](https://github.com/revdotcom/revai-python-sdk/tree/develop/examples).\n\n# For Rev AI Python SDK Developers\n\nRemember in your development to follow the PEP8 style guide. Your code editor likely has Python PEP8 linting packages which can assist you in your development.\n\n# Local testing instructions\n\nPrequisites: virtualenv, tox\n\nTo test locally use the following commands from the repo root\n\n    virtualenv ./sdk-test\n    . ./sdk-test/bin/activate\n    tox\n\nThis will locally run the test suite, and saves significant dev time over\nwaiting for the CI tool to pick it up.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevdotcom%2Frevai-python-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevdotcom%2Frevai-python-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevdotcom%2Frevai-python-sdk/lists"}