Dadangdut33 / Speech-Translate

A realtime speech transcription and translation application using Whisper OpenAI and free translation API. Interface made using Tkinter. Code written fully in Python.
MIT License
421 stars 55 forks source link

[BUG] Running on Apple silicon ends with an error #69

Open pimushkin opened 5 months ago

pimushkin commented 5 months ago

I have trouble running an application on my MacBook Air M1 (ARM). System info:

Python version: 3.11.7 macOS version: 14.3 (23D56) (Sonoma)

2024-02-07 15:47:24.901 | DEBUG   | setting.py:247 [MainThread] - Loading setting environment
2024-02-07 15:47:24.902 | DEBUG   | setting.py:254 [MainThread] - Loading setting file
2024-02-07 15:47:24.902 | INFO    | setting.py:279 [MainThread] - Setting loaded
2024-02-07 15:47:25.208 | INFO    | main.py:2152 [MainThread] - App Version: 1.3.10 - TIME: 2024-02-07 15:47:25
2024-02-07 15:47:25.214 | INFO    | main.py:2153 [MainThread] - OS: Darwin 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:27 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8103 | CPU: arm
2024-02-07 15:47:25.214 | DEBUG   | main.py:2154 [MainThread] - Sys args: ['/Users/username/Projects/Speech-Translate/Run.py']
2024-02-07 15:47:25.214 | DEBUG   | main.py:2155 [MainThread] - Loading UI...
2024-02-07 15:47:25.682 | INFO    | main.py:208 [MainThread] - Tray created successfully
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication macOSVersion]: unrecognized selector sent to instance 0x1536864c0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018a15c540 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x0000000189c4deb4 objc_exception_throw + 60
    2   CoreFoundation                      0x000000018a20e124 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x000000018a0c6764 ___forwarding___ + 1572
    4   CoreFoundation                      0x000000018a0c6080 _CF_forwarding_prep_0 + 96
    5   libtk8.6.dylib                      0x00000001174ffb14 GetRGBA + 48
    6   libtk8.6.dylib                      0x00000001174ff600 SetCGColorComponents + 144
    7   libtk8.6.dylib                      0x00000001174ff974 TkpGetColor + 344
    8   libtk8.6.dylib                      0x0000000117460d40 Tk_GetColor + 220
    9   libtk8.6.dylib                      0x0000000117454480 Tk_Get3DBorder + 204
    10  libtk8.6.dylib                      0x00000001174542b0 Tk_Alloc3DBorderFromObj + 144
    11  libtk8.6.dylib                      0x00000001174620cc DoObjConfig + 832
    12  libtk8.6.dylib                      0x0000000117461c88 Tk_InitOptions + 348
    13  libtk8.6.dylib                      0x0000000117461b84 Tk_InitOptions + 88
    14  libtk8.6.dylib                      0x0000000117489b10 CreateFrame + 1440
    15  libtk8.6.dylib                      0x0000000117489e08 TkListCreateFrame + 156
    16  libtk8.6.dylib                      0x0000000117482db8 Initialize + 1840
    17  _tkinter.cpython-311-darwin.so      0x0000000103e2a3bc Tcl_AppInit + 80
    18  _tkinter.cpython-311-darwin.so      0x0000000103e24914 Tkapp_New + 592
    19  _tkinter.cpython-311-darwin.so      0x0000000103e242fc _tkinter_create + 608
    20  Python                              0x0000000102c71cbc cfunction_vectorcall_FASTCALL + 80
    21  Python                              0x0000000102d04360 _PyEval_EvalFrameDefault + 41968
    22  Python                              0x0000000102d08b34 _PyEval_Vector + 116
    23  Python                              0x0000000102c266b4 _PyObject_FastCallDictTstate + 96
    24  Python                              0x0000000102c90618 slot_tp_init + 188
    25  Python                              0x0000000102c88ac4 type_call + 136
    26  Python                              0x0000000102c26408 _PyObject_MakeTpCall + 128
    27  Python                              0x0000000102d044b4 _PyEval_EvalFrameDefault + 42308
    28  Python                              0x0000000102d08b34 _PyEval_Vector + 116
    29  Python                              0x0000000102c266b4 _PyObject_FastCallDictTstate + 96
    30  Python                              0x0000000102c90618 slot_tp_init + 188
    31  Python                              0x0000000102c88ac4 type_call + 136
    32  Python                              0x0000000102c26408 _PyObject_MakeTpCall + 128
    33  Python                              0x0000000102d044b4 _PyEval_EvalFrameDefault + 42308
    34  Python                              0x0000000102cf932c PyEval_EvalCode + 168
    35  Python                              0x0000000102d4fcb8 run_eval_code_obj + 84
    36  Python                              0x0000000102d4fc1c run_mod + 112
    37  Python                              0x0000000102d4fa5c pyrun_file + 148
    38  Python                              0x0000000102d4f4ac _PyRun_SimpleFileObject + 268
    39  Python                              0x0000000102d4ee44 _PyRun_AnyFileObject + 216
    40  Python                              0x0000000102d6bb58 pymain_run_file_obj + 220
    41  Python                              0x0000000102d6b498 pymain_run_file + 72
    42  Python                              0x0000000102d6ad78 Py_RunMain + 704
    43  Python                              0x0000000102d6beb4 Py_BytesMain + 40
    44  dyld                                0x0000000189c890e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException

