def format_duration(seconds):
    """
    Format a duration into a human-readable string.
    """
    mins, secs = divmod(seconds, 60)
    fmt = '{:.0f}'
    if mins:
        return '{} minutes {} seconds'.format(fmt, fmt).format(mins, secs)
    else:
        return '{} seconds'.format(fmt).format(secs)