Skip to content

Commit

Permalink
remove splash to fix bug #51
Browse files Browse the repository at this point in the history
- bump version
  • Loading branch information
Dadangdut33 committed Nov 9, 2023
1 parent 190c257 commit a7abdc6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 66 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Speech Translate aims to expand whisper ability by combining it with some transl
- [Installation](#installation)
- [From Prebuilt Binary](#from-prebuilt-binary)
- [As A Module](#as-a-module)
- [From Git](#from-git)
- [More Information](#more-information)
- [Building / Developing / Compiling Yourself](#building--developing--compiling-yourself)
- [Setup](#setup)
Expand Down Expand Up @@ -172,6 +173,10 @@ You can then run the program by typing `speech-translate` in your terminal/conso
- If you want to **install** from a **specific branch or commit**, you can do it by adding `@branch_name` or `@commit_hash` at the end of the url. Example: `pip install -U git+https://github.com/Dadangdut33/Speech-Translate.git@dev --extra-index-url https://download.pytorch.org/whl/cu118`
- The **--extra-index-url here might not always be up to date**, so you can check the latest version of pytorch [here](https://pytorch.org/get-started/locally/). You can also check the available version of pytorch [here](https://download.pytorch.org/whl/torch_stable.html). If the newest version is not compatible then please keep using the current url shown here.

## From Git

If you prefer cloning the app directly from git/github, you can follow the guide in [development](https://github.com/Dadangdut33/Speech-Translate/wiki/Development) instead. Doing it this way might also provide a more stable environment.

# More Information

Check out the [wiki](https://github.com/Dadangdut33/Speech-Translate/wiki) for more information about the app, user settings, how to use it, and more.
Expand All @@ -196,15 +201,19 @@ Check out the [wiki](https://github.com/Dadangdut33/Speech-Translate/wiki) for m
2. Activate your virtual environment by running `source venv/bin/activate`
3. Install all the dependencies needed by running `pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118` if you are using GPU or `pip install -r requirements.txt` if you are using CPU.
4. Make sure to have ffmpeg installed and added to your PATH
5. Get to root directory and Run the script by typing `python Main.py`
5. Get to root directory and Run the script by typing `python Run.py`

## Running the app

You can run the app by running the [`Run.py`](./Run.py) located in **root directory**. Alternatively you can also run it using `python -m speech_translate` in the **root directory**.

## Building

Before compiling the project, make sure you have installed all the dependencies and setup your pytorch correctly. Your pytorch version will control wether the app will use GPU or CPU (that's why it's recommended to make virtual environment for the project). The pre compiled version in this project is built using cx_freeze, i have provided the script in [build.py](./build.py). To compile it into an exe run `python build.py build` in the **root directory**. This will produce an executable file in the `build` directory. After that, use innosetup script to create an installer. You can use the provided [installer.iss](./installer.iss) to create an installer.
**Before compiling the project**, make sure you have installed all the dependencies and setup your pytorch correctly. Your pytorch version will control wether the app will use GPU or CPU (that's why it's recommended to make virtual environment for the project).

The pre compiled version in this project is built using cx_freeze, we have provided the script in [build.py](./build.py). This build script is only configured for windows build at the moment, but feel free to contribute if you know how to build properly for other OS.

To compile it into an exe run `python build.py build_exe` in the **root directory**. This will produce a folder containing the compiled project alongside an executable in the `build` directory. After that, use innosetup script to create an installer. You can use the provided [installer.iss](./installer.iss) to create the installer.

## Compatibility

Expand Down
2 changes: 1 addition & 1 deletion installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Speech Translate"
#define MyAppVersion "1.3.1"
#define MyAppVersion "1.3.2"
#define MyAppPublisher "Dadangdut33"
#define MyAppURL "https://github.com/Dadangdut33/Speech-Translate"
#define MyAppExeName "SpeechTranslate.exe"
Expand Down
2 changes: 1 addition & 1 deletion speech_translate/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.3.1"
__version__ = "1.3.2"
__setting_version__ = "1.3.0" # only updated on major changes
65 changes: 3 additions & 62 deletions speech_translate/ui/window/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
from signal import SIGINT, signal # Import the signal module to handle Ctrl+C
from threading import Thread
from time import strftime
from tkinter import Frame, Menu, StringVar, Tk, Toplevel, filedialog, ttk, Canvas
from tkinter import Frame, Menu, StringVar, Tk, Toplevel, filedialog, ttk
from typing import Dict, Literal

from loguru import logger
from PIL import Image, ImageDraw, ImageTk
from PIL import Image, ImageDraw
from pystray import Icon as icon
from pystray import Menu as menu
from pystray import MenuItem as item
from torch import cuda
from stable_whisper import WhisperResult

from speech_translate._constants import APP_NAME
from speech_translate._path import app_icon, splash_image
from speech_translate._path import app_icon
from speech_translate._version import __version__
from speech_translate.ui.custom.checkbutton import CustomCheckButton
from speech_translate.ui.custom.combobox import CategorizedComboBox, ComboboxWithKeyNav
Expand Down Expand Up @@ -120,60 +120,6 @@ def exit_app(self):
gc.running = False


class Splash(Toplevel):
def __init__(self, parent, geometry):
Toplevel.__init__(self, parent)
self.title("Splash")
self.geometry(geometry)
self.overrideredirect(True)
self.resizable(False, False)
self.lift()
self.attributes('-topmost', True)
self.after_idle(self.attributes, '-topmost', False)

self.x = 0
self.y = 0
self.bind("<Button-1>", self.start_move)
self.bind("<ButtonRelease-1>", self.stop_move)
self.bind("<B1-Motion>", self.on_motion)

# load image file
try:
self.image = Image.open(splash_image)
self.image = self.image.resize((640, 360))
except Exception:
logger.error("Splash image not found")
self.image = Image.new("RGB", (640, 360), "black")

# load image to canvas
self.canvas = Canvas(self, width=768, height=345, highlightthickness=0)
self.canvas.pack(pady=0, ipady=0)

self.imgtk = ImageTk.PhotoImage(self.image)
self.canvas.create_image(0, 170, anchor="w", image=self.imgtk)

self.loadbar = ttk.Progressbar(self, orient="horizontal", length=200, mode="indeterminate")
self.loadbar.pack(side="bottom", fill="x", pady=0, ipady=0)
self.loadbar.start(15)

## required to make window show before the program gets to the mainloop
self.update()

def start_move(self, event):
self.x = event.x_root - self.winfo_x()
self.y = event.y_root - self.winfo_y()

def stop_move(self, event):
self.x = None
self.y = None

def on_motion(self, event):
if self.x is not None and self.y is not None:
new_x = event.x_root - self.x
new_y = event.y_root - self.y
self.geometry("+%s+%s" % (new_x, new_y))


class MainWindow:
"""
Main window of the app
Expand Down Expand Up @@ -215,9 +161,6 @@ def __init__(self):

set_ui_style(sj.cache["theme"])

self.splash = Splash(self.root, f"640x360+{self.root.winfo_x() + 300}+{self.root.winfo_y() + 200}")
self.root.withdraw()

gc.wrench_emoji = emoji_img(16, " 🛠️")
gc.folder_emoji = emoji_img(13, " 📂")
gc.open_emoji = emoji_img(13, " ↗️")
Expand Down Expand Up @@ -594,8 +537,6 @@ def __init__(self):

# ------------------ on Start ------------------
bind_focus_recursively(self.root, self.root)
self.splash.destroy()
self.root.deiconify()
self.root.geometry(sj.cache["mw_size"])
self.root.lift()
self.root.attributes('-topmost', True)
Expand Down

0 comments on commit a7abdc6

Please sign in to comment.