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.
Developed by Paul Elliot
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
.mp3file 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:
- Fork the repository
- Create a feature branch
- Make your changes
- Run the tests:
python -m unittest discover tests - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mantisai-0.1.18.tar.gz.
File metadata
- Download URL: mantisai-0.1.18.tar.gz
- Upload date:
- Size: 108.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e3e37c4b5ddce50533f1816d29dff3a7a938e9d0818e7bbd84aa8176777841
|
|
| MD5 |
2119a56c7e3834d604ff8d40face07e0
|
|
| BLAKE2b-256 |
586c69b7ffdaff6ffd61a8bdc62e4bd722eb1e52afc363c07049364459104139
|
File details
Details for the file mantisai-0.1.18-py3-none-any.whl.
File metadata
- Download URL: mantisai-0.1.18-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0ea4b4c0a86ce84c7590b57d0783d723cd5e6e7037d4574bfac81c471902580
|
|
| MD5 |
92ce5a7ab24c7cb686f5d711270706d0
|
|
| BLAKE2b-256 |
3415bb0d02b3adb2db69f11e08e8bb8199d23125245b6ee36f935b0eb6baab06
|