Enabling Puppy to speak in multiple languages - March 2019

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Enabling Puppy to speak in multiple languages - March 2019

#1 Post by ETP »

.
Enabling Puppy to speak in multiple languages:

This post details a possible approach to adding spoken translated text to puppy system scripts
that contain gettext splash messages of various types.
I would envisage it being used just for important informational messages or warnings.

I posted here: http://murga-linux.com/puppy/viewtopic. ... 37#1017537

about a "Multilingual Spoken Startup Welcome Plus Internet Alarm" pet and once again google translate is
used here but this time in conjunction with global environment variables set by the file /etc/profile.d/tts

A small standard block of code needs to be added to any script where display & speech is required.

The proof of concept demo pet (speechify-V2.pet) attached in the second post here, includes a modified system script ( /usr/sbin/save2flash )
The modified lines in that are as follows with the added code in colour.
  • yaf-splash -bg orange -placement top -close never -text "$(gettext "Saving RAM to 'pup_save'...")" &
    YAFPID=$!
    trans -b -p $TTS_FROM: :$TTS_TO "Saving RAM to 'pup-save'..."
Failure of the additional block of code if translation fails for some reason such as a dropped internet connection, is silent and does not impact on the script.
Should music already be playing the spoken message is mixed in with it and is easily audible.

Installation:

1. I would recommend first installing the pet referenced in the link above as the speechify.pet in this thread also requires translate-shell_0.9.6.6-1 plus it's dependencies.
The 2 pets in combination also give a better impression of what this could lead to.

2. In "Default Applications Chooser" make sure that you have /usr/bin/mpv set as the default "Audio Player"

3. Install the speechify.pet and reboot ensuring that you save the session.

Testing and Testers:

This demo pet has only been tested with 666philb's Bionicpup64 8.0 CE but should work with any recent WoofCE Pup that has translate-shell in it's repositories.
In particular I would appreciate testing by members who normally operate in a language other than English. (en)

Provision is made in the /etc/profile.d/tts file for bilingual members such as musher0 who may be operating in either language to display messages
in one language but have them spoken in another language. (musher0 for example, may prefer them spoken in his native Latin !)

Please let me know if you can suggest other possible scripts that could benefit from having speech added and I will endeavour to do that and add them to the speechify.pet.

Finally:

A copy of the /etc/profile.d/tts file included in the pet is reproduced below.

Code: Select all

# This is /etc/profile.d/tts        ETP 9th March 2019
# Sets global environment variables for text to speech in addition to gettext message.
# NOTES:
# GETTEXT messages are currently in english but in addition to being displayed in your own language
# will also be spoken in your own language. Minor changes will need to be made to any scripts that can make effective use of this speech utility.
#
# Provision is also made to have the spoken language set to a language other than the displayed language.
# Assuming that you selected English when first setting up the Pup everything would be in English but by
# commenting out line 15 and uncommenting line 16 you can opt to specify, at the end of line 16, any other language
# just for the spoken messages. If you make any changes to this file you must save and reboot to give effect to those changes.
# 
#
# Line 13
export TTS_FROM=en
export TTS_TO=`echo $LANG | cut -d_ -f1`
# export TTS_TO=fr
Last edited by ETP on Mon 02 Sep 2019, 12:43, edited 7 times in total.
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Enabling Puppy to speak in multiple languages.

#2 Post by ETP »

speechify pets
Attachments
speechify-V2.pet
.. v2 pet released 28/08/19
(1.51 KiB) Downloaded 193 times
speechify.pet
.. v1 pet released 13/03/19
(7.27 KiB) Downloaded 324 times
Last edited by ETP on Wed 28 Aug 2019, 15:30, edited 2 times in total.
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

foxpup
Posts: 1132
Joined: Fri 29 Jul 2016, 21:08

dpup Stretch

#3 Post by foxpup »

Hello ETP

Just tested on dPup Stretch RC4 from radky and it works flawlessly!

I combine english with dutch (nl), btw, but I also tried other languages and combinations.
Nice game :D . I just exported TTS_TO in terminal to change language.

The text to be spoken should not contain '_' or such, because the lady also reads this as 'underscore'. :)

Is there something in Puppy that detects if the battery is low? That would be a good candidate.

Another fine addition to Puppy from ETP!

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Enabling Puppy to speak in multiple languages.

#4 Post by ETP »

Hi foxpup,

Thanks for testing with dpup Stretch.

