Skip to main content

Extracts metadata about a video, such as the transcript, duration, and comments, with optional audio transcription using OpenAI Whisper.

Project description

PAR YT2Text

PyPI PyPI - Python Version
Runs on Linux | MacOS | Windows Arch x86-63 | ARM | AppleSilicon
PyPI - License

PAR YT2Text Based on yt By Daniel Miessler with the addition of OpenAI Whisper for videos that don't have transcripts.

"Buy Me A Coffee"

Features

  • Extract metadata, transcripts, and comments from YouTube videos
  • If the transcript is not available, optionally use OpenAI Whisper API or Local model to transcribe the audio

Prerequisites

  • To install PAR YT2Text, make sure you have Python 3.11.
  • Create a GOOGLE API key
  • If you want to use OpenAI Whisper API, create an OPENAI API key (An OpenAI key is not needed for local OpenAI Whisper).

uv is recommended

Linux and Mac

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Installation

Installation From Source WITHOUT support for local OpenAI Whisper

  • Clone the repository:
git clone https://github.com/paulrobello/par_yt2text.git
cd par_yt2text
uv sync

Installation From Source WITH support for local OpenAI Whisper

  • Clone the repository:
git clone https://github.com/paulrobello/par_yt2text.git
cd par_yt2text
uv sync -U --extra local-whisper

Installation From PyPI WITHOUT support for local OpenAI Whisper

uv tool install par_yt2text
pipx install par_yt2text

Installation From PyPI WITH support for local OpenAI Whisper

To install PAR YT2Text from PyPI with local OpenAI Whisper, run any of the following commands:

uv tool install -U 'git+https://github.com/paulrobello/par_yt2text[local-whisper]' --index https://download.pytorch.org/whl/cu121 --index-strategy unsafe-best-match
pipx install 'par_yt2text[local-whisper] @ git+https://github.com/paulrobello/par_yt2text' --pip-args="--extra-index-url https://download.pytorch.org/whl/cu121"

Usage

Create a file called ~/.par_yt2text.env with your Google API key and OpenAI API key in it.

GOOGLE_API_KEY= # needed for youtube-transcript-api
OPENAI_API_KEY= # needed for OpenAI API whisper audio transcription (An OpenAI key is not needed for local OpenAI Whisper).
PAR_YT2TEXT_SAVE_DIR= # where to save the transcripts if you dont specify a folder in the --save option

Whisper audio transcription will only be used if you specify the --whisper or --local-whisper option and the video does not have a transcript.
If you want to force the use of whisper audio transcription, use the --force-whisper option with one of the --whisper or --local-whisper options.

Often the transcript will come back a single long line. PAR YT2Text will attempt to add newlines to the transcript to make it easier to read unless you specify the --no-fix-newlines option.

Local Whisper

While the OpenAI Whisper API is fast and inexpensive a free local option is available.
NOTE: Local whisper mode can be very slow on cpu. If you have a CUDA enabled GPU it will be used unless you specify the --whisper-device option.
turbo is the default local model however you should consult the OpenAI Whisper documentation to see what models are available and select the best one for your VRAM needs.

Running from source

uv run par_yt2text --transcript --whisper 'https://www.youtube.com/watch?v=COSpqsDjiiw'

Running if installed from PyPI

par_yt2text --transcript --whisper 'https://www.youtube.com/watch?v=COSpqsDjiiw'

Example of forcing use of local Whisper if tool was installed with local Whisper enabled

par_yt2text --transcript --force-whisper --whisper-local 'https://www.youtube.com/watch?v=COSpqsDjiiw'

Options

usage: par_yt2text [-h] [--duration] [--transcript] [--comments] [--metadata] [--no-fix-newlines] [--whisper] [--local-whisper]
                   [--whisper-device {auto,cpu,cuda}] [--force-whisper] [--whisper-model WHISPER_MODEL] [--lang LANG] [--save FILE]
                   url

positional arguments:
  url                   YouTube video URL

options:
  -h, --help            show this help message and exit
  --duration            Output only the duration
  --transcript          Output only the transcript
  --comments            Output the comments on the video
  --metadata            Output the video metadata
  --no-fix-newlines     Dont attempt to fix missing newlines from sentences
  --whisper             Use OpenAI Whisper to transcribe the audio if transcript is not available
  --local-whisper       Use Local OpenAI Whisper to transcribe the audio if transcript is not available
  --whisper-device {auto,cpu,cuda}
                        Device to use for local Whisper cpu, cuda (default: auto)
  --force-whisper       Force use of selected Whisper to transcribe the audio even if transcript is available
  --whisper-model WHISPER_MODEL
                        Whisper model to use for audio transcription (default-api: whisper-1, default-local: turbo)
  --lang LANG           Language for the transcript (default: English)
  --save FILE           Save the output to a file

Whats New

  • Version 0.2.4:
    • Fixed cross-platform path handling for Windows compatibility
  • Version 0.2.3:
    • Updated dependencies and ensure Python 3.14 compatibility
  • Version 0.2.2:
    • Updated dependencies
  • Version 0.2.1:
    • Updated dependencies
  • Version 0.2.0:
    • Added support for local OpenAI Whisper
  • Version 0.1.0:
    • Initial release

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Paul Robello - probello@gmail.com (Based on yt By Daniel Miessler)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

par_yt2text-0.2.5.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

par_yt2text-0.2.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file par_yt2text-0.2.5.tar.gz.

File metadata

  • Download URL: par_yt2text-0.2.5.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for par_yt2text-0.2.5.tar.gz
Algorithm Hash digest
SHA256 926f1dbaa9b845a7c2ad20ded9ccbff00abc2c1e5f1ed8e9fefe14ea4634317b
MD5 e4e1faf00793782df6935245fb73a383
BLAKE2b-256 eb198f93ebdf540c63942448c6ef19936c0fe243672aeddfbd486088e845bc15

See more details on using hashes here.

Provenance

The following attestation bundles were made for par_yt2text-0.2.5.tar.gz:

Publisher: release-all.yml on paulrobello/par_yt2text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file par_yt2text-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: par_yt2text-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for par_yt2text-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0331877e1e87c825867005703f2f79b088f7ba22ccd89979e6e41b7c0181f737
MD5 cf716605d801408b818baf782ff5175c
BLAKE2b-256 b466ac2db9b45d4eec44ad7bc959c13721cf2f5e0f610dd462b5d46ca62f12ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for par_yt2text-0.2.5-py3-none-any.whl:

Publisher: release-all.yml on paulrobello/par_yt2text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page