Switch transcription backend from Whisper to Mistral AI API

This commit is contained in:
Damien
2026-06-10 16:36:32 +02:00
parent bda2b516a4
commit ba63761c90
4 changed files with 374 additions and 507 deletions

View File

@@ -1,6 +1,6 @@
# Audio Summary with Local LLM
This tool is designed to provide a quick and concise summary of audio and video files. It supports summarizing content either from a local file or directly from YouTube. The tool uses Whisper for transcription and a local version of Llama3 (via Ollama) for generating summaries.
This tool is designed to provide a quick and concise summary of audio and video files. It supports summarizing content either from a local file or directly from YouTube. The tool uses Mistral AI API for transcription and a local version of Llama3 (via Ollama) for generating summaries.
> [!TIP]
> It is possible to change the model you wish to use.
@@ -10,7 +10,7 @@ This tool is designed to provide a quick and concise summary of audio and video
- **YouTube Integration**: Download and summarize content directly from YouTube.
- **Local File Support**: Summarize audio/video files available on your local disk.
- **Transcription**: Converts audio content to text using Whisper.
- **Transcription**: Converts audio content to text using Mistral AI API.
- **Summarization**: Generates a concise summary using Llama3 (Ollama).
- **Transcript Only Option**: Option to only transcribe the audio content without generating a summary.
- **Device Optimization**: Automatically uses the best available hardware (MPS for Mac, CUDA for NVIDIA GPUs, or CPU).
@@ -23,6 +23,8 @@ Before you start using this tool, you need to install the following dependencies
- [Ollama](https://ollama.com) for LLM model management
- `ffmpeg` (required for audio processing)
- [uv](https://docs.astral.sh/uv/getting-started/installation/) for package management
- Mistral AI API key (free tier available)
- Mistral AI API key (set as `MISTRAL_API_KEY` environment variable)
## Installation
@@ -39,6 +41,17 @@ uv sync
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
### Mistral API Setup
1. Sign up for a Mistral AI account and get your API key from the [Mistral AI platform](https://mistral.ai/)
2. Set your API key as an environment variable:
```bash
export MISTRAL_API_KEY="your-api-key-here"
```
Or add it to your `.bashrc` or `.zshrc` file for persistent use.
### LLM Requirement
[Download and install](https://ollama.com) Ollama to carry out LLM Management. More details about LLM models supported can be found on the Ollama [GitHub](https://github.com/ollama/ollama).
@@ -196,24 +209,21 @@ OLLAMA_MODEL = "llama3"
WHISPER_MODEL = "openai/whisper-large-v2"
```
#### Changing the Whisper Model
#### Changing the Mistral Transcription Model
To use a different Whisper model for transcription:
To use a different Mistral model for transcription:
1. Update the `WHISPER_MODEL` variable with one of these options:
- `"openai/whisper-tiny"` (fastest, least accurate)
- `"openai/whisper-base"` (faster, less accurate)
- `"openai/whisper-small"` (balanced)
- `"openai/whisper-medium"` (slower, more accurate)
- `"openai/whisper-large-v2"` (slowest, most accurate)
1. Update the `MISTRAL_MODEL` variable with one of the available Mistral audio models:
- `"voxtral-mini-latest"` (default, good balance)
- `"voxtral-small-latest"` (smaller, faster)
2. Example:
```python
WHISPER_MODEL = "openai/whisper-medium" # A good balance between speed and accuracy
MISTRAL_MODEL = "voxtral-small-latest" # Faster transcription
```
For CPU-only systems, using a smaller model like `whisper-base` is recommended for better performance.
The Mistral API handles all hardware acceleration automatically, so no device selection is needed.
#### Changing the LLM Model