Discussion:
[PATCHv2 2/2] speakup: Support spelling unicode characters
Samuel Thibault
2017-03-13 00:17:14 UTC
Permalink
This supports spelling unicode characters by just passing them to
the speech synthesis in direct mode.

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

Index: linux-4.10/drivers/staging/speakup/main.c
===================================================================
--- linux-4.10.orig/drivers/staging/speakup/main.c
+++ linux-4.10/drivers/staging/speakup/main.c
@@ -432,7 +432,7 @@ static void speak_char(u16 ch)
char *cp;
struct var_t *direct = spk_get_var(DIRECT);

- if (direct && direct->u.n.value) {
+ if (ch >= 0x100 || (direct && direct->u.n.value)) {
if (IS_CHAR(ch, B_CAP)) {
spk_pitch_shift++;
synth_printf("%s", spk_str_caps_start);
@@ -443,8 +443,6 @@ static void speak_char(u16 ch)
return;
}

- if (ch >= 0x100)
- return;
cp = spk_characters[ch];
if (cp == NULL) {
pr_info("speak_char: cp == NULL!\n");
@@ -712,17 +710,16 @@ static void spell_word(struct vc_data *v
char *cp1;
char *str_cap = spk_str_caps_stop;
char *last_cap = spk_str_caps_stop;
+ struct var_t *direct = spk_get_var(DIRECT);
u16 ch;

if (!get_word(vc))
return;
while ((ch = *cp)) {
- if (ch >= 0x100)
- /* FIXME */
- continue;
if (cp != buf)
synth_printf(" %s ", delay_str[spk_spell_delay]);
- if (IS_CHAR(ch, B_CAP)) {
+ /* FIXME: Non-latin1 considered as lower case */
+ if (ch < 0x100 && IS_CHAR(ch, B_CAP)) {
str_cap = spk_str_caps_start;
if (*spk_str_caps_stop)
spk_pitch_shift++;
@@ -734,18 +731,21 @@ static void spell_word(struct vc_data *v
synth_printf("%s", str_cap);
last_cap = str_cap;
}
- if (this_speakup_key == SPELL_PHONETIC &&
+ if (ch >= 0x100 || (direct && direct->u.n.value)) {
+ synth_putwc_s(ch);
+ } else if (this_speakup_key == SPELL_PHONETIC &&
ch <= 0x7f && isalpha(ch)) {
ch &= 0x1f;
cp1 = phonetic[--ch];
+ synth_printf("%s", cp1);
} else {
cp1 = spk_characters[ch];
if (*cp1 == '^') {
synth_printf("%s", spk_msg_get(MSG_CTRL));
cp1++;
}
+ synth_printf("%s", cp1);
}
- synth_printf("%s", cp1);
cp++;
}
if (str_cap != spk_str_caps_stop)
Samuel Thibault
2017-03-13 00:17:13 UTC
Permalink
9831013cbdbd3d06430a1db01d8c32d50c7d1c04 ('speakup: convert screen reading to
16bit characters') paved the way for handling unicode characters in speakup, but
for the review mode, it missed actually getting unicode characters from the VC. This fixes by just turning the use_unicode parameter to 1.

Signed-off-by: Samuel Thibault <***@ens-lyon.org>
Tested-by: Zahari Yurukov <***@gmail.com>

Index: linux-2.6/drivers/staging/speakup/main.c
===================================================================
--- linux-2.6.orig/drivers/staging/speakup/main.c
+++ linux-2.6/drivers/staging/speakup/main.c
@@ -483,7 +483,7 @@ static u16 get_char(struct vc_data *vc,
c |= 0x100;
}

- ch = inverse_translate(vc, c, 0);
+ ch = inverse_translate(vc, c, 1);
*attribs = (w & 0xff00) >> 8;
}
return ch;
Chris Brannon
2017-03-13 10:02:57 UTC
Permalink
Post by Samuel Thibault
9831013cbdbd3d06430a1db01d8c32d50c7d1c04 ('speakup: convert screen reading to
16bit characters') paved the way for handling unicode characters in speakup, but
for the review mode, it missed actually getting unicode characters from the VC. This fixes by just turning the use_unicode parameter to 1.
Reviewed-by: Chris Brannon <***@the-brannons.com>
Chris Brannon
2017-03-14 16:06:36 UTC
Permalink
Post by Samuel Thibault
This supports spelling unicode characters by just passing them to
the speech synthesis in direct mode.
Index: linux-4.10/drivers/staging/speakup/main.c
===================================================================
--- linux-4.10.orig/drivers/staging/speakup/main.c
+++ linux-4.10/drivers/staging/speakup/main.c
@@ -432,7 +432,7 @@ static void speak_char(u16 ch)
char *cp;
struct var_t *direct = spk_get_var(DIRECT);
- if (direct && direct->u.n.value) {
+ if (ch >= 0x100 || (direct && direct->u.n.value)) {
if (IS_CHAR(ch, B_CAP)) {
spk_pitch_shift++;
synth_printf("%s", spk_str_caps_start);
@@ -443,8 +443,6 @@ static void speak_char(u16 ch)
return;
}
This is going to misidentify some Unicode characters >= 0x100 as
capital. You probably want to add ch < 0x100 tests to the if(is_char
...) conditions, like you did in spell_word. Please resend with that
fix and you'll get my Reviewed-by line.

Regards,
-- Chris
Samuel Thibault
2017-03-14 19:57:03 UTC
Permalink
Post by Chris Brannon
This is going to misidentify some Unicode characters >= 0x100 as
capital. You probably want to add ch < 0x100 tests to the if
Indeed, I've submitted a correction, thanks!

Samuel
Chris Brannon
2017-03-14 20:12:03 UTC
Permalink
Post by Samuel Thibault
This supports spelling unicode characters by just passing them to
the speech synthesis in direct mode.
Reviewed-by: Chris Brannon <***@the-brannons.com>

Loading...