Code Samples

Use the code samples below to integrate your applications with the API.

Python SDK

Create and use a custom vocabulary

attention

This example uses the Rev AI Python SDK.

The following example can be used to create and submit custom vocabularies independently and directly to the custom vocabularies API, as well as check on their progress.

To use this example, replace the <REVAI_ACCESS_TOKEN> placeholder with your Rev AI access token.

Copy
Copied
from rev_ai import custom_vocabularies_client
from rev_ai.models import CustomVocabulary

token = "<REVAI_ACCESS_TOKEN>"

# create a client
client = custom_vocabularies_client.RevAiCustomVocabulariesClient(token)

# construct a CustomVocabulary object using your desired phrases
custom_vocabulary = CustomVocabulary(["Patrick Henry Winston", "Robert C Berwick", "Noam Chomsky"])

# submit the CustomVocabulary
custom_vocabularies_job = client.submit_custom_vocabularies([custom_vocabulary])

# view the job's progress
job_state = client.get_custom_vocabularies_information(custom_vocabularies_job['id'])

# get list of previously submitted custom vocabularies
custom_vocabularies_jobs = client.get_list_of_custom_vocabularies()

# delete the CustomVocabulary
client.delete_custom_vocabulary(custom_vocabularies_job['id'])