kraanzu/smassh

๐Ÿ› 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:

  1. Enable the sound option
  2. Type some text
  3. See error

Expected behavior ๐Ÿค”
It should play the keypress sound

Screenshots ๐Ÿง
gif
A still image of the error (from the gif)
image

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.
image

File Tree

Python 3.10
Contains the sounds required
image

Python 3.9
Doesn't even have the termtyper directory
image

This line seems to be the problem

https://github.com/kraanzu/termtyper/blob/9da5010f8349bd8bf487b5b48042d769c8e79c17/src/termtyper/utils/parser.py#L26-L35

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

Manually changing the sounds_loc in my config raises another error ๐Ÿ˜ซ

image

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 :)