All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 0/2] [patch 0/2] speakup: Expose punctuation level to software speech synthesis
@ 2022-08-23 22:25 Samuel Thibault
  2022-08-23 22:25 ` [patch 1/2] speakup-dummy: Add support for PUNCT variable Samuel Thibault
  2022-08-23 22:25 ` [patch 2/2] speakup: Notify synthesizers of the punctuation level change Samuel Thibault
  0 siblings, 2 replies; 6+ messages in thread
From: Samuel Thibault @ 2022-08-23 22:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, speakup

Hello,

This update to speakup makes software speech better tune their
punctuation level according to the speakup situation.

Samuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch 1/2] speakup-dummy: Add support for PUNCT variable
  2022-08-23 22:25 [patch 0/2] [patch 0/2] speakup: Expose punctuation level to software speech synthesis Samuel Thibault
@ 2022-08-23 22:25 ` Samuel Thibault
  2022-09-01 14:59   ` Greg KH
  2022-08-23 22:25 ` [patch 2/2] speakup: Notify synthesizers of the punctuation level change Samuel Thibault
  1 sibling, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2022-08-23 22:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, speakup, Samuel Thibault

This allows to debug the update of the punctuation level.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux/drivers/accessibility/speakup/speakup_dummy.c
===================================================================
--- linux.orig/drivers/accessibility/speakup/speakup_dummy.c
+++ linux/drivers/accessibility/speakup/speakup_dummy.c
@@ -27,6 +27,7 @@ static struct var_t vars[] = {
 	{ INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } },
 	{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
 	{ TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
+	{ PUNCT, .u.n = {"PUNCT %d\n", 0, 0, 3, 0, 0, NULL } },
 	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
 	V_LAST_VAR
 };
@@ -42,6 +43,8 @@ static struct kobj_attribute pitch_attri
 	__ATTR(pitch, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute inflection_attribute =
 	__ATTR(inflection, 0644, spk_var_show, spk_var_store);
+static struct kobj_attribute punct_attribute =
+	__ATTR(punct, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute rate_attribute =
 	__ATTR(rate, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute tone_attribute =
@@ -69,6 +72,7 @@ static struct attribute *synth_attrs[] =
 	&caps_stop_attribute.attr,
 	&pitch_attribute.attr,
 	&inflection_attribute.attr,
+	&punct_attribute.attr,
 	&rate_attribute.attr,
 	&tone_attribute.attr,
 	&vol_attribute.attr,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch 2/2] speakup: Notify synthesizers of the punctuation level change
  2022-08-23 22:25 [patch 0/2] [patch 0/2] speakup: Expose punctuation level to software speech synthesis Samuel Thibault
  2022-08-23 22:25 ` [patch 1/2] speakup-dummy: Add support for PUNCT variable Samuel Thibault
