Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Keypress sound not working #4

Closed
wasi-master opened this issue Apr 7, 2022 · 4 comments
Closed

馃悰 Keypress sound not working #4

wasi-master opened this issue Apr 7, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@wasi-master
Copy link

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

@wasi-master wasi-master added the bug Something isn't working label Apr 7, 2022
@wasi-master wasi-master changed the title [BUG] Keypress sound not working 馃悰 Keypress sound not working Apr 7, 2022
@wasi-master
Copy link
Author

Manually changing the sounds_loc in my config raises another error 馃槴

image

@kraanzu
Copy link
Owner

kraanzu commented Apr 7, 2022

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

@kraanzu
Copy link
Owner

kraanzu commented Apr 7, 2022

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

kraanzu added a commit that referenced this issue Apr 7, 2022
@wasi-master
Copy link
Author

Thanks for the quick fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants