Skip to content

pyannoteai/pyannoteAI-python-sdk

Repository files navigation

Official pyannoteAI Python SDK

Installation

$ pip install pyannoteai.sdk

Then head over to dashboard.pyannote.ai and create an API key.

Speaker diarization

# instantiate client
from pyannoteai.sdk import Client
client = Client("your-api-key")

# upload conversation file
media_url = client.upload('/path/to/conversation.wav')

# submit a diarization job
job_id = client.diarize(media_url)

# retrieve diarization
diarization = client.retrieve(job_id)
# diarization['output']['diarization'] contains diarization output

Use help(client.diarize) to learn about options.

Speaker identification

# create a voiceprint from a sample of Lex's voice
lex_url = client.upload('/path/to/lex.wav')
job_id = client.voiceprint(lex_url)
lex = client.retrieve(job_id)
# lex['output']['voiceprint'] contains Lex's voiceprint

# create a voiceprint from a sample of Mark's voice
mark_url = client.upload('/path/to/mark.wav')
job_id = client.voiceprint(mark_url)
mark = client.retrieve(job_id)
# mark['output']['voiceprint'] contains Mark's voiceprint

# use those voiceprints to track Lex and Mark in the conversation
voiceprints = {'lex': lex['output']['voiceprint'], 'mark': mark['output']['voiceprint']}
job_id = client.identify('/path/to/conversation.wav', voiceprints)
identification = client.retrieve(job_id)
# identification['output']['identification'] contains identification output

Use help(client.identify) to learn about options.