Metadata-Version: 2.4
Name: meetdown
Version: 0.5.0
Summary: Generate Markdown meeting transcripts from speech-to-text JSON.
License-Expression: MIT
Requires-Dist: click>=8.3.3
Requires-Dist: httpx>=0.27.0
Requires-Dist: imageio-ffmpeg>=0.6.0
Requires-Dist: rich>=13.7.0
Requires-Dist: typer>=0.26.8
Requires-Dist: huggingface-hub>=1.0 ; extra == 'local'
Requires-Dist: numpy>=2.0 ; extra == 'local'
Requires-Dist: torch>=2.6 ; extra == 'local'
Requires-Dist: transformers>=5.24.1 ; extra == 'local'
Requires-Dist: notionit>=0.2.0 ; extra == 'notion'
Requires-Python: >=3.12
Provides-Extra: local
Provides-Extra: notion
Description-Content-Type: text/markdown

# meetdown

`meetdown` is a small Python CLI for turning meeting audio into a Markdown transcript.

The CLI sends a local audio or video file to a speech provider, normalizes the
response, and writes a `.md` file with the full text and speaker-by-speaker
transcript when the provider returns speaker information. When `--provider` is
omitted, meetdown uses `MEETDOWN_PROVIDER`, or the only provider with configured
credentials. Recordings longer than a provider's request limit are split
automatically, and each transcript gets a quick quality check for common
speech-recognition hallucinations.

## Install and run

Run it directly with `uvx`; cloning this repository is not required:

```powershell
uvx meetdown meeting.m4a -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key"
```

Recordings copied from a Mac or an iPhone often store Korean file names in a
decomposed Unicode form that looks the same but does not match a typed name.
meetdown finds such files anyway, and names the transcript after the name you
typed.

Use the optional Notion extra when you want meetdown to upload the saved
Markdown file to Notion:

```powershell
uvx "meetdown[notion]" transcribe meeting.m4a -o meeting.md --notion
```

For local development:

```powershell
uv run meetdown meeting.m4a -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key"
```

Set credentials with environment variables:

```powershell
$env:CLOVA_SPEECH_INVOKE_URL="https://your.invoke.url"
$env:CLOVA_SPEECH_SECRET_KEY="your-secret-key"
```

You can also pass them directly:

```powershell
uvx meetdown meeting.m4a -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key"
```

Run `meetdown` without arguments, or use `--help`, to see the command list
without transcribing anything. Use `quickstart` for examples and `defaults` for
the current provider auto-detection status. In interactive terminals, the
defaults view is color-coded by area; set `NO_COLOR=1` to keep plain text
output.

```powershell
uvx meetdown
uvx meetdown --help
uvx meetdown quickstart
uvx meetdown defaults
uvx meetdown transcribe --help
```

Recognition language defaults to `auto`, so meetdown does not force a single
language when audio contains a mix such as English and Korean. Pass
`--language ko-KR`, `--language en-US`, or another provider-supported language
when you want to bias recognition toward one language. CLOVA Speech requires a
concrete language, so meetdown sends `ko-KR` for CLOVA when `--language auto` is
used; aliases such as `ko` and `ko-kr` are normalized to `ko-KR`.

## Python API

Use the top-level package API when you want to call meetdown from Python instead
of shelling out to the CLI:

```python
from meetdown import render_markdown, transcribe_file, write_markdown

response = transcribe_file("meeting.m4a", provider="openai")
markdown = render_markdown(
    response,
    title="Weekly sync",
    source_path="meeting.m4a",
)
write_markdown("meeting.md", markdown)
```

Pass `provider="local", model="best"` to transcribe on this computer; the
response then carries the model and device details under `local_run`.
`transcribe_file` uses the same provider resolution rules as the CLI. For more
control, import `resolve_provider_config` and `transcribe_with_provider` from
`meetdown` and keep the provider config in your own application code.

## Notion upload

Notion upload is optional. Install or run meetdown with the `notion` extra, then
set the Notion destination in environment variables:

