Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress bar + info [Request] #25

Open
dxcore35 opened this issue Nov 15, 2024 · 0 comments
Open

Progress bar + info [Request] #25

dxcore35 opened this issue Nov 15, 2024 · 0 comments

Comments

@dxcore35
Copy link

Hello, it will be very nice to give it a progressbard: with current line where is the transcription to keep user entertained, and actualy see if something is going on

Template

15% [███████░░░░░░░░░░░░░░░░░░░░░] | [00:15:23] The quick brown fox jumps over the lazy dog

CHAPTERS:

00:01:45 | Chapter: Prologue
00:05:30 | Chapter: Chapter 1

Scripts

def display_progress(percentage: float, time_str: str, current_text: str, width: int = 50) -> None:
    """Display a self-updating progress bar with current sentence.
    
    :param percentage: Current progress percentage (0-100)
    :param time_str: Current time position in format HH:MM:SS
    :param current_text: Current text being processed
    :param width: Width of the progress bar in characters
    """
    import shutil
    terminal_width = shutil.get_terminal_size().columns
    
    # Calculate progress bar
    filled = int(width * percentage / 100)
    bar = '█' * filled + '░' * (width - filled)
    
    # Create output string
    output = f'\r{percentage:>3.0f}% [{bar}] | [{time_str}] {current_text}'
    
    # Clear the line and print new content
    print(f'\r{" " * terminal_width}', end='', flush=True)
    print(output[:terminal_width], end='', flush=True)

def display_chapters() -> callable:
    """Create a function to handle chapter display in terminal.
    
    :return: Function to add chapters to display
    """
    _chapters = []
    _header_printed = False
    
    def add_chapter(time: str, chapter: str) -> None:
        """Add a new chapter to the display.
        
        :param time: Chapter start time in format HH:MM:SS
        :param chapter: Chapter title/name
        """
        nonlocal _header_printed
        
        if not _header_printed:
            print("\nCHAPTERS:")
            print("-" * 14)
            _header_printed = True
            
        _chapters.append(f"{time} | Chapter: {chapter}")
        print(_chapters[-1])
    
    return add_chapter

@dxcore35 dxcore35 changed the title Progress bar + info Progress bar + info [Request] Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant