Skip to content

Latest commit

 

History

History
93 lines (73 loc) · 2.85 KB

Vcon-Quick-Start.md

File metadata and controls

93 lines (73 loc) · 2.85 KB

Table of Contents

Example Code

Example Simple vCon Construction

import vcon

# Construct empty vCon
vCon = vcon.Vcon()

# Add some basic call META data
caller = "+18881234567"
called = "1234"
caller_index = vCon.set_party_parameter("tel", caller)
called_index = vCon.set_party_parameter("tel", called)
vCon.set_uuid("example.com")

# Add a recording of the call
recording_name = "call_recording.wav"
with open(recording_name, 'rb') as file_handle:
  recording_bytes = file_handle.read()

vCon.add_dialog_inline_recording(
  recording_bytes,
  "Mon, 23 May 2022 20:09:01 -0000",
  23.5, # sec. duration
  [caller_index, called_index], # parties recorded
  "audio/x-wav", # MIME type
  recording_name)

# Transcribe using the default FilterPlugin and default options
# for transcription: whisper
vCon.transcribe({})

# Summarize the conversation using OpenAI Chat GPT
vCon.openai_chat_completion({})

# Serialize the vCon to a JSON format string
json_string = vCon.dumps()

# Save the JSON format vCon to a file with pretty indentation:
vCon.dump("my_vcon.vcon", indent = 2)

Example vCon signing

# sign a vCon
cert_chain_file_names = ["signer.crt", "issuer.crt", "ca_root.crt"]
private_key_file_name = "signer.key"
vCon.sign(cert_chain_file_names, private_key_file_name)

# NOTE: vCon is now read only

# serialize the signed vCon
signed_vcon_json = vCon.dumps()

Example Verification of Signed vCon

# Construct a vCon from a signed vCon JSON string
signed_vcon = vcon.Vcon()
signed_vcon.loads(signed_vcon_json)

# NOTE: cannot read signed vCon data until it is verified

# Verify the signed vCon 
ca_list = ["ca.crt"]
signed_vcon.verify(ca_list)

Test Certificates

A set of certifcates have been created for the purpose of testing the signing and verification of vCons using the vcon python package. The certifcates and their private keys can be found here. DO NOT USE THESE CERTIFICATES OR KEYS IN PRODUCTION. They are for TESTING ONLY!!!!

You can substitue the following values in the variables in the above examples, if you would like to use the test certs and keys:

cert_chain_file_names = ["certs/fake_grp.crt", "certs/fake_div.crt", "ca_root.crt"]
private_key_file_name = "certs/fake_grp.key"
ca_list = ["certs/fake_ca_root.crt"]

Layers for AWS Lambda Functions

If you would like to use the python vcon package in an AWS lambda function, a layer for the vcon package and each of its dependencies can be created using the following command:

make layers