LocalWhisperTranscriber
Transcribe audio files using OpenAI's Whisper model running locally on your machine.
Key Features
- Transcribes audio to text using a locally downloaded Whisper model.
- Supports multiple model sizes from
tinytolarge-v3. - Accepts audio files as file paths,
Pathobjects, orByteStreamobjects. - Returns transcriptions as Haystack
Documentobjects. - Configurable device support (CPU, GPU) for inference.
- Supports additional Whisper parameters like language, task, and temperature.
Configuration
- Drag the
LocalWhisperTranscribercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Set the
modelto the Whisper model size you want to use. Larger models are more accurate but slower. Available sizes are:tiny,tiny.en,base,base.en,small,small.en,medium,medium.en,large,large-v1,large-v2, andlarge-v3.
- Set the
- Go to the Advanced tab to configure
deviceandwhisper_paramsfor options likelanguageandtask.
Connections
LocalWhisperTranscriber receives a list of audio file sources. It outputs a list of Document objects containing the transcription text. Connect its documents output to a splitter, embedder, or other pipeline components.
Source Code
To check this component's source code, open whisper_local.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
LocalWhisperTranscriber:
type: haystack_integrations.components.audio.whisper.LocalWhisperTranscriber
init_parameters:
model: large
whisper_params:
language: en
Using the Component in a Pipeline
# haystack-pipeline
components:
LocalWhisperTranscriber:
type: haystack_integrations.components.audio.whisper.LocalWhisperTranscriber
init_parameters:
model: base
whisper_params:
language: en
task: transcribe
document_splitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: word
split_length: 250
split_overlap: 30
connections:
- sender: LocalWhisperTranscriber.documents
receiver: document_splitter.documents
max_runs_per_component: 100
metadata: {}
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
sources | List[Union[str, Path, ByteStream]] | A list of audio file paths, Path objects, or ByteStream objects to transcribe. |
whisper_params | Optional[Dict[str, Any]] | Additional parameters for the Whisper transcription, overriding init-time values. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | The transcriptions as Haystack Documents. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
model | str | large | The Whisper model size to use. Options are tiny, tiny.en, base, base.en, small, small.en, medium, medium.en, large, large-v1, large-v2, and large-v3. The .en variants are English-only models. |
device | Optional[ComponentDevice] | None | The device to run inference on. If not set, automatically detected. |
whisper_params | Optional[Dict[str, Any]] | None | Additional parameters passed to whisper.transcribe(). Supports language (ISO 639-1 code), task ("transcribe" or "translate"), temperature, and other Whisper options. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
sources | List[Union[str, Path, ByteStream]] | A list of audio file paths or streams to transcribe. | |
whisper_params | Optional[Dict[str, Any]] | None | Additional parameters to override init-time values. |
Related Information
Was this page helpful?