@ 2022-08-23 22:25 ` Samuel Thibault
  1 sibling, 0 replies; 6+ messages in thread
From: Samuel Thibault @ 2022-08-23 22:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, speakup, Samuel Thibault

Even if speakup does the filtering itself, it does not filter out A_PUNC
characters (because these are needed e.g. for prosody), so we have to tell
synthesizers whether they should filter them out or not.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
 drivers/accessibility/speakup/speakup_soft.c |   26 ++++++++++++++++++++++++--
 drivers/accessibility/speakup/spk_types.h    |    2 +-
 drivers/accessibility/speakup/varhandlers.c  |   12 ++++++++----
 3 files changed, 33 insertions(+), 7 deletions(-)

--- a/drivers/accessibility/speakup/varhandlers.c
+++ b/drivers/accessibility/speakup/varhandlers.c
@@ -138,6 +138,7 @@ struct st_var_header *spk_get_var_header
 		return NULL;
 	return p_header;
 }
+EXPORT_SYMBOL_GPL(spk_get_var_header);
 
 struct st_var_header *spk_var_header_by_name(const char *name)
 {
@@ -221,15 +222,17 @@ int spk_set_num_var(int input, struct st
 		*p_val = val;
 	if (var->var_id == PUNC_LEVEL) {
 		spk_punc_mask = spk_punc_masks[val];
-		return 0;
 	}
 	if (var_data->u.n.multiplier != 0)
 		val *= var_data->u.n.multiplier;
 	val += var_data->u.n.offset;
-	if (var->var_id < FIRST_SYNTH_VAR || !synth)
+
+	if (!synth)
+		return 0;
+	if (synth->synth_adjust && synth->synth_adjust(synth, var))
+		return 0;
+	if (var->var_id < FIRST_SYNTH_VAR)
 		return 0;
-	if (synth->synth_adjust)
-		return synth->synth_adjust(var);
 
 	if (!var_data->u.n.synth_fmt)
 		return 0;
@@ -245,6 +248,7 @@ int spk_set_num_var(int input, struct st
 	synth_printf("%s", cp);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(spk_set_num_var);
 
 int spk_set_string_var(const char *page, struct st_var_header *var, int len)
 {
--- a/drivers/accessibility/speakup/speakup_soft.c
+++ b/drivers/accessibility/speakup/speakup_soft.c
@@ -26,6 +26,7 @@
 static int softsynth_probe(struct spk_synth *synth);
 static void softsynth_release(struct spk_synth *synth);
 static int softsynth_is_alive(struct spk_synth *synth);
+static int softsynth_adjust(struct spk_synth *synth, struct st_var_header *var);
 static unsigned char get_index(struct spk_synth *synth);
 
 static struct miscdevice synth_device, synthu_device;
@@ -41,7 +42,7 @@ static struct var_t vars[] = {
 	{ INFLECTION, .u.n = {"\x01%dr", 5, 0, 9, 0, 0, NULL } },
 	{ VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
 	{ TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },
-	{ PUNCT, .u.n = {"\x01%db", 0, 0, 2, 0, 0, NULL } },
+	{ PUNCT, .u.n = {"\x01%db", 0, 0, 3, 0, 0, NULL } },
 	{ VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },
 	{ FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },
 	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
@@ -133,7 +134,7 @@ static struct spk_synth synth_soft = {
 	.catch_up = NULL,
 	.flush = NULL,
 	.is_alive = softsynth_is_alive,
-	.synth_adjust = NULL,
+	.synth_adjust = softsynth_adjust,
 	.read_buff_add = NULL,
 	.get_index = get_index,
 	.indexing = {
@@ -426,6 +427,27 @@ static int softsynth_is_alive(struct spk
 	return 0;
 }
 
+static int softsynth_adjust(struct spk_synth *synth, struct st_var_header *var)
+{
+	struct st_var_header *punc_level_var;
+	struct var_t *var_data;
+
+	if (var->var_id != PUNC_LEVEL)
+		return 0;
+
+	/* We want to set the the speech synthesis punctuation level
+	 * accordingly, so it properly tunes speaking A_PUNC characters */
+	var_data = var->data;
+	if (!var_data)
+		return 0;
+	punc_level_var = spk_get_var_header(PUNCT);
+	if (!punc_level_var)
+		return 0;
+	spk_set_num_var(var_data->u.n.value, punc_level_var, E_SET);
+
+	return 1;
+}
+
 module_param_named(start, synth_soft.startup, short, 0444);
 
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
--- a/drivers/accessibility/speakup/spk_types.h
+++ b/drivers/accessibility/speakup/spk_types.h
@@ -195,7 +195,7 @@ struct spk_synth {
 	void (*catch_up)(struct spk_synth *synth);
 	void (*flush)(struct spk_synth *synth);
 	int (*is_alive)(struct spk_synth *synth);
-	int (*synth_adjust)(struct st_var_header *var);
+	int (*synth_adjust)(struct spk_synth *synth, struct st_var_header *var);
 	void (*read_buff_add)(u_char c);
 	unsigned char (*get_index)(struct spk_synth *synth);
 	struct synth_indexing indexing;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 1/2] speakup-dummy: Add support for PUNCT variable
  2022-08-23 22:25 ` [patch 1/2] speakup-dummy: Add support for PUNCT variable Samuel Thibault
