Toggle Menu
Prev Up Next

# `langchain_community.document_loaders.parsers.audio`.OpenAIWhisperParser

class langchain_community.document_loaders.parsers.audio.OpenAIWhisperParser(api_key: Optional[str] = None, *, chunk_duration_threshold: float = 0.1, base_url: Optional[str] = None)

  Transcribe and parse audio files.

  Audio transcription is with OpenAI Whisper model.

  Parameters

    - api_key (Optional[str]) – OpenAI API key

    - chunk_duration_threshold (float) – minimum duration of a chunk in seconds NOTE: According to the OpenAI API, the chunk duration should be at least 0.1 seconds. If the chunk duration is less or equal than the threshold, it will be skipped.

    - base_url (Optional[str]) –

  Methods

  `__init__`([api_key, ...]) |
  `lazy_parse`(blob) | Lazily parse the blob.
  `parse`(blob) | Eagerly parse the blob into a document or documents.

  __init__(api_key: Optional[str] = None, *, chunk_duration_threshold: float = 0.1, base_url: Optional[str] = None)
    Parameters

      - api_key (Optional[str]) –

      - chunk_duration_threshold (float) –

      - base_url (Optional[str]) –

  lazy_parse(blob: Blob) → Iterator[Document]

    Lazily parse the blob.

    Parameters

      blob (Blob) –

    Return type

      Iterator[Document]

  parse(blob: Blob) → List[Document]

    Eagerly parse the blob into a document or documents.

    This is a convenience method for interactive development environment.

    Production applications should favor the lazy_parse method instead.

    Subclasses should generally not over-ride this parse method.

    Parameters

      blob (Blob) – Blob instance

    Returns

      List of documents

    Return type

      List[Document]

# Examples using OpenAIWhisperParser

- Google

- set a flag to switch between local and remote parsing