Skip to main content

vid2txt

A Python package for transcribing videos/audios to text using various speech-to-text services. Currently supports AssemblyAI for high-quality transcription.

Features

  • Download and transcribe from YouTube or any URL (via yt-dlp)
  • Extract audio from video files using FFmpeg
  • Direct support for audio formats (MP3, WAV, M4A, AAC, FLAC, OGG, WMA)
  • Transcribe audio using AssemblyAI API
  • Export transcripts in multiple formats:
    • Plain text (.txt)
    • SubRip subtitles (.srt)
    • Interactive HTML (.html) with embedded video/audio player
  • Language forcing support

Installation

pip install vid2txt

Install from source:

git clone https://github.com/ahmedsalim3/vid2txt.git
cd vid2txt
pip install -e .

Setup

Set your AssemblyAI API key as an environment variable:

export ASSEMBLYAI_API_KEY="your-api-key-here"

# On Windows (PowerShell):
$env:ASSEMBLYAI_API_KEY="your-api-key-here"

Get a free API key from: https://www.assemblyai.com/dashboard/signup

Usage

Command Line Interface

vid2txt MEDIA_PATH [OPTIONS]

Where MEDIA_PATH can be:

  • A local video file (.mp4, .mkv, .mov, ...)
  • A local audio file (.mp3, .wav, ...)
  • A YouTube or other URL

Options

  • -o, --output-dir: Output directory (default: same as input file)
  • -l, --language: Force transcription language (e.g., 'en', 'ar', 'es')
  • --model: Speech-to-text model to use (currently only 'assemblyai')
  • --force-audio-extract: Force re-extraction of audio from video files
  • --audio: Download audio only when using YouTube URLs (faster)

Examples

# Transcribe a local video file
vid2txt video.mp4

# Transcribe a local audio file
vid2txt podcast.mp3

# Transcribe from YouTube (downloads best video+audio)
vid2txt "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# Download and transcribe audio only (faster)
vid2txt "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --audio

# Specify output directory and language
vid2txt https://www.youtube.com/watch?v=dQw4w9WgXcQ -o ./output -l en

# Force re-extraction of audio even if cached
vid2txt video.mp4 --force-audio-extract

# Show help
vid2txt -h

Python API

from vid2txt import Transcriber
from pathlib import Path

media_path = Path("video.mp4") # or Path("audio.mp3"), or a URL
output_dir = Path("output") # Output directory
api_key = "your_api_key" # if using assemblyai


transcriber = Transcriber(
    output_dir=output_dir,
    language="en",
    model="assemblyai",
    api_key=api_key
)


segments = transcriber.transcribe(media_path=media_path)

# Save in different formats
transcriber.save_plain_text(
    segments=segments, 
    out_path=output_dir / Path("transcript.txt")
)
transcriber.save_srt(
    segments=segments,
    out_path=output_dir / Path("transcript.srt")
)
transcriber.save_html(
    segments=segments, 
    out_path=output_dir / Path("transcript.html"), 
    media_path=media_path
)

Contributing

Contributions are welcome, feel free to open an issue or submit a pull request

Here are a few ideas for future development:

TODO

  • Add support for additional speech-to-text models (e.g., OpenAI Whisper or other open-source models)
  • Extend the Summarizer to generate concise summaries of transcripts
  • Extend the Translator to support source → target language translation

Metadata

Release files for vid2txt 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vid2txt 0.1.1
File Size Uploaded Provenance Actions
vid2txt-0.1.1.tar.gz 57.2 MB Without provenance Details for vid2txt-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vid2txt 0.1.1
File Interpreter ABI Platform Actions
vid2txt-0.1.1-py3-none-any.whl Python 3 none any Details for vid2txt-0.1.1-py3-none-any.whl

Total release size: 57.2 MB

Release files / vid2txt-0.1.1.tar.gz

Download URL vid2txt-0.1.1.tar.gz
Size 57.2 MB
Tags Source
SHA-256 checksum
How to use checksums
1d99558380ad9b0d27ac7c54a345da78382ffaa9ed08d84702b436b3fbe1d9de
BLAKE2b-256 checksum
How to use checksums
a20011305de4c069af05fc794579b417e63ed8cf70556f4e834470d3a60cd4c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / vid2txt-0.1.1-py3-none-any.whl

Download URL vid2txt-0.1.1-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffc8298ef58574dd2e9ff862746c241c212f9677f8d19eb944bdbbe5cb5c81bf
BLAKE2b-256 checksum
How to use checksums
98c0b778e039b200b4182e6939027d30f6255990087375d8a777400f2657d322
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for vid2txt 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page