The Media API was created to help you build a prototype or proof of concept. Any data stored is temporary and will be removed. For production use cases you should choose your preferred storage provider.

A few key points:

Temporary: The media you store with these APIs is temporary and will be automatically removed within 24 - 48 hours.

Secure: The media is stored in an isolated location that only you can access with your API token. It is encrypted while in transit with HTTPS. Access to the production system is controlled to prevent unauthorized use.

Create and use a temporary storage location

A typical workflow to upload your media is:

  • Create a temporary storage location with a pre-signed URL and upload your media.
  • Use your temporary storage with Jobs APIs.
upload-file.py
import os
import requests

# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("PYANNOTEAI_API_TOKEN", "your_token_here")

url = "https://api.pyannote.ai/v1/media/input"
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json"
}
 # Replace the url value with your temporary storage location that you want to create.
body = {
    "url": "media://example/conversation.wav",
}

 # Create a pre-signed URL.
response = requests.post(url, json=body, headers=headers)
response.raise_for_status()
data = response.json()
presigned_url = data["url"]
print("Uploading {0} to {1}".format(input_path, presigned_url))
with open(input_path, "rb") as input_file:
    # Upload your media.
    requests.put(presigned_url, data=input_file)

2. Use your temporary storage with Jobs APIs

After you have uploaded your media, you can use the Jobs API to process it.

create-job.py
import os
import requests

# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("PYANNOTEAI_API_TOKEN", "your_token_here")

# Replace the input value with your temporary storage location.
body = {
  "url" : "media://example/conversation.wav",
}

url = "https://api.pyannote.ai/v1/diarize"
headers = {
   "Authorization": "Bearer {0}".format(api_token),
   "Content-Type": "application/json"
}

response = requests.post(url, json=body, headers=headers)
response.raise_for_status()
print(response.json())

API Reference