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
423 stars 55 forks source link

[BUG] TCLError bad pad value "2.5": must be positive screen distance #60

Closed rdlmda closed 6 months ago

rdlmda commented 7 months ago

Log

$ speech-translate 
2023-12-16 10:28:02.097 | INFO    | setting.py:284 [MainThread] - Setting loaded
2023-12-16 10:28:04.206 | INFO    | main.py:2081 [MainThread] - App Version: 1.3.6
2023-12-16 10:28:04.208 | INFO    | main.py:2082 [MainThread] - OS: Linux 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 | CPU: x86_64
2023-12-16 10:28:04.255 | INFO    | main.py:2083 [MainThread] - GPU: NVIDIA GeForce 930MX | CUDA: Detected 1 GPU(s): NVIDIA GeForce 930MX
2023-12-16 10:28:04.255 | DEBUG   | main.py:2084 [MainThread] - Sys args: ['/home/user/.local/bin/speech-translate']
2023-12-16 10:28:04.255 | DEBUG   | main.py:2085 [MainThread] - Loading UI...
2023-12-16 10:28:04.371 | INFO    | main.py:207 [MainThread] - Tray created successfully
2023-12-16 10:28:04.592 | DEBUG   | main.py:259 [MainThread] - Available Theme to use: ['default', 'sun-valley-light', 'sun-valley-dark', 'clam', 'alt', 'classic']
2023-12-16 10:28:04.593 | DEBUG   | style.py:32 [MainThread] - Setting theme: sun-valley-light
2023-12-16 10:28:04.641 | DEBUG   | style.py:60 [MainThread] - Setting custom light theme style
2023-12-16 10:28:04.781 | ERROR   | device.py:426 [MainThread] - 'PyAudio' object has no attribute 'get_default_wasapi_loopback'
Traceback (most recent call last):

  File "/home/user/.local/bin/speech-translate", line 8, in <module>
    sys.exit(main())
    │   │    └ <function main at 0x7f7dd1ed5a20>
    │   └ <built-in function exit>
    └ <module 'sys' (built-in)>
  File "/home/user/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 2091, in main
    main_ui = MainWindow()
              └ <class 'speech_translate.ui.window.main.MainWindow'>
  File "/home/user/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 460, in __init__
    self.menu_speaker = self.input_device_menu("speaker")
    │                   │    └ <function MainWindow.input_device_menu at 0x7f7dd1ed4430>
    │                   └ <speech_translate.ui.window.main.MainWindow object at 0x7f7dd0b2fa60>
    └ <speech_translate.ui.window.main.MainWindow object at 0x7f7dd0b2fa60>
  File "/home/user/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 930, in input_device_menu
    success, default_host = get_default_dict[mode]()
                            │                └ 'speaker'
                            └ {'hostAPI': <function get_default_host_api at 0x7f7dd37057e0>, 'mic': <function get_default_input_device at 0x7f7dd37056c0>, ...
> File "/home/user/.local/lib/python3.10/site-packages/speech_translate/utils/audio/device.py", line 419, in get_default_output_device
    default_device = p.get_default_wasapi_loopback()  # type: ignore
                     └ <pyaudio.PyAudio object at 0x7f7dd0b42b30>

AttributeError: 'PyAudio' object has no attribute 'get_default_wasapi_loopback'
2023-12-16 10:28:04.783 | ERROR   | device.py:427 [MainThread] - Something went wrong while trying to get the default output device (speaker).
2023-12-16 10:28:04.811 | ERROR   | _logging.py:63 [MainThread] - Traceback (most recent call last):
2023-12-16 10:28:04.812 | ERROR   | _logging.py:63 [MainThread] - File "/home/user/.local/bin/speech-translate", line 8, in <module>
2023-12-16 10:28:04.812 | ERROR   | _logging.py:63 [MainThread] - sys.exit(main())
2023-12-16 10:28:04.812 | ERROR   | _logging.py:63 [MainThread] - File "/home/user/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 2091, in main
2023-12-16 10:28:04.813 | ERROR   | _logging.py:63 [MainThread] - main_ui = MainWindow()
2023-12-16 10:28:04.813 | ERROR   | _logging.py:63 [MainThread] - File "/home/user/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 494, in __init__
2023-12-16 10:28:04.813 | ERROR   | _logging.py:63 [MainThread] - self.cbtn_task_transcribe.pack(side="left", padx=5, pady=2.5, ipady=0)
2023-12-16 10:28:04.814 | ERROR   | _logging.py:63 [MainThread] - File "/usr/lib/python3.10/tkinter/__init__.py", line 2425, in pack_configure
2023-12-16 10:28:04.815 | ERROR   | _logging.py:63 [MainThread] - self.tk.call(
2023-12-16 10:28:04.815 | ERROR   | _logging.py:63 [MainThread] - _tkinter
2023-12-16 10:28:04.815 | ERROR   | _logging.py:63 [MainThread] - .
2023-12-16 10:28:04.816 | ERROR   | _logging.py:63 [MainThread] - TclError
2023-12-16 10:28:04.816 | ERROR   | _logging.py:63 [MainThread] - :
2023-12-16 10:28:04.816 | ERROR   | _logging.py:63 [MainThread] - bad pad value "2.5": must be positive screen distance

Desktop (please complete the following information):

OS: Linux Mint 21.2 x86_64 App Installation version: module App / Python version: Python 3.10.12

rdlmda commented 7 months ago

(sorry for opening so many bug reports!) 😭

rdlmda commented 7 months ago

(As a side note, I encountered this issue: https://stackoverflow.com/q/77235006 and had to remove matplotlib-3.8.0 via pip as I had python3-matplotlib 3.5.1-2build1 on my system... I hope that's unrelated here)

Dadangdut33 commented 7 months ago

(sorry for opening so many bug reports!)

np don't worry

AttributeError: 'PyAudio' object has no attribute 'get_default_wasapi_loopback'

Are you sure you are on the latest commit? because the previous commit 7652dd6e71d6ae52c23ef4c845d1aa68a5d7e95e should have fixed crashed by this bug

can you verify this by running pip install -U git+https://github.com/Dadangdut33/Speech-Translate.git --upgrade --force-reinstall --no-deps before starting the app again

rdlmda commented 7 months ago

Ran the command, it removed v1.3.6 and installed v1.3.7, the issue still persists.

pip install -U git+https://github.com/Dadangdut33/Speech-Translate.git --upgrade --force-reinstall --no-deps --verbose
Using pip 23.3.1 from /home/user/.local/lib/python3.10/site-packages/pip (python 3.10)
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/Dadangdut33/Speech-Translate.git
  Cloning https://github.com/Dadangdut33/Speech-Translate.git to /tmp/pip-req-build-r3pfs33o
  Running command git version
  git version 2.34.1
  Running command git clone --filter=blob:none https://github.com/Dadangdut33/Speech-Translate.git /tmp/pip-req-build-r3pfs33o

(...)

  Running command git rev-parse HEAD
  f3710c63b2fcd89741f604dd234350240927e1d6
  Resolved https://github.com/Dadangdut33/Speech-Translate.git to commit f3710c63b2fcd89741f604dd234350240927e1d6
  Running command git submodule update --init --recursive -q
  Running command git rev-parse HEAD
  f3710c63b2fcd89741f604dd234350240927e1d6
  Running command python setup.py egg_info

(...)

Successfully installed SpeechTranslate-1.3.7
rdlmda commented 7 months ago

If I'm reading the install log correctly, the commit is https://github.com/Dadangdut33/Speech-Translate/commit/f3710c63b2fcd89741f604dd234350240927e1d6 instead of https://github.com/Dadangdut33/Speech-Translate/commit/7652dd6e71d6ae52c23ef4c845d1aa68a5d7e95e, but the issue persists.

rdlmda commented 7 months ago
$ speech-translate 
2023-12-16 18:23:52.818 | INFO    | setting.py:289 [MainThread] - Setting loaded
2023-12-16 18:23:55.140 | INFO    | main.py:2082 [MainThread] - App Version: 1.3.7
2023-12-16 18:23:55.142 | INFO    | main.py:2083 [MainThread] - OS: Linux 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 | CPU: x86_64
2023-12-16 18:23:55.192 | INFO    | main.py:2084 [MainThread] - GPU: NVIDIA GeForce 930MX | CUDA: Detected 1 GPU(s): NVIDIA GeForce 930MX
2023-12-16 18:23:55.193 | DEBUG   | main.py:2085 [MainThread] - Sys args: ['/home/ruda/.local/bin/speech-translate']
2023-12-16 18:23:55.193 | DEBUG   | main.py:2086 [MainThread] - Loading UI...
2023-12-16 18:23:55.251 | INFO    | main.py:207 [MainThread] - Tray created successfully
2023-12-16 18:23:55.396 | DEBUG   | main.py:259 [MainThread] - Available Theme to use: ['default', 'sun-valley-light', 'sun-valley-dark', 'clam', 'alt', 'classic']
2023-12-16 18:23:55.396 | DEBUG   | style.py:32 [MainThread] - Setting theme: sun-valley-light
2023-12-16 18:23:55.434 | DEBUG   | style.py:60 [MainThread] - Setting custom light theme style
2023-12-16 18:23:55.533 | ERROR   | device.py:426 [MainThread] - 'PyAudio' object has no attribute 'get_default_wasapi_loopback'
Traceback (most recent call last):

  File "/home/ruda/.local/bin/speech-translate", line 8, in <module>
    sys.exit(main())
    │   │    └ <function main at 0x7f8e6250db40>
    │   └ <built-in function exit>
    └ <module 'sys' (built-in)>
  File "/home/ruda/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 2092, in main
    main_ui = MainWindow()
              └ <class 'speech_translate.ui.window.main.MainWindow'>
  File "/home/ruda/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 461, in __init__
    self.menu_speaker = self.input_device_menu("speaker")
    │                   │    └ <function MainWindow.input_device_menu at 0x7f8e6250c550>
    │                   └ <speech_translate.ui.window.main.MainWindow object at 0x7f8e61146260>
    └ <speech_translate.ui.window.main.MainWindow object at 0x7f8e61146260>
  File "/home/ruda/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 931, in input_device_menu
    success, default_host = get_default_dict[mode]()
                            │                └ 'speaker'
                            └ {'hostAPI': <function get_default_host_api at 0x7f8e63d317e0>, 'mic': <function get_default_input_device at 0x7f8e63d316c0>, ...
> File "/home/ruda/.local/lib/python3.10/site-packages/speech_translate/utils/audio/device.py", line 419, in get_default_output_device
    default_device = p.get_default_wasapi_loopback()  # type: ignore
                     └ <pyaudio.PyAudio object at 0x7f8e61165330>

AttributeError: 'PyAudio' object has no attribute 'get_default_wasapi_loopback'
2023-12-16 18:23:55.535 | ERROR   | device.py:427 [MainThread] - Something went wrong while trying to get the default output device (speaker).
2023-12-16 18:23:55.571 | ERROR   | _logging.py:63 [MainThread] - Traceback (most recent call last):
2023-12-16 18:23:55.571 | ERROR   | _logging.py:63 [MainThread] - File "/home/ruda/.local/bin/speech-translate", line 8, in <module>
2023-12-16 18:23:55.572 | ERROR   | _logging.py:63 [MainThread] - sys.exit(main())
2023-12-16 18:23:55.572 | ERROR   | _logging.py:63 [MainThread] - File "/home/ruda/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 2092, in main
2023-12-16 18:23:55.573 | ERROR   | _logging.py:63 [MainThread] - main_ui = MainWindow()
2023-12-16 18:23:55.587 | ERROR   | _logging.py:63 [MainThread] - File "/home/ruda/.local/lib/python3.10/site-packages/speech_translate/ui/window/main.py", line 495, in __init__
2023-12-16 18:23:55.589 | ERROR   | _logging.py:63 [MainThread] - self.cbtn_task_transcribe.pack(side="left", padx=5, pady=2.5, ipady=0)
2023-12-16 18:23:55.590 | ERROR   | _logging.py:63 [MainThread] - File "/usr/lib/python3.10/tkinter/__init__.py", line 2425, in pack_configure
2023-12-16 18:23:55.591 | ERROR   | _logging.py:63 [MainThread] - self.tk.call(
2023-12-16 18:23:55.591 | ERROR   | _logging.py:63 [MainThread] - _tkinter
2023-12-16 18:23:55.592 | ERROR   | _logging.py:63 [MainThread] - .
2023-12-16 18:23:55.592 | ERROR   | _logging.py:63 [MainThread] - TclError
2023-12-16 18:23:55.592 | ERROR   | _logging.py:63 [MainThread] - :
2023-12-16 18:23:55.592 | ERROR   | _logging.py:63 [MainThread] - bad pad value "2.5": must be positive screen distance
Dadangdut33 commented 7 months ago

If you are not on windows the log AttributeError: 'PyAudio' object has no attribute 'get_default_wasapi_loopback' should happen but it should not be causing any crash. It seems 2023-12-16 18:23:55.592 | ERROR | _logging.py:63 [MainThread] - bad pad value "2.5": must be positive screen distance is the problem?

that's weird it's not causing any crash on my end. I tried it on my ubuntu on wsl, i'll changed it to 3 and can you verify if it still cause any crash

Dadangdut33 commented 6 months ago

It should have been fixed now so, I'm gonna close this. Feel free to open it again if it turns out the bug is not fixed yet.

once again, thanks for reporting the bug