๐ Keypress sound not working
wasi-master opened this issue ยท 4 comments
Describe the bug ๐
When pressing a key, instead of a sound coming, it shows an error at the bottom of the screen
To Reproduce ๐ฃ
Steps to reproduce the behavior:
- Enable the sound option
- Type some text
- See error
Expected behavior ๐ค
It should play the keypress sound
Screenshots ๐ง
A still image of the error (from the gif)
Desktop (please complete the following information): ๐ค
- OS: Windows 11
- Version 22H2 (22581.200)
Additional context ๐
It seems like the file path being passed to playsound is from the python 3.9 directory instead of being in the python 3.10 one where I installed termtyper. I've uninstalled playsound and termtyper from python 3.9, I only have them in python 3.10 but this still occurs.
This line seems to be the problem
This assumes the pip command is always going to be from the python interpreter termtyper is installed in. In my case, I have the pip command set to python 3.9, so the rich location shown by pip show rich
is the one from that, for python 3.9 it would need to run py -3.10 -m pip show rich
, but why does it even need to run these commands? just to get the path where termtyper is installed? for that you can just use the following snippet:
import os.path
sounds = os.path.join(os.path.dirname(__file__), "sounds", "mech.wav")
This is what I use in my pypi-command-line
package and it works great.
I just realized that I can set sounds_loc
in my config but it should set the location automatically though
Sorry about the dirty hack!
I was not able to find a way, at the time of development, to properly save the wav files and fetch them later.
I will look into the code you provided
import os.path
sounds = os.path.join(os.path.dirname(__file__), "sounds", "mech.wav")
Will update you shortly :)
That works great !!!
Thank you so much @wasi-master for the insight! ๐ค
The lag for the first time startup is gone too :)
I am pushing the updates now...you can recheck <3
Thanks for the quick fix :)