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.
Key Features
- Audio Transcription: Convert audio files to text
- Text Summarization: Generate concise summaries of your audio content
- Information Extraction: Retrieve specific details from audio using custom prompts
- Structured Data: Extract information in typed, validated formats using Pydantic models
- YouTube Support: Automatically process YouTube URLs
- Pydantic Validation: Ensure robust input/output handling
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"))
Structured Data Extraction
Extract typed, validated data using Pydantic models:
from pydantic import BaseModel, Field
from typing import List
class MeetingAnalysis(BaseModel):
title: str = Field(..., description="Title of the meeting")
attendees: List[str] = Field(..., description="List of meeting participants")
action_items: List[str] = Field(..., description="Action items discussed")
key_decisions: List[str] = Field(..., description="Key decisions made")
duration: float = Field(..., description="Meeting duration in minutes")
# Extract structured data from audio
meeting = mantis.extract_structured("meeting.mp3", MeetingAnalysis)
print(f"Meeting: {meeting.title}")
print(f"Duration: {meeting.duration} minutes")
print("\nAction Items:")
for item in meeting.action_items:
print(f"- {item}")
YouTube Support
Process YouTube content with the same API:
# Transcribe a YouTube video
transcript = mantis.transcribe("https://www.youtube.com/watch?v=example")
# Extract structured data from YouTube
class VideoAnalysis(BaseModel):
title: str
main_points: List[str]
timestamps: dict[str, float]
sentiment: str
analysis = mantis.extract_structured(
"https://youtube.com/watch?v=example",
VideoAnalysis
)
Usage Notes
- Unified Interface: Whether you're passing a
.mp3file or a YouTube URL, the functions work the same way - 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
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.6.tar.gz.
File metadata
- Download URL: mantisai-0.1.6.tar.gz
- Upload date:
- Size: 70.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45eab63e4ba809ea7f273983f33c1820a6e0f0cacdf7bf52e5297d132a4974e6
|
|
| MD5 |
634bf22514c87c3932e6f24fa80a65ed
|
|
| BLAKE2b-256 |
e801a69c11cf709ca474dbb27675d3537d10eb84a2c9437d358a755dccc2fdeb
|
File details
Details for the file mantisai-0.1.6-py3-none-any.whl.
File metadata
- Download URL: mantisai-0.1.6-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc13e0374e8cf0f30ae109378aeea62df2d6d87fe14952083e20a30ef7bcc9b3
|
|
| MD5 |
3c932a4d4891ff08e900f0e02ab0749a
|
|
| BLAKE2b-256 |
197d330c85b9536e243e61054118605f0d73a8ec687e823c5b6f3808eed16dd2
|