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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speakup does not pass the punctuation level to the synthesis #8

Closed
gcasse opened this issue Aug 15, 2022 · 16 comments
Closed

Speakup does not pass the punctuation level to the synthesis #8

gcasse opened this issue Aug 15, 2022 · 16 comments

Comments

@gcasse
Copy link

gcasse commented Aug 15, 2022

The punctuation characters associated to A_PUNC in chartab are not replaced by a space (32) by Speakup even if the punctuation level = 0 (observed in kernel 5.16.11).

This can be mitigated by associating the relevant characters to PUNC instead.

For example, the simple quote character ' (39) is let unmodified by Speakup.
Once the following command lines are launched as root, the simple quote character is correctly:

  • replaced by a space character if punctuation level < 3
  • let unmodified if punctuation level = 3

CHARTAB=/sys/accessibility/speakup/i18n/chartab
grep A_PUNC $CHARTAB | while read line; do echo ${line%A_PUNC}PUNC > $CHARTAB; done

This has been checked under Slint using speechd-up and confirmed by another user (Debian 11, console based environment, csh).

@sthibaul
Copy link
Contributor

sthibaul commented Aug 15, 2022

Hello,

Well, yes, AFAIK speakup does not perform the punctuation filtering by itself, it always delegates it to the devices. In espeakup, for instance, when receiving the \x01%db command, it calls espeak_SetParameter(espeakPUNCTUATION) to delegate the setting to the eventual synthesis.

Samuel

@sthibaul
Copy link
Contributor

Mmmm, actually there is some punctuation-related processing called spk_punc_mask, the code doesn't really document how that's supposed to be interacting with the backend support for punctuation...

@sthibaul
Copy link
Contributor

But I believe to get the user-expected behavior, the backend should really interpret the \x01%db command to set the punctuation level inside the synthesis, that's what all speakup drivers do.

@sthibaul
Copy link
Contributor

replaced by a space character if punctuation level < 3

Thinking again how punctuation works, we definitely do not want this: AIUI, we have to pass this kind of character to the eventual synthesis, so that the synthesis knows which prosody etc. it should use. It's really up to the eventual synthesis to decide whether it should speak out e.g. exclamation point or not, and in both case it needs to receive the character, so that it takes it into account for the prosody, be it spoken out or not.

@gcasse
Copy link
Author

gcasse commented Aug 15, 2022

Hello,

I also agree but it is not what I observed using speechd-up (via /var/log/speechd-up.log, log level at 5).
Initially the b command is interpreted as 'punctuation all' and send the relevant command to speech-dispatcher.
Then whichever the pressed key (speakupkey + F9 or F10), no 'b' command is received by speechd-up, instead the punctuation characters appeared replaced by speakup itself.

Here is what was logged by speechd-up (after replacing A_PUNC by PUNC in chartab)
Conditions in the console:

  • user prompt: user1@slint:~$
  • test: lauch command line
    echo "'hello' ? ? "

*** Punctuation level set to 2, speakup appears to replace some punctuation character by space
[Mon Aug 15 05:30:32 2022] speechd: Main loop characters read = 12 : (punclevel 2 )
[Mon Aug 15 05:30:32 2022] speechd: text: |punclevel 2 12|
[Mon Aug 15 05:30:32 2022] speechd: [speaking]
[Mon Aug 15 05:30:32 2022] speechd: Text before recoding: |punclevel 2 |
[Mon Aug 15 05:30:32 2022] speechd: Recoded text: |punclevel 2 |
[Mon Aug 15 05:30:32 2022] speechd: Sending to speechd as text: |punclevel 2 |
[Mon Aug 15 05:30:32 2022] speechd: ---
[Mon Aug 15 05:30:34 2022] speechd: Main loop characters read = 1 : (^X)
[Mon Aug 15 05:30:34 2022] speechd: [stop]
[Mon Aug 15 05:30:34 2022] speechd: Main loop characters read = 15 : (user1@slint $ )
[Mon Aug 15 05:30:34 2022] speechd: text: |user1@slint $ 15|
[Mon Aug 15 05:30:34 2022] speechd: [speaking]
[Mon Aug 15 05:30:34 2022] speechd: Text before recoding: |user1@slint $ |
[Mon Aug 15 05:30:34 2022] speechd: Recoded text: |user1@slint $ |
[Mon Aug 15 05:30:34 2022] speechd: Sending to speechd as text: |user1@slint $ |
[Mon Aug 15 05:30:34 2022] speechd: ---
[Mon Aug 15 05:30:34 2022] speechd: Main loop characters read = 1 : (^X)
[Mon Aug 15 05:30:34 2022] speechd: [stop]
[Mon Aug 15 05:30:34 2022] speechd: Main loop characters read = 35 : (user1@slint $ echo hello )
[Mon Aug 15 05:30:34 2022] speechd: text: |user1@slint $ echo hello 35|
[Mon Aug 15 05:30:34 2022] speechd: [speaking]
[Mon Aug 15 05:30:34 2022] speechd: Text before recoding: |user1@slint $ echo hello |
[Mon Aug 15 05:30:34 2022] speechd: Recoded text: |user1@slint $ echo hello |
[Mon Aug 15 05:30:34 2022] speechd: Sending to speechd as text: |user1@slint $ echo hello |

