#!/usr/bin/env python3
"""Offline USD budget estimate; no API calls. Rates are a 2026-10-21 snapshot."""
import argparse
from decimal import Decimal, InvalidOperation
RATES = {'openai/gpt-transcribe': Decimal('0.000075'),
         'elevenlabs/scribe_v2': Decimal('0.0000611111')}
def nonnegative(value):
    try:
        result = Decimal(value)
    except InvalidOperation:
        raise argparse.ArgumentTypeError('Use a finite non-negative number')
    if not result.is_finite() or result < 0:
        raise argparse.ArgumentTypeError('Use a finite non-negative number')
    return result
def estimate(hours, extra_hours, rate):
    return (hours + extra_hours) * Decimal(3600) * rate
if __name__ == '__main__':
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument('--hours', required=True, type=nonnegative, help='Original source-audio hours')
    p.add_argument('--extra-hours', default=Decimal(0), type=nonnegative, help='Assumed additional billable audio: duplicates, retries or overlap')
    p.add_argument('--rate-per-second', type=nonnegative, help='Override both snapshot rows with your verified USD/second rate')
    a = p.parse_args()
    rates = {'custom': a.rate_per_second} if a.rate_per_second is not None else RATES
    print('Budget only: no billing minimum, rounding, account discount, feature fee, tax, storage, summary or human review included.')
    for model, rate in rates.items():
        cost = estimate(a.hours, a.extra_hours, rate)
        print(f'{model}: {(a.hours+a.extra_hours):f} submitted hours, USD {cost:.8f} (approximately ${cost:.2f})')
