diff --git a/abogen/gui.py b/abogen/gui.py index b43ac07..a0ea427 100644 --- a/abogen/gui.py +++ b/abogen/gui.py @@ -1536,7 +1536,6 @@ class abogen(QWidget): QMessageBox.warning(self, "Duplicate Item", "This item is already in the queue.") return - print("Adding:", item_queue) self.enqueue(item_queue) # Clear input after adding to queue self.input_box.clear_input() @@ -1758,6 +1757,48 @@ class abogen(QWidget): Thread(target=gpu_and_load, daemon=True).start() + def show_queue_summary(self): + """Show a styled, resizable summary dialog after queue finishes.""" + if not self.queued_items: + return + + # Build HTML summary for better styling + summary_html = "" + for idx, item in enumerate(self.queued_items, 1): + status = "Completed" + output = getattr(item, "output_path", None) + if not output: + output = "Unknown" + summary_html += ( + f"{idx}) {os.path.basename(item.file_name)}
" + f"Language: {item.lang_code}
" + f"Voice: {item.voice}
" + f"Output: {output}
" + f"Status: {status}" + f"

" + ) + summary_html += "" + + dialog = QDialog(self) + dialog.setWindowTitle("Queue Summary") + dialog.resize(600, 500) # Make window resizable and larger + + layout = QVBoxLayout(dialog) + text_edit = QTextEdit(dialog) + text_edit.setReadOnly(True) + text_edit.setHtml(summary_html) + layout.addWidget(text_edit) + + close_btn = QPushButton("Close", dialog) + close_btn.setFixedHeight(36) + close_btn.clicked.connect(dialog.accept) + layout.addWidget(close_btn) + + dialog.setLayout(layout) + dialog.setMinimumSize(400, 300) + dialog.setSizeGripEnabled(True) # Allow resizing + dialog.exec_() + def on_conversion_finished(self, message, output_path): prevent_sleep_end() if message == "Cancelled": @@ -1786,6 +1827,10 @@ class abogen(QWidget): self.update_log(message) if output_path: self.last_output_path = output_path + # Store output_path in the current queued item if in queue mode + if self.queued_items and self.current_queue_index < len(self.queued_items): + self.queued_items[self.current_queue_index].output_path = output_path + self.etr_label.hide() # Hide ETR label self.progress_bar.setValue(100) self.progress_bar.hide() @@ -1808,7 +1853,7 @@ class abogen(QWidget): if self.open_file_btn: self.open_file_btn.setVisible(show_open_file_button) - # Only show finish_widget if queue is done --- + # Only show finish_widget if queue is done if self.current_queue_index + 1 >= len(self.queued_items) or not self.queued_items: # Queue finished, show finish screen self.controls_widget.hide() @@ -1816,6 +1861,9 @@ class abogen(QWidget): self.log_text.moveCursor(QTextCursor.End) self.log_text.ensureCursorVisible() save_config(self.config) + # Show queue summary if more than one item + if len(self.queued_items) > 1: + self.show_queue_summary() else: # More items in queue: clear log and reload for next item self.log_text.clear() diff --git a/abogen/utils.py b/abogen/utils.py index 46f77b9..fc27734 100644 --- a/abogen/utils.py +++ b/abogen/utils.py @@ -217,14 +217,22 @@ def calculate_text_length(text): def get_gpu_acceleration(enabled): - from torch.cuda import is_available - - if not enabled: - return "CUDA GPU available but using CPU.", False - - if is_available(): - return "CUDA GPU available and enabled.", True - return "CUDA GPU is not available. Using CPU.", False + try: + import torch + from torch.cuda import is_available + if not enabled: + return "CUDA GPU available but using CPU.", False + if is_available(): + return "CUDA GPU available and enabled.", True + # Gather more diagnostic info if CUDA is not available + try: + cuda_devices = torch.cuda.device_count() + cuda_error = torch.cuda.get_device_name(0) if cuda_devices > 0 else "No devices found" + except Exception as e: + cuda_error = str(e) + return f"CUDA GPU is not available. Using CPU.\nDetails: {cuda_error}", False + except Exception as e: + return f"Error checking CUDA GPU: {e}", False def prevent_sleep_start():