brailcom / speechd

Common high-level interface to speech synthesis
GNU General Public License v2.0
219 stars 64 forks source link

Error when creating user config for the first time #747

Open genodeftest opened 2 years ago

genodeftest commented 2 years ago

Steps to reproduce

  1. Have a fresh installation of speech dispatcher or a fresh user account or delete your ~/.config/speech-dispatcher folder
  2. Run spd-conf as user with any configuration (default values are fine)

Obtained behavior

Instead of saving the file at the end, speech-dispatcher errors out:

$ spd-config
[…]
>
Default speech pitch range (on the scale of -100..100, 0 is default, 50 is higher, -50 is lower) [0] :
>
Traceback (most recent call last):
  File "/usr/bin/spd-conf", line 26, in <module>
    sys.exit(speechd_config.main())
  File "/usr/lib64/python3.10/site-packages/speechd_config/config.py", line 841, in main
    configure.complete_config()
  File "/usr/lib64/python3.10/site-packages/speechd_config/config.py", line 754, in complete_config
    self.configure_basic_settings(type='user')
  File "/usr/lib64/python3.10/site-packages/speechd_config/config.py", line 673, in configure_basic_settings
    self.options_substitute(configfile,
  File "/usr/lib64/python3.10/site-packages/speechd_config/config.py", line 549, in options_substitute
    for line in fileinput.input(configfile, inplace=True, backup=".bak"):
  File "/usr/lib64/python3.10/fileinput.py", line 256, in __next__
    line = self._readline()
  File "/usr/lib64/python3.10/fileinput.py", line 357, in _readline
    os.rename(self._filename, self._backupfilename)
FileNotFoundError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '/home/[username]/.config/speech-dispatcher/speechd.conf' -> '/home/[username]/.config/speech-dispatcher/speechd.conf.bak'

Expected behavior

Save file at end of following configuration wizard spd-conf.

Behavior information

(does not apply as this is not a bug in the speech-dispatcher daemon)

Distribution

Fedora 36

Version of Speech-dispatcher

speech-dispatcher-0.11.1-2.fc36.x86_64
speech-dispatcher-espeak-ng-0.11.1-2.fc36.x86_64
speech-dispatcher-utils-0.11.1-2.fc36.x86_64
speech-dispatcher-flite-0.11.1-2.fc36.x86_64

Additional notes

I think (but I am not 100% sure) that this issue is the same as #649 which hasn't been fixed completely. That fix has landed in the 0.11.1 release (which I'm running) as far as I understand from the git history of 0.11 branch.

I think, the actual cause of the traceback is different: The file ~/.config/speech-dispatcher/speechd.conf does not exist on a fresh installation or after deleting ~/.config/speech-dispatcher. When fileinput.input() is called on that code, the fileinput module relies on the existence of that file and tries to rename it using os.rename() (source code).

If I understand the issue correctly, there should be some code creating¹ that file if it does not exist yet. That code should probably be placed at the beginning of options_substitute before calling fileinput.input().


¹ or copying from the default config file. I don't know the code well enough to tell.

sthibaul commented 2 years ago

Please do not strip the output of spd-conf, you can never know what will be important in the output, notably you should be getting:


Speech Dispatcher configuration tool

Do you want to setup a completely new configuration? [yes] :
>
Do you want to create/setup a 'user' or 'system' configuration? [user] :
>
User configuration created in /home/samy/.config/speech-dispatcher

That last line is what puts the default configuration in $HOME/.config/speech-dispatcher, which I guess in your case fails for some reason. You could try to track what is happening in the create_user_configuration function.

tgrushka commented 1 month ago

More than 2 years later in 2024, spd-conf still does not work at all when an existing config does not exist.

This should be very, very easy to test:

  1. rm -rf ~/.config/speech-dispatcher
  2. spd-conf -n
  3. Fail.

My output:

tom@fedora ~> spd-conf -n

Speech Dispatcher configuration tool

Do you want to setup a completely new configuration? [yes] :
Do you want to create/setup a 'user' or 'system' configuration? [user] :
User configuration created in /home/tom/.config/speech-dispatcher
Configuring user settings for Speech Dispatcher
Default output module [espeak-ng] :
Default language (two/three-letter iso language code like "en" or "cs", possibly with a region qualification.) [en-US] :
Default audio output method [pulse] :
Default speech rate (on the scale of -100..100, 0 is default, 50 is faster, -50 is slower) [0] :
Default speech pitch (on the scale of -100..100, 0 is default, 50 is higher, -50 is lower) [0] :
Default speech pitch range (on the scale of -100..100, 0 is default, 50 is higher, -50 is lower) [0] :
Traceback (most recent call last):
  File "/usr/bin/spd-conf", line 26, in <module>
    sys.exit(speechd_config.main())
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/speechd_config/config.py", line 841, in main
    configure.complete_config()
  File "/usr/lib64/python3.12/site-packages/speechd_config/config.py", line 754, in complete_config
    self.configure_basic_settings(type='user')
  File "/usr/lib64/python3.12/site-packages/speechd_config/config.py", line 673, in configure_basic_settings
    self.options_substitute(configfile,
  File "/usr/lib64/python3.12/site-packages/speechd_config/config.py", line 549, in options_substitute
    for line in fileinput.input(configfile, inplace=True, backup=".bak"):
  File "/usr/lib64/python3.12/fileinput.py", line 251, in __next__
    line = self._readline()
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/fileinput.py", line 337, in _readline
    os.rename(self._filename, self._backupfilename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/tom/.config/speech-dispatcher/speechd.conf' -> '/home/tom/.config/speech-dispatcher/speechd.conf.bak'
sthibaul commented 1 month ago

@tgrushka :

More than 2 years later in 2024 [...] still does not work

contribution is very welcome to get things happen