How to use the command 'whisper' (with examples)
The ‘whisper’ commandline tool is an audio processing utility developed by OpenAI, designed to convert audio files into various text-based formats such as txt
, vtt
, srt
, tsv
, and json
. By leveraging advanced audio recognition models, Whisper not only simplifies the transcription process but also offers options for improved specificity and customization according to user needs. It’s particularly useful for creating transcripts, subtitles, and data analyses from audio content efficiently.
Convert a specific audio file to all of the given file formats
Code:
whisper path/to/audio.mp3
Motivation:
This use case is perfect for users who need to leverage a variety of output formats from a single audio file. It could be useful for different applications—perhaps a textual summary, automatically generated subtitles for a video, or a detailed timestamped transcript that a data analyst might need. By converting the file into multiple formats at once, it saves time and effort, eliminating the need to execute repeated commands.
Explanation:
whisper
: The primary command to invoke the Whisper tool.path/to/audio.mp3
: The path to the input audio file you want to convert. This will be processed into all supported formats by default.
Example Output:
The audio is processed and converted into multiple files such as audio.txt
, audio.vtt
, audio.srt
, audio.tsv
, and audio.json
, all saved in the same directory as the original audio file.
Convert an audio file specifying the output format of the converted file
Code:
whisper path/to/audio.mp3 --output_format txt
Motivation:
This use case is tailored for users who require a particular file format to suit their specific needs without cluttering their directories with multiple unnecessary file types. For example, if a journalist needs a plain text transcript to work on an article, producing only a txt
file makes the workflow significantly simpler and manageable.
Explanation:
whisper
: Initiates the Whisper processing tool.path/to/audio.mp3
: Specifies the input audio file location.--output_format txt
: Specifies that the output should be in text format only.
Example Output:
The command generates a single audio.txt
file containing the transcription of the audio, placed in the same location as the audio file.
Convert an audio file using a specific model for conversion
Code:
whisper path/to/audio.mp3 --model tiny.en
Motivation:
This usage is particularly useful when the user has constraints in terms of computing power or specific accuracy requirements. The availability of model options like tiny
, base
, small
, medium
, and large
allows users to select an appropriate model that balances between performance and accuracy, making it valuable for tasks that require speed over precision or vice versa.
Explanation:
whisper
: The command to run the Whisper program.path/to/audio.mp3
: Specifies the input audio file.--model tiny.en
: Instructs Whisper to use the ’tiny.en’ model, which is a lightweight and faster model tailored for English language transcription.
Example Output:
The audio is transcribed using the ’tiny.en’ model, producing a set of files depending on the default or specified output format, such as audio.txt
.
Convert an audio file specifying which language the audio file is in to reduce conversion time
Code:
whisper path/to/audio.mp3 --language english
Motivation:
This case is aimed at users who want to optimize the performance and reduce the conversion time of their transcription tasks. By explicitly stating the language, the tool can bypass language detection, thus speeding up the overall process. This is especially beneficial when handling large batches of files in a known language.
Explanation:
whisper
: Initiates the Whisper tool.path/to/audio.mp3
: Designates the input audio file location.--language english
: Informs Whisper of the language spoken in the audio to bypass automatic language detection.
Example Output:
The audio is transcribed with pre-set language rules, saving processing resources and producing quick output files like audio.txt
.
Convert an audio file and save it to a specific location
Code:
whisper path/to/audio.mp3 --output_dir "path/to/output"
Motivation:
Organizational efficiency is the motive here, allowing users to direct all output files to a designated directory. This is beneficial when managing large projects where keeping input and output resources separate can help maintain clarity and structure within the project’s folder architecture.
Explanation:
whisper
: Activates the Whisper command.path/to/audio.mp3
: Points to the audio file for conversion.--output_dir "path/to/output"
: Specifies the directory path where the converted files should be saved.
Example Output:
The converted files, such as audio.txt
, are saved in the specified directory path/to/output
.
Convert an audio file in quiet mode
Code:
whisper path/to/audio.mp3 --verbose False
Motivation:
This use case is geared towards minimizing interruptions or distractions during processes. Useful in environments where keeping logs and process outputs minimal is essential, or where multiple instances may be running, and the user wishes to avoid excessive console output clutter.
Explanation:
whisper
: The command to start the Whisper utility.path/to/audio.mp3
: Indicates which audio file to process.--verbose False
: Instructs the program to operate in quiet mode, suppressing non-essential output to the console.
Example Output:
Minimal, if any, console output is generated during the file conversion. Output files like audio.txt
are created without additional process information being displayed.
Conclusion:
The ‘whisper’ command simplifies the process of audio-to-text conversion, offering flexibility and customization through its range of options. From determining output formats and processing models to optimizing conversion times and organizing files efficiently, Whisper caters to various user requirements, enhancing productivity and accuracy in audio transcription tasks.