```powershell
$env:NOTION_TOKEN="secret_..."
$env:NOTION_PARENT_PAGE_ID="your-parent-page-id"
uvx "meetdown[notion]" transcribe meeting.m4a -o meeting.md --notion
```

When `--notion` is used, meetdown checks for the optional dependency,
`NOTION_TOKEN`, and a parent page ID before transcription starts. The Markdown
file is still written first; Notion upload runs only after the local file is
saved. When Notion returns a page URL, meetdown prints it after upload.

You can override the Notion page settings per run:

```powershell
uvx "meetdown[notion]" transcribe meeting.m4a -o meeting.md --notion --notion-parent-page-id "page-id" --notion-title "Weekly sync" --notion-duplicate-strategy timestamp
```

## Providers

If `--provider` is omitted, meetdown uses the provider named in
`MEETDOWN_PROVIDER`. Without it, meetdown picks a provider only when exactly one
provider-specific API key is configured. When several provider keys are present
and no default is set, meetdown stops and lists them instead of guessing:

```powershell
$env:MEETDOWN_PROVIDER="openai"   # clova, openai, or gemini
uvx meetdown meeting.m4a -o meeting.md
```

Pass `--provider` explicitly to override the default for one run, or when you
pass only a generic `--api-key` or `MEETDOWN_API_KEY`.

CLOVA Speech can be selected automatically when you provide a CLOVA Invoke URL
and key:

```powershell
uvx meetdown meeting.m4a -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key"
```

For CLOVA, `--api-url` is the CLOVA Speech Invoke URL from NAVER Cloud Platform.
You may pass either the base Invoke URL or a URL that already ends with
`/recognizer/upload`.

OpenAI and Gemini can be selected automatically from their provider-specific
environment variables. Use `--api-url` when you need to override the provider
endpoint or base URL:

```powershell
$env:OPENAI_API_KEY="your-openai-key"
uvx meetdown meeting.m4a -o meeting.md
uvx meetdown meeting.m4a -o meeting.md --provider openai --api-url "https://api.openai.com/v1"

$env:GEMINI_API_KEY="your-gemini-key"
uvx meetdown meeting.m4a -o meeting.md
```

Use `--model` to override the provider default model. CLOVA does not support
`--model`; the CLOVA Speech model is determined by the Invoke URL/domain.
OpenAI defaults to a diarization-capable transcription model when diarization is
enabled, and to a smaller transcription model when `--no-diarization` is used.
Gemini uses inline audio requests, so larger files are split automatically.

## Local models (no API key)

`--provider local` transcribes on your computer with open models, so the audio
never leaves it. It needs the optional `local` extra. On Windows and Linux,
`--torch-backend auto` makes uv install the CUDA build of PyTorch when an NVIDIA
GPU is present:

```powershell
uvx --torch-backend auto --from "meetdown[local]" meetdown meeting.m4a -o meeting.md --provider local
```

On a Mac with Apple Silicon, leave out `--torch-backend auto`:

```bash
uvx --from "meetdown[local]" meetdown meeting.m4a -o meeting.md --provider local
```

Pick a model by purpose with `--model`, so you never type a model name. Without
`--model`, `auto` picks one for the hardware:

| `--model` | Model | Download | Memory | 1 h of audio: GPU / 16-core CPU | vs CLOVA |
| --- | --- | --- | --- | --- | --- |
| `best` | Qwen3-ASR-1.7B | 4.1 GB | 6 GB GPU or 9 GB RAM | about 2 min / 27 min | 27% |
| `light` | Qwen3-ASR-0.6B | 1.6 GB | 3.7 GB GPU or 4 GB RAM | about 1 min / 16 min | 31% |
| `fast` | Nemotron 3.5 ASR 0.6B | 2.6 GB | 2.7 GB GPU or 3.4 GB RAM | under 1 min / 5 min | 40% |

"vs CLOVA" is the character difference from a CLOVA Speech transcript of a
30-minute Korean meeting; lower is closer, and CLOVA itself makes mistakes too.
GPU times were measured on an RTX 5070 Ti and CPU times on a 16-core Ryzen 9
9950X; a 4-core laptop takes about four times as long. `light` may write long
English passages in Korean, and `fast` skips some speech, so use it for drafts.
All three find speaker turns with Nemotron-3-Diarization (0.4 GB), which tells
apart up to 8 speakers.

