🆕Creating Custom Vocabulary

📖 Create Your Own Custom Vocabulary

Improve transcription accuracy by creating a Custom Vocabulary. This feature is only enabled for English. By using this feature you can define some frequently used words/word groups in your transcriptions to increase transcription accuracy when those words are used.


import requests
import json

# Define the user's API key and language code
user_api_key = 'your_api_key'
language_code = 'en-US'

# URL of your Lambda function that generates the presigned URL
url = "https://api.tor.app/dev-api/features/create-custom-vocabulary"

# Prepare the parameters dictionary
params = {
    'language': "en", # Only English is available for now.
    'hashed_id': user_api_key
}

# Make the GET request to the API
response = requests.get(url, params=params)

# Check the response status code
if response.status_code == 200:
    response_data = response.json()
    print("Success:", response_data)
    presigned_url = response_data['url']

    # List of words or phrases to be written to the file
    words = ["Transkriptor", "Speech To Text", "Chat With Your Transcription", "Recognise Speakers"]

    # File path for the new file
    file_path = '/path/to/your/custom_words.txt'

    # Write words to a .txt file
    with open(file_path, 'w') as file:
        file.write(', '.join(words))
    
    # Upload the file using the presigned URL
    with open(file_path, 'rb') as f:
        upload_response = requests.put(presigned_url, data=f.read())
        if upload_response.status_code == 200:
            print("File uploaded successfully.")
        else:
            print("Failed to upload file:", upload_response.text)
else:
    print("Failed with status code", response.status_code, response.text)

Response


200 OK - Presigned URL Generated Successfully
{
    "message": "Presigned URL generated successfully",
    "url": "https://s3.amazonaws.com/app-options/custom_phrases/example_hashed_id/en_phrases.txt?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&Expires=1432075984&Signature=veryLongSignatureValue%3D"
}

500 Internal Server Error - Error Generating Presigned URL
{
    "Error generating presigned URL"
}