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 Sat 29 Nov 2014, 02:31
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects
Talking Clock
Moderators: Flash, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 3 [32 Posts]   Goto page: 1, 2, 3 Next
Author Message
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sat 08 Oct 2011, 03:27    Post subject:  Talking Clock
Subject description: simple bash script talking clock
 

NEW VERSION 1.3.1

Latest SneekyLinux as kindly donated his voice for the clock, it was recorded at 44100 Hz 16bit so I have converted it to two sizes,
44000Hz 8bit and 8000 Hz 8bit to keep the file size to an acceptable amount.
I can barely tell the difference in the two files, then my HiFi is telephone quality these day's.

Well I have updated to version 1.3.1, this has a tidier looking GUI with hotkey's for all the function's, there is no wav files included with the package,
a voice package can be downloaded separately, I will say that this runs fine on my PC using Lucid 5.2.8, it should run on any puppy as it only relies on clock data and aplay,
if you already are using any of the other versions that being 1.1 or 1.2 then they will need to be completely removed to use this as the file structure is configured differently.

If for any reason the cron job gets removed, you will have to create a new one using "say_clock_time" as the command to be executed.
The next version I may add a button to add a new cron job, I also need to create some more voice's,
it's easy enough to do just need to emulate the wav file's stored in /root/.talking_clock/data/ and name them accordingly.
Anyway let me know if you find a problem, I'm sure it should be fine though.




I'll leave the version 1.1.
==============================================================================================================================================


I've been looking for talking clock and came across a few bash scripts that will do the job, also found some wav files that
I have edited and re-sampled into 8bit files, it doesn't sound to bad though the script could do with some work, as on the hour is say's the 0:0
I would prefer it to say just the hour with either AM or PM, I'll have to do some reading on script writing, anyway it may be of interest to some.
maybe some would like to make a puppy app with it, it is small less than 200k extracted.

Geoffrey

Edit:

I've put together a package for the taking clock using wav files, it is 204k installed, during the install it amends to /var/spool/cron/crontabs/root, so that it runs on the hour,
a small GUI is installed also, this can be found in the menu under system, look for " Say Time Config ", from this small GUI you can set different sound effects and preview them,
also selecting " Setup " will open Pschedule to allow the changing of the clock event timing, this is basic scripting nothing fancy, tried to keep it as simple as possible.

It will speak the time in the AM/PM format, at 12AM it will say " TWELVE MIDNIGHT " and at 12PM say " TWELVE NOON ", depending on the speed of the computer the effects may not work
as they should as they rely on running multiple instances of aplay to get the echo effect, I have not tried this on another PC, works fine on mine but saying that it is a
AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ Core 0: 2310 1: 2310 MHz with 3gigs of ram.

Should it be uninstalled, manually delete the Pschedule entry from within Pschedule as if it is installed again it will amend another copy to /var/spool/cron/crontabs/root.

I think I've covered everything that's needed to be known, let me know how it runs, I'm not planing on doing anymore to it, it seems to work well enough as it is, well it
suit's my purposes, maybe someone would like to make some voice packs.

Edit: I tried this with Slacko 53, had a problem it locked up the PC resulting in a Ctrl+Alt+Back and xwin to get going again,
this happened when the config was run from the menu, I edited the config script so now it works.
sneekylinux_44k8bit_en-2.pet
Description 
pet

 Download 
Filename  sneekylinux_44k8bit_en-2.pet 
Filesize  435.76 KB 
Downloaded  420 Time(s) 
sneekylinux_8k8bit_en-1.pet
Description 
pet

 Download 
Filename  sneekylinux_8k8bit_en-1.pet 
Filesize  126.81 KB 
Downloaded  402 Time(s) 
say_time-1.3.1.pet
Description 
pet

 Download 
Filename  say_time-1.3.1.pet 
Filesize  9.61 KB 
Downloaded  421 Time(s) 
say_time_slow_male_en-1.pet
Description  Voice pack for say time 1.3.1 only
pet

 Download 
Filename  say_time_slow_male_en-1.pet 
Filesize  139.35 KB 
Downloaded  414 Time(s) 
saytime-1.1.pet
Description  Updated so that it works from Slacko53 system menu, previous version locked up Puppy
pet

 Download 
Filename  saytime-1.1.pet 
Filesize  75.73 KB 
Downloaded  448 Time(s) 

Last edited by Geoffrey on Sat 19 Nov 2011, 23:01; edited 6 times in total
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Sat 08 Oct 2011, 05:04    Post subject:  

Smile
I was hoping to able to talk to time itself Shocked
Thanks for providing this, works well - sound not brill but theory is valid.