`auto` picks:

- `best` on an NVIDIA GPU with at least 6 GB of memory, or on an Apple Silicon
  Mac with at least 16 GB of memory.
- `light` on smaller GPUs and Macs, and on computers without a supported GPU.
  Pass `--model best` there when accuracy matters more than time.
- `fast` on computers with less than 6 GB of memory.

meetdown prints the model it chose and why, and records the model ID, its
revision, the device, and timings in the Markdown processing options. To set a
default for one computer, such as a slower laptop, set `MEETDOWN_LOCAL_MODEL`:

```powershell
$env:MEETDOWN_LOCAL_MODEL="light"
```

Run `meetdown models` to compare the models on this computer: what `auto`
picks, the expected time per hour of audio, and which models are downloaded.
`meetdown models --json` prints the same information for scripts.

```powershell
uvx --torch-backend auto --from "meetdown[local]" meetdown models
```

Models download once into the Hugging Face cache at pinned revisions, and later
runs work offline. `--model` also accepts a Hugging Face model ID or a local
folder holding a Qwen3-ASR or Nemotron 3.5 ASR checkpoint in transformers
format, which is useful for trying a fine-tuned model.

Notes on local runs:

- When no API provider is configured and the `local` extra is installed,
  meetdown uses local models without `--provider local`. Set
  `MEETDOWN_PROVIDER=local` to prefer them even when API keys are configured.
- `--language` names the main language. Speech windows detected as another
  language, other than English, are transcribed again in the main language,
  which fixes short or mumbled windows written in the wrong script. With the
  default `auto`, the main language is the one spoken the most.
- `--start` and `--end` work as usual. `--chunk-duration` is not used, because
  local runs have no request limit.
- If meetdown warns that PyTorch has no CUDA support even though the computer
  has an NVIDIA GPU, run it with `--torch-backend auto` as shown above.
- `MEETDOWN_LOCAL_DEVICE` overrides the device: `cpu`, `cuda`, `cuda:1`, or `mps`.
- Apple Silicon Macs run the models on the GPU through PyTorch's MPS backend;
  their speed has not been measured yet. Intel Macs are not supported because
  current PyTorch releases no longer ship builds for them.
- Licenses: Qwen3-ASR is Apache-2.0, and the NVIDIA Nemotron models are under
  OpenMDW-1.1.

## Chunk long recordings

meetdown checks the selected media length before uploading. When it would come
within 10% of one request's limit, the recording is split automatically:

| Provider | Limit per request | Automatic chunk length |
| --- | --- | --- |
| OpenAI | 1400 s of audio (diarization models) and 25 MB | 10 minutes |
| Gemini | about 19 MB of inline audio | up to 20 minutes |
| CLOVA Speech | no client-side limit | not split |

If a provider still rejects the whole file as too long or too large, meetdown
retries once in 10-minute chunks. Pass `--chunk-duration` to choose the chunk
length yourself, or `--no-auto-chunk` to send the file as one request. Speaker
labels restart in each chunk, so the same label in two chunks may be two
different people.

The CLI extracts audio chunks with `ffmpeg`, sends each chunk to the selected provider,
shifts segment timestamps back to the original file timeline, and writes one Markdown file.
If your PC does not have system `ffmpeg`, meetdown falls back to the bundled
`imageio-ffmpeg` executable installed with the package. If system `ffprobe` is
missing, meetdown reads duration metadata through ffmpeg instead.

```powershell
uvx meetdown meeting.mp4 -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key" --chunk-duration 10m
```

Accepted duration forms include `600`, `600s`, `10m`, and `1h`. Uploads default
to `--compress smallest`, which extracts audio and uploads a 64 kbps MP3 copy.
Use `--compress lossless` for FLAC or `--compress none` to avoid compression.
When chunking or range extraction is used, `--compress none` creates WAV chunks:

```powershell
uvx meetdown meeting.mp4 -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key" --chunk-duration 10m --compress lossless
uvx meetdown meeting.mp4 -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key" --chunk-duration 10m --compress none
```

