Re: [orca-list] Get voice settings from Orca
- From: Colomban Wendling <cwendling hypra fr>
- To: orca-list gnome org
- Subject: Re: [orca-list] Get voice settings from Orca
- Date: Tue, 13 Sep 2022 16:38:12 +0200
Hello,
Le 13/09/2022 à 01:44, Rastislav Kish via orca-list a écrit :
as for the Orca's configuration file, you can find it in:
~/.local/share/orca/user-settings.conf
It's a plain-text JSON file, so as long as you have parsing libraries,
it should be reasonable to work with.
Just note, that Orca supports profiles, so you need to take these in
account.
I had to do just what Artem seems to want to achieve once, and although
it's NOT an actual API and is not stable or anything, the simplest is
really to leverage Orca's own code to do the loading, because of the
profiles (which while not terribly complex are not trivial).
So what I ended up doing (while still using a manual fallback for
resilience, though I never actually needed it yet), is something like so:
from orca.backends import json_backend as orca_json_backend
settings =
orca_json_backend.Backend(os.path.expanduser('~/.local/share/orca'))
general_settings = settings.getGeneral()
# ...
voice = general_settings.get('voices', {}).get('default')
if voice:
# ...
If you don't want to use orca.backends.json_backend, you can load the
JSON manually from user-settings.conf and then carefully override
specific keys from settings['general'] with the values from the current
profiles. Basically, a profile's general settings is the main general
settings + profile settings on top.
Once the settings loaded, note that Orca's voice's rate, pitch and
volume are NOT in the same units as speech-dispatcher's. E.g.
spd_rate = int(2 * max(0, min(99, float(voice.get('rate', 50)))) - 98)
Here's the mapping so you don't have to pull your own hairs, mine were
enough (dig through Orca code if you like to, though):
spd_rate = int(2 * max(0, min(99, orca_rate)) - 98)
spd_pitch = int(20 * max(0, min(9, orca_pitch)) - 90)
spd_volume = int(15 * max(0, min(9, orca_volume)) - 35)
Personally, when coding applications, I tend to leave the speech
parameters to Speech dispatcher.
That's a good thing in theory I think, but the problem is that Orca is
not doing that, and Orca is the "main" spd user, so it's not surprising
others want to "sound like Orca". Ideally I guess Orca's settings would
move to spd itself so that's not something one has to worry about, but
that's not the world we live in today, and I'm not sure spd has the
granularity Orca needs (various settings for various "voice profiles" if
you will, like caps, spell, etc.)
Anyway, hope this helps :)
Colomban
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]