I am trying to think of an application - you know something like your backup will be ready at 'saytime' . . .

I know there will be a need for this when I build my time travel prototype . . . just got to wait for Cern to provide blue prints . . . and an inter-dimensional fax number . . . Wink

http://tmxxine.tumblr.com/

Puppy Time
Always Now, Always Ready.

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sat 08 Oct 2011, 07:26    Post subject:  

Lobster wrote:
Smile
I was hoping to able to talk to time itself Shocked
Thanks for providing this, works well - sound not brill but theory is valid.

I am trying to think of an application - you know something like your backup will be ready at 'saytime' . . .

I know there will be a need for this when I build my time travel prototype . . . just got to wait for Cern to provide blue prints . . . and an inter-dimensional fax number . . . Wink

http://tmxxine.tumblr.com/

Puppy Time
Always Now, Always Ready.


lol, yeah the sound files could be better, I noticed the word six is a little lacking, I was hoping to get the app size under 100k,
so I've just put it out there to see if anyone might like to have play with it, you never know something might come of it.

I have been using flite_time with pschedule set to tell me the time on the hour, I have a tendency not to look at the clock,
which in turn means I'm always running late for something, so I though there must be something that don't take up a lot of space
and this seems suitable for the task, well for it's size it probably worth having.

Geoffrey

edit: I copied the word six from the 16.wav, sounds a lot better than the original, just download it and remove the zip extension, it's not
a zip, wasn't worth compressing.
6.wav.zip
Description  I modified this removing a portion of the start as it took to long the other two people who downloaded it do so again
zip

 Download 
Filename  6.wav.zip 
Filesize  2.22 KB 
Downloaded  413 Time(s) 

Last edited by Geoffrey on Sat 08 Oct 2011, 10:14; edited 5 times in total
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Sat 08 Oct 2011, 07:39    Post subject:  

Nice one - thanks Geoffrey Cool
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sat 08 Oct 2011, 09:55    Post subject:  

Mmmm, this may be better than I thought, just playing around with a script to run the saytime script and found that it can give it different effects.

By running it from another script with multiple instances and sleep statements will give it a echo effect similar to a railway station or stadium,
to try that add the path to top of the script, I have mine in /usr/share/talking_clock/ so the script looks like this.

Code:
#!/bin/sh

cd /usr/share/talking_clock/

function sayHours() {
  aplay $1.wav
}

