Skip to content

Commit

Permalink
Few fixes
Browse files Browse the repository at this point in the history
- Fixed an issue related to a popping console window from audio-extract.
- Fixed a Few GUI glitches.
  • Loading branch information
aalramadan committed Jul 10, 2024
1 parent b807782 commit bdf9ab4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 71 deletions.
4 changes: 2 additions & 2 deletions compile/Inno_Setup_Script.iss
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Users\Ali\Desktop\TransVisio\main.dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ali\Desktop\TransVisio\main.dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\Ali\Desktop\TransVisio\dist\main\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Ali\Desktop\TransVisio\dist\main\_internal\*"; DestDir: "{app}\_internal"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Registry]
Expand Down
12 changes: 4 additions & 8 deletions compile/build.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
Build (Windows):
pyinstaller --windowed --hidden-import=tiktoken_ext.openai_public --hidden-import=tiktoken_ext --icon="C:\Users\Ali\Desktop\TransVisio\images\images\icon.ico" main.py
nuitka --standalone --windows-console-mode=disable --msvc=latest --enable-plugin=pyside6 --module-parameter=torch-disable-jit=no --module-parameter=numba-disable-jit=no --noinclude-numba-mode=nofollow --windows-icon-from-ico="C:\Users\Ali\Desktop\TransVisio\images\images\icon.ico" main.py
pyinstaller --noconsole --icon="C:\Users\Ali\Desktop\TransVisio\images\images\icon.ico" main.py

Build (Mac OS):
pyinstaller --onefile --windowed --hidden-import=tiktoken_ext.openai_public --hidden-import=tiktoken_ext --icon="/Users/Ali/Desktop/TransVisio/images/images/icon.icns" main.py
nuitka3 --standalone --windows-console-mode=disable --clang --macos-create-app-bundle --enable-plugin=pyside6 --module-parameter=torch-disable-jit=no --module-parameter=numba-disable-jit=no --noinclude-numba-mode=nofollow --macos-app-icon="/Users/Ali/Desktop/TransVisio/images/images/icon.icns" --windows-icon-from-ico="/Users/Ali/Desktop/TransVisio/images/images/icon.icns" main.py
pyinstaller --onefile --windowed --icon="/Users/Ali/Desktop/TransVisio/images/images/icon.icns" main.py

You might need to manually download ccache-4.2.1.zip and move it to:
/Users/ali/library/Caches/Nuitka/downloads/ccache/v4.2.1

* Use for debugging --> --console instead of --windowed
* Use for debugging:
--console instead of --windowed


6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ def __init__(self):
self.btn_save_transcription.clicked.connect(lambda: ui_functions.save_template_file(self, True))
self.btn_next.clicked.connect(lambda: ui_functions.check_inputs(self))
self.btn_start.clicked.connect(lambda: ui_functions.communicate_with_api(self))
self.btn_back.clicked.connect(lambda: ui_functions.button_click(self, self.btn_back))
self.btn_back.clicked.connect(lambda: ui_functions.button_click(self, self.btn_back))

self.btn_settings.clicked.connect(lambda: ui_functions.expand_settings(self))
self.btn_info.clicked.connect(lambda: ui_functions.expand_about(self))

