Requirements

Python 3.8+ is required to ensure proper functionality of all necessary libraries. As best practice, it is recommended to set up your environment variables as such:
export VALENCE_API_KEY= "api_key_here"
export VALENCE_DISCRETE_URL= "https://discrete-api-url" # Optional: custom Discrete audio endpoint
export VALENCE_ASYNCH_URL= "https://asynch-api-url" # Optional: custom Asynch audio endpoint
export VALENCE_LOG_LEVEL= "DEBUG"  # Optional: INFO, DEBUG, ERROR
Your Valence API Key is required, while while all other fields are optional.

Usage

Install the package via pip.
pip install valenceai
Client Constructor:
from valenceai import ValenceClient

client = ValenceClient(
    api_key=None,           # API key (or use VALENCE_API_KEY env var)
    part_size=5*1024*1024,  # Size of each upload chunk for asynch audio
    show_progress=True,     # Show progress bar for asynch uploads
    max_threads=3          # Number of concurrent threads for asynch uploads
)
DiscreteAPI:
from valenceai import ValenceClient

client = ValenceClient()
result = client.discrete.emotions("YOUR_FILE.wav")
print(result)
AsynchAPI:
from valenceai import ValenceClient

client = ValenceClient(show_progress=True)
request_id = client.asynch.upload("YOUR_FILE.wav")

# Get emotions from uploaded audio
result = client.asynch.emotions(request_id)
print(result)
More information about additional parameters and expected values can be found in the API Reference.

Ready to Get Started?

Check out the Valence package on PyPI →