function sayMins() {
  tens=${1:0:1}
  units=${1:1:1}
    if [ ${#units} = 0   ]; then
    units=$tens
    tens="0"
  fi
  if [ $tens -lt 1 ]; then
    aplay $tens.wav
    aplay $units.wav
  elif [ $tens -lt 2 ]; then
    aplay $1.wav
  else
    tens=$tens"0"
    aplay $tens.wav
    if [ $units -gt 0 ]; then
      aplay $units.wav
    fi
  fi
}

function sayAMPM() {
  aplay $1.wav
}
 
hours=`date +"%-l"`
sayHours $hours
mins=`date +"%-M"`
sayMins $mins
ampm=`date +"%-P"`
sayAMPM $ampm


Then make a system link to it in /usr/bin/ and make another script with this in it,

Code:
#!/bin/sh
saytime &
sleep .1
saytime &
sleep .1
saytime


this script can be anywhere you like, just change the number of instances and sleep statements and timing to hear the the differences,
sounds quite good and actually covers up any imperfections in the sound files.

Geoffrey

edit: here is where I got the sound files from http://evolution.voxeo.com/tools/, to edit and convert them I used Audacity,
MhWavEdit
will also do it, they need to converted to "RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 8000 Hz],
and have the silence removed from the start and end of the files,this will nearly half the file size and allow aplay to use them.

I tried this code to play the clock, sounds really good. Laughing
Code:
#!/bin/sh
saytime &
sleep .1
saytime &
sleep 0
saytime &
sleep 0
saytime &
sleep .1
saytime &
sleep 0
saytime &
sleep 0
saytime &
sleep .1
saytime &
sleep 0
saytime


edit: I tried running it using mplayer instead of aplay, runs a little slower meaning more delay between words,
that being the case it will play 4bit wav files which would be half the size, so in theory should be able to get the app under a 100k
and no difference in sound quality, I haven't found a way to convert to 4bit RIFF (little-endian) data, WAVE audio, IMA ADPCM, mono 8000 Hz in puppy,
but can in windows with the appropriate software, can anyone tell me if there is anything available for linux to do the convertion to 4bit ?
also if running the multiple instances with mplayer can be a little extreme with the added delay, just food for thought, suggestions appreciated.

This is the web page that I got the clock script from http://www.jumpstation.co.uk/scripts/talkingclock/
Back to top
View user's profile Send private message 
harii4


Joined: 30 Jan 2009
Posts: 444
Location: La Porte City, IA , U.S.A.

PostPosted: Sun 09 Oct 2011, 12:58    Post subject:  

I was looking for an chime-ing clock like an grandfatherclock-1.0.1-2_all.deb
but this sounds cool too and easyier. Very Happy

_________________
3.01 Fat Free / Fire Hydrant featherweight/ TXZ_pup / 431JP2012
----------------------------------------------------------------------------------------
Peace and Justice are two sides of the same coin.
Back to top
View user's profile Send private message Visit poster's website 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 535

PostPosted: Sun 09 Oct 2011, 13:40    Post subject:  

Just a comment before really looking into it in detail:

[quote="Geoffrey"]
Code:

  tens=${1:0:1}
  units=${1:1:1}
    if [ ${#units} = 0   ]; then
    units=$tens
    tens="0"
  fi


you can also do:

Code:

tens=$(( 100 + $1 ))
units=${tens:2:1}
tens=${tens:1:1}


Really it would be nice to pick apart the numbers and say them using things like "twelve" instead of "one two" for all but the fractional amounts of seconds. This sounds like a job for a case statement. If you name the sound files from Word0.wav to Word12.wav with a Teen.wav etc, it
seems like it wouldn't be a lot of code to do.

You can also use "espeak" to say the words but that would be a lot larger than just putting in the sound files.
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Sun 09 Oct 2011, 21:45    Post subject:  

Hi Moose,

thanks for the code, definitely needs a rewrite, the problem I see with it is the fact that on the hour instead of saying for example, 5 AM it will say 5 OH OH AM
I've been scratching my head trying get around the problem, any help with this would be appreciated.

I think the beauty of making a talking clock this way is that there are no other dependencies needed, also one can create their own sound files.
Over all it don't sound all that bad, it's not as if it will be playing constantly so it doesn't need to be HIFI quality.
I was thinking of using mplayer for the sound but I think aplay is more suited to the task, it seems more responsive and is better suited for the echo effect.

I was also thinking that a simple GUI for presets to set the active period, on the hour etc, this only needs to amend /var/spool/cron/crontabs/root the same as pschedule,
also maybe some echo effects, these seem to give a bit more loudness to the sound, just a thought.

edit: I fixed the problem with OH OH on the hour, and used your replacement code.
Code:
function sayMins() {
  tens=$(( 100 + $1 ))
  units=${tens:2:1}
  tens=${tens:1:1}
  zero=""
  if [ $units = 0 ]; then
     zero="0"
  fi
  if [ $tens = $zero ]; then
    aplay blank.wav

Added a blank.wav file, I might have a go at adding noon and midnight wave files also, the script now looks like this.
Code:
function sayMins() {
  tens=$(( 100 + $1 ))
  units=${tens:2:1}
  tens=${tens:1:1}
  zero="" 
  if [ $units = 0 ]; then
     zero="0"
  fi
  if [[ $tens = $zero ]]; then
    aplay blank.wav
  elif [ $tens -lt 1 ]; then
    aplay $tens.wav
    aplay $units.wav
  elif [ $tens -lt 2 ]; then
    aplay $1.wav
  else
    tens=$tens"0"
    aplay $tens.wav
    if [ $units -gt 0 ]; then
      aplay $units.wav
    fi
  fi
}
function sayHours() {
  aplay $1.wav
}
function sayAMPM() {
   if [[ $mins = 0 ]]; then
    min="1"
    else
    min="0"
    fi
   if [ $hours = 12 ]; then
    hour="1"
    fi
   if [[ $min = $hour ]]; then
    type="m"
    else
    type=""
   fi
   if [ $ampm = "pm" ]; then
    pmam="p"
    midnoon=$pmam$type
    else
    pmam="a"
    midnoon=$pmam$type
   fi
   if [[ $midnoon = "am" ]]; then
    aplay midnight.wav
   elif [[ $midnoon = "pm" ]]; then
    aplay noon.wav
   else
   aplay $1.wav
   fi
}
hours=`date +"%-l"`
sayHours $hours
mins=`date +"%-M"`
sayMins $mins
ampm=`date +"%-P"`
sayAMPM $ampm


edit: 10/11/2011 Added code for midnight and noon wav, will upload new wav file for midnight and noon.
midnight.wav.zip
Description  new edited wav file for the above script, not a zip, just remove the zip extension
zip

 Download 
Filename  midnight.wav.zip 
Filesize  3.94 KB 
Downloaded  396 Time(s) 
noon.wav.zip
Description  new edited wav file for the above script, not a zip, just remove the zip extension
zip

 Download 
Filename  noon.wav.zip 
Filesize  3.51 KB 
Downloaded  421 Time(s) 
blank.wav.zip
Description  not a zip, just remove the zip extension
zip

 Download 
Filename  blank.wav.zip 
Filesize  46 Bytes 
Downloaded  395 Time(s) 

Last edited by Geoffrey on Tue 11 Oct 2011, 03:16; edited 2 times in total
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 535

PostPosted: Mon 10 Oct 2011, 12:30    Post subject:  

Geoffrey wrote:
Hi Moose,

thanks for the code, definitely needs a rewrite, the problem I see with it is the fact that on the hour instead of saying for example, 5 AM it will say 5 OH OH AM
I've been scratching my head trying get around the problem, any help with this would be appreciated.


I'll take a run at making a function that does a little better. My idea is to have files with cleverly selected names. Lets see if I can do it. I'll come back perhaps later today with the results of my investigation.
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 535

PostPosted: Mon 10 Oct 2011, 13:44    Post subject: Re: Talking Clock
Subject description: simple bash script talking clock
 

Here is my method. I made the script logic simple by making the file names match the numbers.

The file is flat (no directory structure)
sayclock.tar.gz
Description 
gz

 Download 
Filename  sayclock.tar.gz 
Filesize  1.02 KB 
Downloaded  374 Time(s) 
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Tue 11 Oct 2011, 02:35    Post subject: Re: Talking Clock
Subject description: simple bash script talking clock
 

Moose On The Loose wrote:
Here is my method. I made the script logic simple by making the file names match the numbers.

The file is flat (no directory structure)


Moose, I was a little confused, then I realized that you are scripting for espeak, or am I wrong, I was using flite for a clock,
I just stripped out the lib files that the clock required, but it still is large just for a clock,
near 5meg and not the clock to use if you need to know the exact time, it sounds fluent,
but has no settings so what you hear is what you get.

I'm still proceeding with the wav file approach, so far I have updated it to say noon and midnight,
I'm in the process of writing a preferences GUI for it, I'll update the code in my previous post for the noon midnight change.

Geoffrey
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Wed 12 Oct 2011, 10:47    Post subject:  

Uploaded a package for the saytime script, please test it and let me know how it works for you, see first post.

Geoffrey
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 535

PostPosted: Wed 12 Oct 2011, 21:12    Post subject: Re: Talking Clock
Subject description: simple bash script talking clock
 

Geoffrey wrote:
Moose On The Loose wrote:
Here is my method. I made the script logic simple by making the file names match the numbers.

The file is flat (no directory structure)


Moose, I was a little confused, then I realized that you are scripting for espeak, or am I wrong,

Geoffrey


You are wrong. I was showing the method. In the script file, you will see the variables PLAYER and SUFF. With these, you can make it print text as I did or say the words. Just change the PLAYER to be a wave file player, make SUFF to be "wav" and use wave files in place of the text files.

I wanted to demonstrate the method quickly so I did the text version.
Back to top
View user's profile Send private message 
gcmartin


Joined: 14 Oct 2005
Posts: 4447
Location: Earth

PostPosted: Thu 20 Oct 2011, 12:45    Post subject: Interesting Gadget  

Could one suggest how to insert this into the system to be an active system activity?

thre's also the taskbatr clock, could this be a feature of that clock or a replacement of that clock?

Is this a PET?

Thanks in advance

_________________
Get ACTIVE Create Circles; Do those good things which benefit people's needs!
We are all related ... Its time to show that we know this!
3 Different Puppy Search Engine or use DogPile
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1479
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Thu 20 Oct 2011, 23:41    Post subject: Re: Interesting Gadget  

gcmartin wrote:
Could one suggest how to insert this into the system to be an active system activity?

thre's also the taskbatr clock, could this be a feature of that clock or a replacement of that clock?

Is this a PET?

Thanks in advance



Yes it is a pet, see first post, when installed it will say the time on the hour in a AM/PM format, with a American female accent.

If you look in the menu under system there is a item called "Say Time Config" that will let you to select from 3 different echo effects, default being no effect,

select the effect to use and press play to listen to them, setup will open pschedule where you can change the activity time for the clock.

Typing "say_clock_time" in the terminal will say the time also, if for any reason you lose the pschedule task just add a new "say_clock_time" command

I didn't make this as a replacement for the task-bar clock, just as a separate feature, as I don't look at the clock all that often.

It isn't all that elaborate but seems to work ok, hope you find it useful.

Geoffrey
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 3 [32 Posts]   Goto page: 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Puppy Projects
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.1268s ][ Queries: 12 (0.0050s) ][ GZIP on ]