To make sure that tkinter is available on my laptop, I tried running the following code via the terminal: image

Segoe UI is not installed. Python is installed via homebrew. The application was launched according to the instructions for installation via Git (CPU only).

I tried changing the 8th line in main.py by adding root = Tk() at the end after importing Tk as follows: from tkinter import Canvas, Frame, Menu, StringVar, Tk, Toplevel, filedialog, ttk; root = Tk()

After making this change, the error stopped occurring, but then the following error occurred, preventing the application from running:

2024-02-07 16:14:24.491 | DEBUG   | setting.py:247 [MainThread] - Loading setting environment
2024-02-07 16:14:24.491 | DEBUG   | setting.py:254 [MainThread] - Loading setting file
2024-02-07 16:14:24.492 | INFO    | setting.py:279 [MainThread] - Setting loaded
2024-02-07 16:14:24.649 | INFO    | main.py:2152 [MainThread] - App Version: 1.3.10 - TIME: 2024-02-07 16:14:24
2024-02-07 16:14:24.656 | INFO    | main.py:2153 [MainThread] - OS: Darwin 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:27 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8103 | CPU: arm
2024-02-07 16:14:24.656 | DEBUG   | main.py:2154 [MainThread] - Sys args: ['/Users/username/Projects/Speech-Translate/Run.py']
2024-02-07 16:14:24.656 | DEBUG   | main.py:2155 [MainThread] - Loading UI...
2024-02-07 16:14:24.699 | INFO    | main.py:208 [MainThread] - Tray created successfully
2024-02-07 16:14:25.131 | ERROR   | _logging.py:63 [MainThread] - Traceback (most recent call last):
2024-02-07 16:14:25.131 | ERROR   | _logging.py:63 [MainThread] -   File "/Users/username/Projects/Speech-Translate/Run.py", line 4, in <module>
2024-02-07 16:14:25.131 | ERROR   | _logging.py:63 [MainThread] - main()
2024-02-07 16:14:25.131 | ERROR   | _logging.py:63 [MainThread] -   File "/Users/username/Projects/Speech-Translate/speech_translate/ui/window/main.py", line 2162, in main
2024-02-07 16:14:25.132 | ERROR   | _logging.py:63 [MainThread] - main_ui = MainWindow()
2024-02-07 16:14:25.132 | ERROR   | _logging.py:63 [MainThread] -   File "/Users/username/Projects/Speech-Translate/speech_translate/ui/window/main.py", line 256, in __init__
2024-02-07 16:14:25.132 | ERROR   | _logging.py:63 [MainThread] - self.canvas_splash.create_image(0, 170, image=self.img_splash, anchor="w")
2024-02-07 16:14:25.132 | ERROR   | _logging.py:63 [MainThread] -   File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 2846, in create_image
2024-02-07 16:14:25.134 | ERROR   | _logging.py:63 [MainThread] - return self._create('image', args, kw)
2024-02-07 16:14:25.134 | ERROR   | _logging.py:63 [MainThread] -   File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 2832, in _create
2024-02-07 16:14:25.134 | ERROR   | _logging.py:63 [MainThread] - return self.tk.getint(self.tk.call(
2024-02-07 16:14:25.134 | ERROR   | _logging.py:63 [MainThread] - _tkinter
2024-02-07 16:14:25.134 | ERROR   | _logging.py:63 [MainThread] - .
2024-02-07 16:14:25.134 | ERROR   | _logging.py:63 [MainThread] - TclError
2024-02-07 16:14:25.135 | ERROR   | _logging.py:63 [MainThread] - :
2024-02-07 16:14:25.135 | ERROR   | _logging.py:63 [MainThread] - image "pyimage1" doesn't exist
Dadangdut33 commented 4 months ago

hmm i'm really not sure why it does not work and unfortunately i couldn't reproduce this (i don't have a macos environment system).

But rest assured, I wanted to rewrite the UI using PySide6 asap and it might fix this problem