Metadata-Version: 2.4
Name: tecjustica-transcribe
Version: 0.1.3
Summary: CLI para transcrição de audiências judiciais com WhisperX e diarização
Author: TecJustiça
License-Expression: MIT
Keywords: audiência,diarização,justiça,transcrição,whisperx
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Legal Industry
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Requires-Python: <3.14,>=3.10
Requires-Dist: click>=8.0
Requires-Dist: rich>=13.0
Requires-Dist: whisperx>=3.3.0
Description-Content-Type: text/markdown

# tecjustica-transcribe

CLI para transcrição de audiências judiciais com WhisperX e diarização de falantes.

Transcreve vídeos MP4 gerando texto com timestamps e identificação de quem está falando (Juiz, Promotor, Advogado, etc. — identificados como SPEAKER_00, SPEAKER_01...).

## Requisitos do Sistema

### Sistema Operacional

| SO | Suporte | Observações |
|----|---------|-------------|
| **Ubuntu/Debian (WSL2)** | ✅ Testado | Recomendado. Funciona no Windows via WSL2 |
| **Ubuntu/Debian nativo** | ✅ Compatível | Instalação direta |
| **Windows nativo** | ❌ Não suportado | Use WSL2 (veja abaixo) |
| **macOS** | ❌ Não suportado | Requer GPU NVIDIA (CUDA) |

> **Usuários Windows**: instale o [WSL2](https://learn.microsoft.com/pt-br/windows/wsl/install) com Ubuntu. O WSL2 acessa a GPU NVIDIA do Windows automaticamente.

### Hardware

| Componente | Mínimo | Recomendado |
|------------|--------|-------------|
| **GPU NVIDIA** | 6 GB VRAM (ex: RTX 3050) | 8 GB+ VRAM (ex: RTX 3060, RTX 4060) |
| **RAM** | 8 GB | 16 GB |
| **Disco** | 10 GB livres (modelos IA) | 15 GB+ |

> GPUs AMD e Intel **não são compatíveis**. É necessária uma GPU NVIDIA com suporte a CUDA.

### Software

| Dependência | Como instalar | Verificar |
|-------------|---------------|-----------|
| **Driver NVIDIA** | [nvidia.com/drivers](https://www.nvidia.com/drivers) ou Windows Update | `nvidia-smi` |
| **CUDA** | Instalado automaticamente com PyTorch | `python -c "import torch; print(torch.cuda.is_available())"` |
| **ffmpeg** | `sudo apt install ffmpeg` | `ffmpeg -version` |
| **Python 3.10–3.13** | `sudo apt install python3.12` | `python3 --version` |
| **uv** (recomendado) | `curl -LsSf https://astral.sh/uv/install.sh \| sh` | `uv --version` |

> O comando `tecjustica-transcribe init` verifica tudo isso automaticamente e mostra o que está faltando.

### Token HuggingFace (para identificar falantes)

A diarização (identificar quem está falando) usa o modelo [pyannote](https://huggingface.co/pyannote/speaker-diarization-community-1), que exige um token **gratuito** do HuggingFace:

1. Crie uma conta em https://huggingface.co
2. Aceite os termos do modelo em https://huggingface.co/pyannote/speaker-diarization-community-1
3. Gere um token (tipo "Read") em https://huggingface.co/settings/tokens

O comando `init` vai pedir esse token e salvá-lo automaticamente.

> **Sem o token**, você ainda pode transcrever usando `--sem-diarizacao` — a transcrição funciona normalmente, só não identifica os falantes.

## Instalação

```bash
uv tool install tecjustica-transcribe
```

Ou com pip:

```bash
pip install tecjustica-transcribe
```

## Primeiro Uso

```bash
# 1. Verificar requisitos e configurar token (só precisa rodar uma vez)
tecjustica-transcribe init
```

O `init` mostra um diagnóstico completo:

```
╭──────────────── TecJustiça Transcribe — Diagnóstico ─────────────────╮
│ Python            ✅ 3.12.3                                          │
│ Driver NVIDIA     ✅ 591.44                                          │
│ CUDA              ✅ 12.8                                            │
│ GPU               ✅ NVIDIA GeForce RTX 3050 6GB Laptop GPU (6.0 GB) │
│ ffmpeg            ✅ 6.1.1                                           │
│ Token HuggingFace ✅ hf_pcgK...                                      │
╰──────────────────────────────────────────────────────────────────────╯
```

## Transcrever

```bash
# Transcrever com identificação de falantes
tecjustica-transcribe transcrever audiencia.mp4

# Transcrever sem identificar falantes (não precisa de token)
tecjustica-transcribe transcrever audiencia.mp4 --sem-diarizacao

# Escolher pasta de saída (padrão: ./transcricoes/)
tecjustica-transcribe transcrever audiencia.mp4 --output ./minha-pasta
```

## Saída

O comando gera 3 arquivos na pasta `./transcricoes/`:

| Arquivo | Formato | Uso |
|---------|---------|-----|
| `audiencia.txt` | Texto puro com `[SPEAKER_00]` | Leitura e análise |
| `audiencia.srt` | Legendas com timestamps | Players de vídeo (VLC, etc.) |
| `audiencia.json` | Dados completos por palavra | Integração com outros sistemas |

## Solução de Problemas

| Problema | Solução |
|----------|---------|
| `nvidia-smi` não encontrado | Instale o driver NVIDIA: [nvidia.com/drivers](https://www.nvidia.com/drivers) |
| CUDA não disponível | Verifique se o driver NVIDIA é compatível com CUDA 12+ |
| Erro de memória (OOM) | Feche outros programas, especialmente navegadores |
| Token HuggingFace negado | Aceite os termos em [huggingface.co/pyannote/speaker-diarization-community-1](https://huggingface.co/pyannote/speaker-diarization-community-1) |
| ffmpeg não encontrado | `sudo apt install ffmpeg` |

## Guia Rápido: Windows com WSL2

```bash
# 1. Abrir PowerShell como Administrador e instalar WSL2
wsl --install

# 2. Dentro do Ubuntu (WSL2), instalar dependências
sudo apt update && sudo apt install ffmpeg python3.12

# 3. Instalar uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# 4. Instalar tecjustica-transcribe
uv tool install tecjustica-transcribe

# 5. Configurar e transcrever
tecjustica-transcribe init
tecjustica-transcribe transcrever /mnt/c/Users/SeuUsuario/Downloads/audiencia.mp4
```

> No WSL2, seus arquivos do Windows ficam em `/mnt/c/`. Ex: `C:\Users\marcos\Downloads\` → `/mnt/c/Users/marcos/Downloads/`
