Spaces:
Running
Running
File size: 3,857 Bytes
cb39c05 cb27c1b cb39c05 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | """
Progress reporting and statistics display for CLI.
Uses Rich library for beautiful terminal output with progress bars,
tables, and formatted statistics.
"""
from typing import Dict, List
from rich import box
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
console = Console()
def display_header(title: str):
"""
Display a formatted header.
Args:
title: Header title
"""
console.print()
console.print(Panel.fit(f"[bold cyan]{title}[/bold cyan]", border_style="cyan"))
console.print()
def display_success(message: str):
"""
Display a success message.
Args:
message: Success message
"""
console.print(f"[green]β[/green] {message}")
def display_warning(message: str):
"""
Display a warning message.
Args:
message: Warning message
"""
console.print(f"[yellow]β [/yellow] {message}")
def display_error(message: str):
"""
Display an error message.
Args:
message: Error message
"""
console.print(f"[red]β[/red] {message}")
def display_info(message: str):
"""
Display an info message.
Args:
message: Info message
"""
console.print(f"[blue]βΉ[/blue] {message}")
def display_segment_details(segments: List[Dict]):
"""
Display extracted segment details in a table.
Args:
segments: List of segment dictionaries
"""
if not segments:
return
table = Table(title="Extracted Segments", box=box.ROUNDED)
table.add_column("#", style="cyan", no_wrap=True)
table.add_column("Start", style="white")
table.add_column("End", style="white")
table.add_column("Duration", style="white")
table.add_column("Type", style="green")
table.add_column("Confidence", style="yellow")
table.add_column("Quality", style="magenta")
for i, segment in enumerate(segments, 1):
segment_type = segment.get("segment_type", "unknown")
confidence = segment.get("confidence", 0)
snr = segment.get("snr")
# Format quality indicator
if snr is not None:
quality = "β" if snr >= 15 else "β"
else:
quality = "?"
table.add_row(
str(i),
f"{segment['start']:.2f}s",
f"{segment['end']:.2f}s",
f"{segment['duration']:.2f}s",
segment_type.value if hasattr(segment_type, "value") else str(segment_type),
f"{confidence:.2f}",
quality,
)
# Show first 20 segments, with note if more
if len(segments) > 20:
console.print(table)
console.print(f"[dim]Showing first 20 of {len(segments)} segments[/dim]")
else:
console.print(table)
console.print()
def display_quality_report(quality_metrics: Dict):
"""
Display quality metrics report.
Args:
quality_metrics: Quality metrics dictionary
"""
table = Table(title="Quality Metrics", box=box.ROUNDED, show_header=False)
table.add_column("Metric", style="cyan", no_wrap=True)
table.add_column("Value", style="white")
table.add_column("Status", style="green")
if "snr" in quality_metrics:
snr = quality_metrics["snr"]
status = "β Pass" if snr >= 15 else "β Fail"
table.add_row("SNR (Signal-to-Noise Ratio)", f"{snr:.2f} dB", status)
if "stoi" in quality_metrics:
stoi = quality_metrics["stoi"]
status = "β Pass" if stoi >= 0.70 else "β Fail"
table.add_row("STOI (Intelligibility)", f"{stoi:.2f}", status)
if "pesq" in quality_metrics:
pesq = quality_metrics["pesq"]
status = "β Pass" if pesq >= 2.0 else "β Fail"
table.add_row("PESQ (Perceptual Quality)", f"{pesq:.2f}", status)
console.print(table)
console.print()
|