For the purpose of the test I just duplicated the displayed gettext message and I had my doubts about leaving that underscore.
One can of course deviate from the displayed gettext message as long as the gist of the spoken message is the same.
I will keep it simple and in the next version of the pet will just have it say "Saving RAM"
Is there something in Puppy that detects if the battery is low? That would be a good candidate.
Agreed. There are a number of different battery monitors used some relying on scripts and others on binaries.
I may be wrong but I think they all finish up calling /usr/bin/lowbat
which currently reads as follows:

Code: Select all

#!/bin/sh
aplay /usr/share/audio/2barks.wav &
notify-send -u critical "LOW BATTERY!!!" &
sleep 15
aplay /usr/share/audio/2barks.wav
That can be modified as follows: (You may wish to try it)

Code: Select all

#!/bin/sh
aplay /usr/share/audio/2barks.wav &
notify-send -u critical "       LOW BATTERY !!!" &
sleep 3
trans -b -p $TTS_FROM: :$TTS_TO "Attention. Low battery"
sleep 10
aplay /usr/share/audio/2barks.wav
sleep 3
trans -b -p $TTS_FROM: :$TTS_TO "OK, so just ignore me. You will be sorry"
sleep 0.3
aplay /usr/share/audio/2barks.wav
Testing that from the cli with Bionicpup64 8.0 CE & overriding my normal TTS_TO=en
gave the following output. (The barks were retained for dramatic effect plus an extra one added)
  • root# export TTS_TO=fr
    root# lowbat
    Playing WAVE '/usr/share/audio/2barks.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
    Attention. Batterie faible
    Playing WAVE '/usr/share/audio/2barks.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
    OK, alors ignorez-moi. Tu le regretteras
    Playing WAVE '/usr/share/audio/2barks.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
    root#
General points:

The notify-send critical messages here need to be dismissed with a left click. If they are left on
screen they will after a couple of minutes display their elapsed time which is rather nice.

It would be possible to create further global environment variables containing stock phrases to be spoken such as
export LOWBAT=
export LOWMEM=
export LOWDISKSPACE=
export HIGHTEMP=

It is not a good idea to be overwriting system scripts like this as it should really be done in WoofCE but as this is
a POC I am taking a few liberties with old scripts that are unlikely to change.

Update 15th March 2019

@foxpup

Having now installed both dPup Stretch RC4 and Bionicpup64 8.0 to an old Netbook I have a better
grasp of the possibilities with regard to a spoken low battery alarm.

Radky's 32-bit Pup uses powerapplet_tray 2.6.2 which has no provision for alarms but is lightweight and does not require QT.

Phil's 64-bit Bionic uses the more sophisticated QBat 0.2.2 which provides various alarm options and does require QT which is present.
It could be pointed at the lowbat script but that is not set by default. If there is any demand I would prefer to offer an
optional lowbat2 script for that in a different location so either could be set. The contents would be as proposed above.
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Enabling Puppy to speak in multiple languages - March 2019

#5 Post by ETP »

Low Bat Alarm:

The attached pet provides an optional visual & multilingual spoken low battery alarm for QBat 0.2.2
QBat is present in Bionicpup64 8.0 CE.

It requires the speechify.pet described in the original post plus translate-shell_0.9.6.6-1 and it's dependencies.

Installation:

1. Install the pet

2. Right click the battery icon on the taskbar and mirror the settings in the attached screen-shot.
( For testing purposes rather than the sensible final value of 10% set it to 2% less than your
current value and carry on browsing for a couple of minutes so that it will trigger )

3. Restart X
Attachments
QBat_multilingual_alarm-v1.pet
(611 Bytes) Downloaded 282 times
QBat_settings.png
(41.76 KiB) Downloaded 677 times
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Enabling Puppy to speak in multiple languages.

#6 Post by ETP »

A link to a brief video held on Google Photos showing the addition of speech.
The speech in Puppy will be in your native language if you have something other then English selected.
The video is in English.

https://tinyurl.com/y4r6z8ms
.
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Enabling Puppy to speak in multiple languages.

#7 Post by ETP »

.
Please note that a revised pet (speechify-V2.pet) has today been uploaded to the second post in this thread.
In contrast to the V1 pet it only contains one slightly modified example script and the original post in the
thread has been edited to reflect that.

If you have previously installed the V1 pet just use PPM to uninstall it before installing the V2 pet.
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

Post Reply