Boost Transcription Accuracy with LeMUR (LeMUR Custom Vocab)
This Cookbook is designed to help you transcribe audio files using the AssemblyAI API and boost transcription accuracy using a custom vocabulary list and LeMUR. Custom vocabulary can include company names, industry-specific terms, and other rare words that might not be accurately transcribed by pre-trained models. For example, a company name like Sprinklr
may be transcribed incorrectly, and this is where customer vocabulary boosting can help.
Quickstart
Getting Started
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for an AssemblyAI account and get your API key from your dashboard.
Side Note: Costs
We’ve optimized the LeMUR prompt to minimize the number of output tokens produced by the model, which will reduce the overall cost of this solution significantly, but if you do want to calculate the total number of input / output tokens and cost associated with them, please use our LeMUR pricing cookbook as a reference on how to do so.
Step-by-Step Instructions
Now let’s install the AssemblyAI SDK and the Termcolor library, which will be used for showing which corrections LeMUR has made to the transcript.
Then we’ll import the SDK and set our AssemblyAI API key.
Next, we’ll transcribe our file and save it for later use with LeMUR.
Now we’ll define our first function for this use case. This function will correct a given sentence using LeMUR with the provided custom vocab list. We’ll then call this function for each sentence in our transcript to correct specific words. Please note, though, that this means each sentence will require another request to LeMUR, which may cause you to hit request per minute (RPM) limits and receive an error. If you do end up receiving RPM errors often, please reach out to support@assemblyai.com to have your RPM limit increased.
Then we can define our second function. This function will extract all of the sentences from our transcript and pass them to LeMUR with our custom vocabulary list for correction. We’ll be importing termcolor
to show which words have been corrected with LeMUR.
Run your Example
Now you can try an example using our sample MP3 file and some word corrections. We chose to use some media with a lot of unique words, a World of Warcraft trailer, to help showcase how this solution can account for multiple ways that a unique word might be mis-transcribed initially. Below is the original transcript, the corrections made, and the final corrected transcript for comparison.