@ 2022-09-01 14:59   ` Greg KH
  2022-09-01 16:10     ` Samuel Thibault
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2022-09-01 14:59 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: linux-kernel, speakup

On Wed, Aug 24, 2022 at 12:25:02AM +0200, Samuel Thibault wrote:
> This allows to debug the update of the punctuation level.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> Index: linux/drivers/accessibility/speakup/speakup_dummy.c
> ===================================================================
> --- linux.orig/drivers/accessibility/speakup/speakup_dummy.c
> +++ linux/drivers/accessibility/speakup/speakup_dummy.c
> @@ -27,6 +27,7 @@ static struct var_t vars[] = {
>  	{ INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } },
>  	{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
>  	{ TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
> +	{ PUNCT, .u.n = {"PUNCT %d\n", 0, 0, 3, 0, 0, NULL } },
>  	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
>  	V_LAST_VAR
>  };
> @@ -42,6 +43,8 @@ static struct kobj_attribute pitch_attri
>  	__ATTR(pitch, 0644, spk_var_show, spk_var_store);
>  static struct kobj_attribute inflection_attribute =
>  	__ATTR(inflection, 0644, spk_var_show, spk_var_store);
> +static struct kobj_attribute punct_attribute =
> +	__ATTR(punct, 0644, spk_var_show, spk_var_store);
>  static struct kobj_attribute rate_attribute =
>  	__ATTR(rate, 0644, spk_var_show, spk_var_store);
>  static struct kobj_attribute tone_attribute =
> @@ -69,6 +72,7 @@ static struct attribute *synth_attrs[] =
>  	&caps_stop_attribute.attr,
>  	&pitch_attribute.attr,
>  	&inflection_attribute.attr,
> +	&punct_attribute.attr,
>  	&rate_attribute.attr,
>  	&tone_attribute.attr,
>  	&vol_attribute.attr,
> 

Don't we also need a Documentation/ABI/ update for this new sysfs file?

Can you send that as a follow-on patch?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 1/2] speakup-dummy: Add support for PUNCT variable
  2022-09-01 14:59   ` Greg KH
@ 2022-09-01 16:10     ` Samuel Thibault
  2022-09-01 16:23       ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2022-09-01 16:10 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, speakup

Hello,