You can still force the exact temporary upload format with `--chunk-format mp3`,
`--chunk-format flac`, or `--chunk-format wav`.

You can transcribe only part of the source file. Timestamps in the Markdown stay
on the original media timeline:

```powershell
uvx meetdown meeting.mp4 -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key" --start 10m --end 45m
uvx meetdown meeting.mp4 -o meeting.md --api-url "https://your.invoke.url" --api-key "your-secret-key" --start 00:10:00 --end 00:45:00 --chunk-duration 10m
```

## Offline conversion

If you already have a CLOVA Speech JSON response, convert it without calling the API:

```powershell
uvx meetdown --from-json examples/clova_response.sample.json -o sample.md --title "Sample Meeting"
```

After an API-backed transcription, generated Markdown includes a `Processing options` section
with the provider, model, language, compression, chunking, range, timeout settings, estimated
API cost, and a replay command for the run. The CLI prints the same cost estimate. OpenAI estimates use
provider-reported token usage when available and otherwise use the published estimated
per-minute rate. Gemini estimates use provider-reported modality token usage for the standard
paid tier. Local runs report $0 because no API is called. CLOVA estimates include base speech recognition at 5 KRW per 15-second request unit;
speaker diarization and other optional feature charges are not included.

Rates are maintained as dated list prices, with the pricing date and source saved alongside the
estimate. Free-tier allowances, credits, taxes, and account-specific adjustments are excluded,
so the provider invoice can differ. Cost is reported as unavailable for unrecognized models,
custom OpenAI or Gemini endpoints, or responses without enough usage metadata. See the official
[OpenAI](https://developers.openai.com/api/docs/pricing),
[Gemini](https://ai.google.dev/gemini-api/docs/pricing), and
[CLOVA](https://www.ncloud.com/product/aiService/clovaSpeech) pricing pages for current rates.

API keys are never written, not even in masked form; the Markdown only records
whether a key was configured. Replay commands use `<...>` placeholders for secret
values; replace them before running the command.

## Quality check

Some speech models loop on a phrase, emit text faster than anyone can speak, or
translate speech into English instead of transcribing it. meetdown scores every
transcript for these patterns without extra API calls and writes the result to
the Markdown metadata, such as `Quality check: poor: 47% suspect; repetition 3`.
`ok` means nothing was flagged, `review` means isolated problems, and `poor`
means a large share of the text is suspect. The Latin-script check runs when
`--language` starts with `ko`. When a transcript is flagged, re-transcribe with
another provider or with `--no-diarization`, and re-transcribe key ranges with
`--start` and `--end` before relying on names, dates, or numbers.

## Automation

Pass `--json` to print one JSON object to stdout when the run ends. Progress
messages move to stderr, so scripts and agents can parse stdout directly:

```powershell
uvx meetdown meeting.m4a -o meeting.md --language ko-KR --json
```

The summary includes the provider and how it was chosen (`option`,
`environment`, `credentials`, or `installed` when local models were used because
no API provider is configured), the local model and device for local runs, the
media duration, chunking (`option`, `auto`,
or `retry`), segment counts, the cost estimate, the quality report, and warnings.
Failures print `{"status": "error", "code": ..., "message": ...}` and exit with
code 1. Codes include `provider_ambiguous` (with `candidates`),
`provider_not_configured`, `provider_invalid_default`,
`provider_credentials_missing`, `provider_dependency_missing` (the `local`
extra is not installed), `provider_limit`, `provider_error`,
`media_error`, `input_not_found`, `notion_error`, and `invalid_option`.

When a provider returns unnamed speakers, meetdown writes speaker placeholders
like `[[SPEAKER_1]]` and `[[SPEAKER_2]]`. These are intentionally easy to find
with Replace All and change to real names after you identify the speakers.

## Initial scope

This project intentionally starts small. It supports one local file, provider-backed
speech recognition, full text output, speaker-segment output, and Markdown file generation.
Summaries, decisions, action items, database storage, web UI, async callbacks, and batch
processing are later extensions.
