Toggle Menu
Prev Up Next

# `langchain_community.document_loaders.google_speech_to_text`.GoogleSpeechToTextLoader

class langchain_community.document_loaders.google_speech_to_text.GoogleSpeechToTextLoader(project_id: str, file_path: str, location: str = 'us-central1', recognizer_id: str = '_', config: Optional[RecognitionConfig] = None, config_mask: Optional[FieldMask] = None)

  [Deprecated] Loader for Google Cloud Speech-to-Text audio transcripts.

  It uses the Google Cloud Speech-to-Text API to transcribe audio files and loads the transcribed text into one or more Documents, depending on the specified format.

  To use, you should have the `google-cloud-speech` python package installed.

  Audio files can be specified via a Google Cloud Storage uri or a local file path.

  For a detailed explanation of Google Cloud Speech-to-Text, refer to the product documentation. https://cloud.google.com/speech-to-text

  Notes

  Deprecated since version 0.0.32.

  Initializes the GoogleSpeechToTextLoader.

  Parameters

    - project_id (str) – Google Cloud Project ID.

    - file_path (str) – A Google Cloud Storage URI or a local file path.

    - location (str) – Speech-to-Text recognizer location.

    - recognizer_id (str) – Speech-to-Text recognizer id.

    - config (Optional[RecognitionConfig]) – Recognition options and features. For more information: https://cloud.google.com/python/docs/reference/speech/latest/google.cloud.speech_v2.types.RecognitionConfig

    - config_mask (Optional[FieldMask]) – The list of fields in config that override the values in the `default_recognition_config` of the recognizer during this recognition request. For more information: https://cloud.google.com/python/docs/reference/speech/latest/google.cloud.speech_v2.types.RecognizeRequest

  Methods

  `__init__`(project_id, file_path[, location, ...]) | Initializes the GoogleSpeechToTextLoader.
  `alazy_load`() | A lazy loader for Documents.
  `aload`() | Load data into Document objects.
  `lazy_load`() | A lazy loader for Documents.
  `load`() | Transcribes the audio file and loads the transcript into documents.
  `load_and_split`([text_splitter]) | Load Documents and split into chunks.

  __init__(project_id: str, file_path: str, location: str = 'us-central1', recognizer_id: str = '_', config: Optional[RecognitionConfig] = None, config_mask: Optional[FieldMask] = None)

    Initializes the GoogleSpeechToTextLoader.

    Parameters

      - project_id (str) – Google Cloud Project ID.

      - file_path (str) – A Google Cloud Storage URI or a local file path.

      - location (str) – Speech-to-Text recognizer location.

      - recognizer_id (str) – Speech-to-Text recognizer id.

      - config (Optional[RecognitionConfig]) – Recognition options and features. For more information: https://cloud.google.com/python/docs/reference/speech/latest/google.cloud.speech_v2.types.RecognitionConfig

      - config_mask (Optional[FieldMask]) – The list of fields in config that override the values in the `default_recognition_config` of the recognizer during this recognition request. For more information: https://cloud.google.com/python/docs/reference/speech/latest/google.cloud.speech_v2.types.RecognizeRequest

  async alazy_load() → AsyncIterator[Document]

    A lazy loader for Documents.

    Return type

      AsyncIterator[Document]

  async aload() → List[Document]

    Load data into Document objects.

    Return type

      List[Document]

  lazy_load() → Iterator[Document]

    A lazy loader for Documents.

    Return type

      Iterator[Document]

  load() → List[Document]

    Transcribes the audio file and loads the transcript into documents.

    It uses the Google Cloud Speech-to-Text API to transcribe the audio file and blocks until the transcription is finished.

    Return type

      List[Document]

  load_and_split(text_splitter: Optional[TextSplitter] = None) → List[Document]

    Load Documents and split into chunks. Chunks are returned as Documents.

    Do not override this method. It should be considered to be deprecated!

    Parameters

      text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

    Returns

      List of Documents.

    Return type

      List[Document]

# Examples using GoogleSpeechToTextLoader

- Google

- or a local file path: file_path = “./audio.wav”