*** Punctuation level set to 3, all the punctuation characters are read by speechd-up
[Mon Aug 15 05:30:41 2022] speechd: text: |punclevel 3 12|
[Mon Aug 15 05:30:41 2022] speechd: [speaking]
[Mon Aug 15 05:30:41 2022] speechd: Text before recoding: |punclevel 3 |
[Mon Aug 15 05:30:41 2022] speechd: Recoded text: |punclevel 3 |
[Mon Aug 15 05:30:41 2022] speechd: Sending to speechd as text: |punclevel 3 |
[Mon Aug 15 05:30:41 2022] speechd: ---
[Mon Aug 15 05:30:44 2022] speechd: Main loop characters read = 1 : (^X)
[Mon Aug 15 05:30:44 2022] speechd: [stop]
[Mon Aug 15 05:30:44 2022] speechd: Main loop characters read = 15 : (user1@slint:~$ )
[Mon Aug 15 05:30:44 2022] speechd: text: |user1@slint:~$ 15|
[Mon Aug 15 05:30:44 2022] speechd: [speaking]
[Mon Aug 15 05:30:44 2022] speechd: Text before recoding: |user1@slint:~$ |
[Mon Aug 15 05:30:44 2022] speechd: Recoded text: |user1@slint:~$ |
[Mon Aug 15 05:30:44 2022] speechd: Sending to speechd as text: |user1@slint:~$ |
[Mon Aug 15 05:30:44 2022] speechd: ---
[Mon Aug 15 05:30:44 2022] speechd: Main loop characters read = 1 : (^X)
[Mon Aug 15 05:30:44 2022] speechd: [stop]
[Mon Aug 15 05:30:44 2022] speechd: Main loop characters read = 35 : (user1@slint:~$ echo "'hello' ? ? " )
[Mon Aug 15 05:30:44 2022] speechd: text: |user1@slint:~$ echo &quot;&apos;hello&apos; ? ? &quot; 35|
[Mon Aug 15 05:30:44 2022] speechd: [speaking]
[Mon Aug 15 05:30:44 2022] speechd: Text before recoding: |user1@slint:~$ echo &quot;&apos;hello&apos; ? ? &quot; |
[Mon Aug 15 05:30:44 2022] speechd: Recoded text: |user1@slint:~$ echo &quot;&apos;hello&apos; ? ? &quot; |
[Mon Aug 15 05:30:44 2022] speechd: Sending to speechd as text: |user1@slint:~$ echo &quot;&apos;hello&apos; ? ? &quot; |

@sthibaul
Copy link
Contributor

I also agree but it is not what I observed using speechd-up

Oh, then that's a different story. AIUI it should really be receiving the b command, just like it receives pitch, rate, etc. commands.

@sthibaul sthibaul reopened this Aug 15, 2022
@sthibaul sthibaul changed the title Speakup does not filter the 'A_PUNC' punctuation characters Speakup does not pass the punctuation level to the synthesis Aug 15, 2022
@sthibaul
Copy link
Contributor

spk_set_num_var indeed does set spk_punc_mask and does not care about notifying the synth, that's odd.

@sthibaul
Copy link
Contributor

sthibaul commented Aug 15, 2022

It seems that the confusion is even deeper: speechd-up takes 0 as "all", while espeakup takes 0 as "none" (because it blindly casts it into espeak_PUNCT_TYPE)
It looks like nobody every took to actually ask "what do these value represent", precisely because speakup already does the processing and doesn't update the level.

@sthibaul
Copy link
Contributor

williamh/speechd-up#7

@sthibaul
Copy link
Contributor

@sthibaul
Copy link
Contributor

sthibaul commented Aug 19, 2022

Could you check that this patch ec64d7a fixes telling your speechd-up installation the punctuation level? (note that you need fix williamh/speechd-up#7 to have it properly plugged to speech-dispatcher)

@gcasse
Copy link
Author

gcasse commented Aug 20, 2022

Could you attach for quicker feedback the speechd-up.log file (debug level 5) corresponding to
echo "'hello' ? ? " at punctuation level 2 and then punctuation level 3 ?

@sthibaul
Copy link
Contributor

Here are the results at different punctuation levels:
log.txt

Note that I have applied the speechd-up fix, but compiled it against an old speech-dispatcher which didn't have the "most" level, thus why the "most"-then-"some" log.

@sthibaul
Copy link
Contributor

So as expected the question marks are always transmitted, so that the eventual synthesis behind speech-dispatcher can always perform the prosody. But with the punctuation level set with [0-3]b, it will know how much punctuation to pronounce.

@gcasse
Copy link
Author

gcasse commented Aug 23, 2022

Thank you, receiving the punctuation level is helpful.
Would it be possible to avoid these supplementary white spaces when level = 3?

echo "'hello' ? ? "
[...]
[Sun Aug 21 19:23:59 2022] speechd: Recoded text: |
&apos; hello &apos; ? ?

@sthibaul
Copy link
Contributor

I guess these are meant to make sure that synthesizers do separate out the punctuation to speak it. I however have no idea where in the speakup code that's getting introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants