Skip to content

transcription

Open In Colab Youtube

Single-Module Pipeline: transcribe

🇨🇴 Versión en español de este documento

This document is a walkthrough of how to assemble and use a single-module pipeline that only includes a transcribe module.

Transcription is the process of converting spoken language into written text. Its applications include creating subtitles for videos, facilitating accessible content for the hearing-impaired, automating meeting minutes, and generating searchable archives of spoken information for easy reference.

The document is divided into the following sections:

Pipeline Setup

Let's first instantiate a single-module transcribe pipeline.

We use the create_pipeline method for this, passing only the transcribe module name into module_chain.

# create a pipeline with a single transcribe module
pipeline = krixik.create_pipeline(name="single_transcribe_1", module_chain=["transcribe"])

Required Input Format

The transcribe module accepts audio inputs. Acceptable file formats are only MP3 for the time being.

Let's take a quick look at a valid input file, and then process it.

# examine contents of input file
import IPython

IPython.display.Audio(data_dir + "input/Interesting Facts About Colombia.mp3")

Using the Default Model

Let's process our test input file using the transcribe module's default model : whisper-tiny.

Given that this is the default model, we need not specify model selection through the optional modules argument in the process method.

# process the file with the default model
process_output = pipeline.process(
    local_file_path=data_dir + "input/Interesting Facts About Colombia.mp3",  # the initial local filepath where the input file is stored
    local_save_directory=data_dir + "output",  # the local directory that the output file will be saved to
    expire_time=60 * 30,  # process data will be deleted from the Krixik system in 30 minutes
    wait_for_process=True,  # wait for process to complete before returning IDE control to user
    verbose=False,
)  # do not display process update printouts upon running code

The output of this process is printed below. To learn more about each component of the output, review documentation for the process method.

Because the output of this particular module-model pair is a JSON file, the process output is provided in this object as well (this is only the case for JSON outputs). Moreover, the output file itself has been saved to the location noted in the process_output_files key. The file_id of the processed input is used as a filename prefix for the output file.

To confirm that everything went as it should have, let's load in the text file output from process_output_files:

# load in process output from file - here we only print the transcript, and not the timestamped version, since the output is quite long
with open(process_output["process_output_files"][0]) as f:
    print(json.dumps(json.load(f)[0]["transcript"].strip(), indent=2))
"That's episode looking at the great country of Columbia. We looked at some really basic facts. It's name, a bit of its history, the type of people that live there, land size and all that jazz. But in this video, we're gonna go into a little bit more of a detailed look. Yo, what is going on guys? Welcome back to F2D facts. The channel where I look at people cultures and places, my name is Dave Wouple. And today we are gonna be looking more at Columbia in our Columbia Part 2 video. Which just reminds me guys, this is part of our Columbia playlist. I'll put it down in the description box below and I'll talk about that more at the end of the video. But if you're new here, join me every single Monday to learn about new countries from around the world. You can do that by hitting that subscribe and that belt notification button. But that skits."

The returned JSON file has not only the snippets of transcribed text, but along with each includes timestamps and a "confidence" value for the accuracy of each transcription. Those timestamps and confidence values have been excluded from the above printout for simplicity's sake.

Using a Non-Default Model

To use a non-default model like whisper-large-v3, we must enter it explicitly through the modules argument when invoking the process method.

We do so below to process the same input file shown above.

# process the file with a non-default model
process_output = pipeline.process(
    local_file_path=data_dir + "input/Interesting Facts About Colombia.mp3",  # all parameters save 'modules' as above
    local_save_directory=data_dir + "output",
    expire_time=60 * 30,
    wait_for_process=True,
    verbose=False,
    modules={"transcribe": {"model": "whisper-large-v3"}},
)  # specify a non-default model for this process as well as its parameters
# load in process output from file - here we only print the transcript, and not the timestamped version, since the output is quite long
with open(process_output["process_output_files"][0]) as f:
    print(json.dumps(json.load(f)[0]["transcript"].strip(), indent=2))
"Episode looking at the great country of Colombia We looked at some really just basic facts its name a bit of its history the type of people that live there Landsize and all that jazz, but in this video, we're gonna go into a little bit more of a detailed look Yo, what is going on guys? Welcome back to have to D facts a channel where I look at people cultures and places My name is Dave Walpole and today we are gonna be looking more at Colombia in our Columbia part 2 video Which just reminds me guys, this is part of our Columbia playlist I'll put it down there in the description box below and I'll talk about that more at the end of the video But if you're new here join me every single Monday to learn about new countries from around the world You can do that by hitting that subscribe and that belt notification button, but let's get started"