Greg KH, le jeu. 01 sept. 2022 16:59:28 +0200, a ecrit:
> On Wed, Aug 24, 2022 at 12:25:02AM +0200, Samuel Thibault wrote:
> > This allows to debug the update of the punctuation level.
> > 
> > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > 
> > Index: linux/drivers/accessibility/speakup/speakup_dummy.c
> > ===================================================================
> > --- linux.orig/drivers/accessibility/speakup/speakup_dummy.c
> > +++ linux/drivers/accessibility/speakup/speakup_dummy.c
> > @@ -27,6 +27,7 @@ static struct var_t vars[] = {
> >  	{ INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } },
> >  	{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
> >  	{ TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
> > +	{ PUNCT, .u.n = {"PUNCT %d\n", 0, 0, 3, 0, 0, NULL } },
> >  	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
> >  	V_LAST_VAR
> >  };
> > @@ -42,6 +43,8 @@ static struct kobj_attribute pitch_attri
> >  	__ATTR(pitch, 0644, spk_var_show, spk_var_store);
> >  static struct kobj_attribute inflection_attribute =
> >  	__ATTR(inflection, 0644, spk_var_show, spk_var_store);
> > +static struct kobj_attribute punct_attribute =
> > +	__ATTR(punct, 0644, spk_var_show, spk_var_store);
> >  static struct kobj_attribute rate_attribute =
> >  	__ATTR(rate, 0644, spk_var_show, spk_var_store);
> >  static struct kobj_attribute tone_attribute =
> > @@ -69,6 +72,7 @@ static struct attribute *synth_attrs[] =
> >  	&caps_stop_attribute.attr,
> >  	&pitch_attribute.attr,
> >  	&inflection_attribute.attr,
> > +	&punct_attribute.attr,
> >  	&rate_attribute.attr,
> >  	&tone_attribute.attr,
> >  	&vol_attribute.attr,
> > 
> 
> Don't we also need a Documentation/ABI/ update for this new sysfs file?

It is already there actually, because it's the same variables fo various
syntheses, and this is just adding the support for punct (already known
in other syntheses) to the dummy synthesis.

Samuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 1/2] speakup-dummy: Add support for PUNCT variable
  2022-09-01 16:10     ` Samuel Thibault
@ 2022-09-01 16:23       ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2022-09-01 16:23 UTC (permalink / raw)
  To: Samuel Thibault, linux-kernel, speakup

On Thu, Sep 01, 2022 at 06:10:25PM +0200, Samuel Thibault wrote:
> Hello,
> 
> Greg KH, le jeu. 01 sept. 2022 16:59:28 +0200, a ecrit:
> > On Wed, Aug 24, 2022 at 12:25:02AM +0200, Samuel Thibault wrote:
> > > This allows to debug the update of the punctuation level.
> > > 
> > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > 
> > > Index: linux/drivers/accessibility/speakup/speakup_dummy.c
> > > ===================================================================
> > > --- linux.orig/drivers/accessibility/speakup/speakup_dummy.c
> > > +++ linux/drivers/accessibility/speakup/speakup_dummy.c
> > > @@ -27,6 +27,7 @@ static struct var_t vars[] = {
> > >  	{ INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } },
> > >  	{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
> > >  	{ TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
> > > +	{ PUNCT, .u.n = {"PUNCT %d\n", 0, 0, 3, 0, 0, NULL } },
> > >  	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
> > >  	V_LAST_VAR
> > >  };
> > > @@ -42,6 +43,8 @@ static struct kobj_attribute pitch_attri
> > >  	__ATTR(pitch, 0644, spk_var_show, spk_var_store);
> > >  static struct kobj_attribute inflection_attribute =
> > >  	__ATTR(inflection, 0644, spk_var_show, spk_var_store);
> > > +static struct kobj_attribute punct_attribute =
> > > +	__ATTR(punct, 0644, spk_var_show, spk_var_store);
> > >  static struct kobj_attribute rate_attribute =
> > >  	__ATTR(rate, 0644, spk_var_show, spk_var_store);
> > >  static struct kobj_attribute tone_attribute =
> > > @@ -69,6 +72,7 @@ static struct attribute *synth_attrs[] =
> > >  	&caps_stop_attribute.attr,
> > >  	&pitch_attribute.attr,
> > >  	&inflection_attribute.attr,
> > > +	&punct_attribute.attr,
> > >  	&rate_attribute.attr,
> > >  	&tone_attribute.attr,
> > >  	&vol_attribute.attr,
> > > 
> > 
> > Don't we also need a Documentation/ABI/ update for this new sysfs file?
> 
> It is already there actually, because it's the same variables fo various
> syntheses, and this is just adding the support for punct (already known
> in other syntheses) to the dummy synthesis.

Ah, nevermind, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-01 16:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 22:25 [patch 0/2] [patch 0/2] speakup: Expose punctuation level to software speech synthesis Samuel Thibault
2022-08-23 22:25 ` [patch 1/2] speakup-dummy: Add support for PUNCT variable Samuel Thibault
2022-09-01 14:59   ` Greg KH
2022-09-01 16:10     ` Samuel Thibault
2022-09-01 16:23       ` Greg KH
2022-08-23 22:25 ` [patch 2/2] speakup: Notify synthesizers of the punctuation level change Samuel Thibault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.