Skip to main content

A Python package for transcribing audio files, summarizing text, and extracting information using Gemini AI and Pydantic.

Project description

Mantis: Audio Processing with Large Language Models

Mantis is a Python package that makes it easy to transcribe audio files, generate summaries, and extract information using large language models. Built with Pydantic for robust data validation, it provides a simple and user-friendly API for processing both local audio files and YouTube content.

PyPI version License

Key Features

  • Audio Transcription: Convert audio files to text with clean output
  • Text Summarization: Generate concise summaries of your audio content
  • Information Extraction: Retrieve specific details from audio using custom prompts
  • YouTube Support: Automatically process YouTube URLs with reliable caching
  • Pydantic Validation: Ensure robust input/output handling
  • Robust Error Handling: Comprehensive assertions and error checks throughout the codebase

Supported Formats

  • .mp3 - MP3 audio files
  • .wav - WAV audio files
  • .m4a - M4A audio files
  • .ogg - OGG audio files
  • YouTube URLs

Installation

Install Mantis with pip:

pip install mantisai

Quick Start

Basic Usage

import mantis

# Transcribe a local audio file
print(mantis.transcribe("path/to/local/audio.mp3"))

# Summarize a local audio file
print(mantis.summarize("path/to/local/audio.mp3"))

# Extract information using a custom prompt
print(mantis.extract("path/to/local/audio.mp3", "Extract key details"))

YouTube Support

Process YouTube content with the same API:

# Transcribe a YouTube video
transcript = mantis.transcribe("https://www.youtube.com/watch?v=example")

# Summarize a YouTube video
summary = mantis.summarize("https://www.youtube.com/watch?v=example")

# Extract information from a YouTube video
info = mantis.extract("https://www.youtube.com/watch?v=example", "Identify the key themes")

Command Line Interface

Mantis also provides a convenient CLI:

# Transcribe an audio file
python -m mantis.cli transcribe "path/to/audio.mp3"

# Summarize a YouTube video
python -m mantis.cli summarize "https://www.youtube.com/watch?v=example"

# Extract information with a custom prompt
python -m mantis.cli extract "path/to/audio.mp3" "Identify the key themes"

Usage Notes

  • Unified Interface: Whether you're passing a .mp3 file or a YouTube URL, the functions work the same way
  • Clean Transcriptions: By default, transcriptions remove disfluencies and speech artifacts
  • Custom Prompts: For extraction, you can provide custom prompts to guide the information retrieval
  • API Key: Ensure your Gemini AI API key is set in your environment (or in your code)
  • Default Model: Mantis uses Gemini 1.5 Flash by default
  • Silent Operation: Logging is disabled by default for clean output. Enable it only when needed for debugging.
# By default, logging is disabled for clean output

# Enable informational logging when needed
import mantis
mantis.enable_verbose_logging()

# Enable detailed debug logging for troubleshooting
mantis.enable_debug_logging()

# Enable only warnings and errors
mantis.enable_warning_logging()

Recent Improvements (v0.1.17)

  • Enhanced YouTube Processing: Fixed caching issues with YouTube downloads
  • Improved Robustness: Added comprehensive assertions throughout the codebase
  • Better Error Handling: More reliable cleanup of temporary files
  • Simplified Interface: Streamlined CLI with focus on core functionalities
  • Silent Operation: Disabled all logging by default for clean, results-only output

Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run the tests: python -m unittest discover tests
  5. Submit a pull request

For more details, see CONTRIBUTING.md

License

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

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

mantisai-0.1.17.tar.gz (97.4 kB view details)

Uploaded Source

Built Distribution

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

mantisai-0.1.17-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file mantisai-0.1.17.tar.gz.

File metadata

  • Download URL: mantisai-0.1.17.tar.gz
  • Upload date:
  • Size: 97.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for mantisai-0.1.17.tar.gz
Algorithm Hash digest
SHA256 b753ff22e09cebb8ed31bd8845165a69f6e12cb2cfc19e25a5b231ac420f7222
MD5 aa8b4684290c4388ccea695a54a5d090
BLAKE2b-256 2c367e8757822a957e6c99b4d205a543d325d6e5d973d28ff583750ac0b846ef

See more details on using hashes here.

File details

Details for the file mantisai-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: mantisai-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for mantisai-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 a1117bc270a0a03921123f6872a0c542829ca8abae3fa34c3142757cdf43ae83
MD5 2690c4c532788fb0eb8a4175b53de354
BLAKE2b-256 922f89c3bc7157b9bfd3be6d37b5110b5c9d70af89886b3fd2a6e1a49c427fc9

See more details on using hashes here.

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