self.data_table.itemSelectionChanged.connect(lambda: ui_functions.items_selected(self))
self.btn_delete_row.clicked.connect(lambda: ui_functions.delete_row(self))
self.btn_info.clicked.connect(lambda: ui_functions.expand_about(self))
self.btn_reverse.clicked.connect(lambda: ui_functions.change_text_direction(self))
self.chk_box_dark.clicked.connect(lambda: ui_functions.theme_switch(self, self.chk_box_dark))
self.chk_box_light.clicked.connect(lambda: ui_functions.theme_switch(self, self.chk_box_light))
Expand Down
10 changes: 5 additions & 5 deletions main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
<x>0</x>
<y>0</y>
<width>1024</width>
<height>728</height>
<height>734</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1024</width>
<height>728</height>
<height>734</height>
</size>
</property>
<property name="font">
Expand Down Expand Up @@ -511,9 +511,9 @@ QTextBrowser {
<property name="geometry">
<rect>
<x>0</x>
<y>-236</y>
<y>0</y>
<width>380</width>
<height>1056</height>
<height>1062</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
Expand Down
39 changes: 25 additions & 14 deletions ui_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PySide6.QtWidgets import (QMessageBox, QFileDialog, QTableWidgetItem,
QHeaderView,QAbstractItemView, QStyledItemDelegate, QTableWidgetItem)
from PySide6.QtCore import QSize, QEasingCurve, QPropertyAnimation, Qt, QFile, QTextStream
from PySide6.QtCore import QSize, QEasingCurve, QPropertyAnimation, Qt, QFile, QTextStream, QTimer
from PySide6.QtGui import QIcon, QMovie
from srt import parse as parse_srt, compose as compose_srt
from ass import parse as parse_ass
Expand All @@ -10,14 +10,12 @@
from audio_extract import extract_audio
from faster_whisper import WhisperModel
from datetime import timedelta
from torch import cuda
from pandas import ExcelFile, read_csv, DataFrame
from pandas import read_excel, read_csv, DataFrame
from json import loads, dumps
from re import findall
from google.generativeai import GenerativeModel, configure, types
from os import environ, remove
from uuid import uuid4

from torch import cuda

environ["KMP_DUPLICATE_LIB_OK"]="TRUE" # Needed to get faster-whisper to work

Expand Down Expand Up @@ -116,7 +114,7 @@ def switch_whisper_models(main_window):
main_window.api_key_whisper.setEnabled(True)
main_window.combo_model_size.setEnabled(False)

def animate_widget(main_window, widget, next_widget=None):
def animate_widget(main_window, widget, next_widget=None):
width = widget.width()
width_extended = SETTINGS.EXPAND_WIDTH if width == 0 else 0
main_window.animate_expand = QPropertyAnimation(widget, b"minimumWidth")
Expand All @@ -126,18 +124,31 @@ def animate_widget(main_window, widget, next_widget=None):
main_window.animate_expand.setEasingCurve(QEasingCurve.InOutQuart)
main_window.animate_expand.finished.connect(lambda: animate_widget(main_window, next_widget) if next_widget else None)
main_window.animate_expand.start()


def expand_settings(main_window):
main_window.btn_settings.setEnabled(False)
main_window.btn_info.setEnabled(False)
if main_window.AboutFrame.width() == SETTINGS.EXPAND_WIDTH:
animate_widget(main_window, main_window.AboutFrame, main_window.SettingsExpand)
QTimer.singleShot(2 * SETTINGS.TIME_ANIMATION, lambda: enable_buttons(main_window))
else:
animate_widget(main_window, main_window.SettingsExpand)
QTimer.singleShot(SETTINGS.TIME_ANIMATION, lambda: enable_buttons(main_window))

def expand_about(main_window):
main_window.btn_settings.setEnabled(False)
main_window.btn_info.setEnabled(False)
if main_window.SettingsExpand.width() == SETTINGS.EXPAND_WIDTH:
animate_widget(main_window, main_window.SettingsExpand, main_window.AboutFrame)
QTimer.singleShot(2 * SETTINGS.TIME_ANIMATION, lambda: enable_buttons(main_window))
else:
animate_widget(main_window, main_window.AboutFrame)
QTimer.singleShot(SETTINGS.TIME_ANIMATION, lambda: enable_buttons(main_window))

def enable_buttons(main_window):
main_window.btn_settings.setEnabled(True)
main_window.btn_info.setEnabled(True)


def issue_warning_error(main_window, title, text):
Expand All @@ -147,6 +158,7 @@ def issue_warning_error(main_window, title, text):
async def load_template_file(main_window):
loading_gif(main_window, 'start')
main_window.btn_next.setEnabled(False)
main_window.btn_save.setEnabled(False)
global template_loaded
global template_file
global template_file_format
Expand All @@ -168,13 +180,12 @@ async def load_template_file(main_window):
template_file = parse_ass(file)
template_file_format = 'ass-ssa'
elif selected_file.endswith('.xlsx'):
xl = ExcelFile(selected_file)
df = xl.parse(xl.sheet_names[0]) # Get first sheet only
template_file = df.iloc[:, 0].tolist() # Get all rows of the first column as a list
xl = read_excel(selected_file, sheet_name=0, header=None) # First sheet only
template_file = xl.iloc[:, 0].tolist() # Get all rows of the first column as a list
template_file_format = 'excel'
elif selected_file.endswith('.csv'):
df = read_csv(selected_file, header=None)
template_file = df.iloc[:, 0].tolist()
xl = read_csv(selected_file)
template_file = xl.iloc[:, 0].tolist()
template_file_format = 'excel'
else:
api_key_whisper = main_window.api_key_whisper.text().strip()
Expand Down Expand Up @@ -241,7 +252,7 @@ def save_template_file(main_window, transcriptions):
global template_file
options = QFileDialog.Options()

if template_file_format == 'ass-ssa' and not transcriptions:
if template_file_format == 'ass-ssa':
filter = "SubStation Alpha (*.ssa);;Advacned SubStation Alpha (*.ass)"
fileName, _ = QFileDialog.getSaveFileName(None,"Save File", "", filter, options=options)
if fileName:
Expand Down Expand Up @@ -291,7 +302,7 @@ def save_template_file(main_window, transcriptions):

def check_inputs(main_window):
global template_loaded
if not main_window.input.text() :
if not main_window.input.text():
issue_warning_error(main_window, "Warning", "Specify a template file")
else:
main_window.StackedWidget.setCurrentWidget(main_window.PostProcessing)
Expand Down Expand Up @@ -412,7 +423,7 @@ def create_sentences_dictionaries(main_window, input_size):
return sentences_list

def generate_prompt(main_window):
prompt = f"""The target language of translation is {main_window.target_language.currentText()}.
prompt = f"""The target language of translation is {main_window.target_language.currentText()}
The content genre is: {main_window.box_genre.currentText()}
The Target Demographic is: {main_window.box_demo.currentText()}
The Localization Approach is: {main_window.box_localization.currentText()}
Expand Down
Loading

0 comments on commit bdf9ab4

Please sign in to comment.