Recognise Speakers in Transcription

๐Ÿ”Š Recognizing Speakers in Your Transcription

You can create Speaker Profiles so that in your future transcriptions you won't have to manually adjust speaker names. Using clear and long audio files will help with the success of assigning Speaker Profiles in transcriptions. You can create speaker profiles either from a local audio file or from one of your transcriptions in Transkriptor.

Create a Speaker Profile From a Local Audio File - Part 1 Generate Upload URL

To create a speaker profile, upload a local audio file. This function will generate the URL that you are supposed to upload your audio file.

import requests
import json

api_key = "user_api_key"
speaker_label_name = "speaker_label_name"
url = f"https://um2vro8lrb.execute-api.eu-central-1.amazonaws.com/prod/transkriptorannotation/createurlforprofile"

payload = {
    "hashed_id": api_key,
    "speaker_name": speaker_label_name
}
headers = {}

response = requests.request("POST", url, headers=headers, json=payload)

upload_url = json.loads(response.text)["upload_url"]

Response

200 OK
{
  "upload_url": "https://sampleurl"
}

403 Forbidden
{
  "message": "Upload limit reached for this speaker"
}

500 Internal Server Error
{
  "error": "Detailed error message"
}

Create a Speaker Profile From a Local Audio File - Part 2 Upload Your Audio File

You can upload your audio file to the specified URL as shown below.

# Assuming 'response' is obtained from your previous request
upload_url = json.loads(response.text)["upload_url"]

# Specify the path to your audio file
file_path = 'example.mp3'

# Open the file in binary mode
with open(file_path, 'rb') as f:
    files = {'file': f}

    # PUT request to upload the file using the presigned URL
    upload_response = requests.put(upload_url, data=f)

    # Print the response from the server
    print(upload_response.status_code)
    print(upload_response.text)

Response

200 OK

200

Create a Speaker Profile From a Local Audio File - Part 3 Generate Speaker Profile

After you have successfully uploaded your audio file, make a request to finisher API as shown below. Make sure speaker_label_name matches the name in your request in Part 1


import requests
import json

api_key = "user_api_key"
speaker_label_name = "speaker_label_name"
url = f"https://um2vro8lrb.execute-api.eu-central-1.amazonaws.com/prod/transkriptorannotation/uploaderfinisher"

payload = {
    "hashed_id": api_key,
    "speaker_name": speaker_label_name
}
headers = {}

response = requests.request("POST", url, headers=headers, json=payload)

Response

200 OK
{
  "statusCode": 200,
  "body": "Audio processed and uploaded successfully!"
}

403 Forbidden
{
  "statusCode": 403,
  "body": {
    "message": "Upload limit reached for this speaker"
  }
}

500 Internal Server Error
{
  "statusCode": 500,
  "body": "Error processing audio file: Detailed error message"
}

Create a Speaker Profile From Previous Transcriptions

As well as uploading a new audio file to create a speaker profile, you can create a speaker profile from your previous transcriptions.


import requests
import json

api_key = "user_api_key"
order_id = "file_order_id"
old_speaker_name = "SPK_1"
new_speaker_name = "new speaker name"
start_time = 0 # in ms
end_time = 13000 # in ms

url = f"https://um2vro8lrb.execute-api.eu-central-1.amazonaws.com/prod/transkriptorannotation/useraddedspeaker"

payload = {
    "start_time": start_time,
    "end_time": end_time,
    "order_id": order_id,
    "hashed_id": api_key,
    "old_speaker_name": old_speaker_name,
    "new_speaker_name": new_speaker_name
}
headers = {}

response = requests.request("POST", url, headers=headers, json=payload)

print(response.text)

Response

200 OK
"Audio processed and uploaded successfully!"

400 Bad Request
{
  "error": "The request is invalid or malformed."
}

500 Internal Server Error
{
  "error": "An error occurred on the server."
}

Get a List of Your Speaker Profiles

You can view the list of speaker profiles you created.

import requests
import json

api_key = "user_api_key"
url = f"https://um2vro8lrb.execute-api.eu-central-1.amazonaws.com/prod/transkriptorannotation/getuserprofiles?hashed_id={api_key}"

payload = {}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

speaker_labels = json.loads(response.text)
print(f"Speaker profiles: ",speaker_labels)

Response

200 OK
{
  "statusCode": 200,
  "body": [
    {
      "speaker_name": "speaker1",
      "download_url": "https://download_url_1"
    },
    {
      "speaker_name": "speaker2",
      "download_url": "https://download_url_2"
    }
  ]
}

500 Error Fetching User Settings
{
  "statusCode": 500,
  "body": {
    "error": "Failed to fetch user settings"
  }
}

500 Internal Server Error
{
  "statusCode": 500,
  "body": {
    "error": "Detailed error message"
  }
}

Learn Your Speaker Profiles Count and See If You Have Reached Limit For Creating Speaker Profile

For efficiency of transcribing process speaker profile count is limited to 20, if you think you need to increase that limit please contact us.

import requests
import json

api_key = "user_api_key"
url = f"https://um2vro8lrb.execute-api.eu-central-1.amazonaws.com/prod/transkriptorannotation/checkspeakercount?hashed_id={api_key}"

payload = {}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

speaker_label_count = json.loads(response.text)
print(f"Speaker profile count: ",speaker_label_count)

Response

200 OK
{
  "statusCode": 200,
  "body": {
    "speaker_label_count": 7,
    "limit_reached": false
  }
}

200 OK (Limit Reached)
{
  "statusCode": 200,
  "body": {
    "speaker_label_count": 10,
    "limit_reached": true
  }
}

500 Internal Server Error
{
  "statusCode": 500,
  "body": {
    "error": "Failed to fetch user settings"
  }
}

Delete a Speaker Profile

You can delete a speaker profile that you created.

import requests
import json

api_key = "user_api_key"
speaker_label_name = "speaker label name"
url = f"https://um2vro8lrb.execute-api.eu-central-1.amazonaws.com/prod/transkriptorannotation/deleteuserprofile"

payload = {
    "hashed_id": api_key,
    "speaker_name": speaker_label_name
}
headers = {}

response = requests.request("POST", url, headers=headers, json=payload)

print(response.text)

Response

200 OK
{
  "statusCode": 200,
  "body": "Speaker deleted successfully"
}

404 Not Found
{
  "statusCode": 404,
  "body": "Speaker not found"
}

500 Internal Server Error
{
  "statusCode": 500,
  "body": "Failed to fetch user settings"
}

500 Internal Server Error
{
  "statusCode": 500,
  "body": "Failed to update user settings"
}