Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 24 Mar 2019, 07:42
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Enabling Puppy to speak in multiple languages - March 2019
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
ETP


Joined: 19 Oct 2010
Posts: 1146
Location: UK

PostPosted: Wed 13 Mar 2019, 04:33    Post subject:  Enabling Puppy to speak in multiple languages - March 2019
Subject description: (That's one small step for man, one giant leap for puppy-kind)
 

.
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.php?p=1017537#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.pet) attached in the second post here, includes 2 modified system scripts ( /usr/sbin/save2flash and /usr/sbin/bootflash )
The modified lines in those 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'..."


    /usr/lib/gtkdialog/box_ok "Bootflash" error "$(gettext 'No USB drive plugged in')" & trans -b -p $TTS_FROM: :$TTS_TO "No USB drive plugged in"


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 !)

When testing the menu item "BootFlash install Puppy to USB" make sure that you have no USB sticks, SD cards or USB drives plugged in or you will
not see or hear the error message. To test the other script just click on your desktop save icon.
EDIT: As from 15th March a Bionicpup64 8.0 update will replace the bootflash menu item as
there is a change over to using "StickPup-usb stick installer" but the bootflash script will remain.
In order to test, open a terminal type bootflash then press enter.

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 is reproduced below.
Code:

# 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

_________________
Regards ETP

Kennels

Last edited by ETP on Tue 19 Mar 2019, 11:22; edited 4 times in total
Back to top
View user's profile Send private message 
ETP


Joined: 19 Oct 2010
Posts: 1146
Location: UK

PostPosted: Wed 13 Mar 2019, 04:35    Post subject: Enabling Puppy to speak in multiple languages.
Subject description: pet
 

speechify.pet (v1)
speechify.pet
Description 
pet

 Download 
Filename  speechify.pet 
Filesize  7.27 KB 
Downloaded  11 Time(s) 

_________________
Regards ETP

Kennels
Back to top
View user's profile Send private message 
foxpup


Joined: 29 Jul 2016
Posts: 783
Location: europa near northsea

PostPosted: Wed 13 Mar 2019, 16:32    Post subject: dpup Stretch  

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 Very Happy . 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'. Smile

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!
Back to top
View user's profile Send private message 
ETP


Joined: 19 Oct 2010
Posts: 1146
Location: UK

PostPosted: Thu 14 Mar 2019, 12:10    Post subject: Enabling Puppy to speak in multiple languages.  

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"

Quote:
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:
#!/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:
#!/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

Kennels
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0390s ][ Queries: 13 (0.0034s) ][ GZIP on ]