topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 1:33 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Silly Idea? A program that counts out loud  (Read 26854 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Silly Idea? A program that counts out loud
« on: August 09, 2007, 10:10 PM »
I had a funny idea today, and although i can't for the life of me think of a real use for this, it might be a fun project for someone looking to mess around with speech synthesis libraries.

Idea is a small program that just starts counting out loud like:
one, two, three, ..., five thousand and fifty four, ...
and so on until you stop it.

Might be interesting to put it on while you are trying to get to sleep.  I think for something like this it would be nice to use a quality voice library or maybe even custom recordings of the numbers (such a limited vocabulary so it should be possible).

Armando

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 2,727
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #1 on: August 09, 2007, 11:44 PM »
Crazy man. :)

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #2 on: August 10, 2007, 02:00 AM »
I see an use for gymnastics.  one, two, three, ...,

Especially if you would include repeating:
REPEAT FROM [ 1] TO [ 20]
and PAUSE before repeating: [ 30]sec.

Then i am able to open an gym, but need to increase
the vocabulary with -- "once again please" -- and -- "the last five now, ladies"

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #3 on: August 10, 2007, 05:32 AM »
Should be a fun little programming exercise anyway - once you've made an algorithm that can spell out an integer in English, the rest is pretty simple (until you get into trying to make the stitched-together speech sound natural ;) ).
- carpe noctem

app103

  • That scary taskbar girl
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 5,884
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #4 on: August 10, 2007, 06:02 AM »
It would end up sounding like an automated telephone information system at best. (the one for directory assistance)

It doesn't really seem all that hard to do, just thinking about it...but it probably will be harder than I think in practice.

Conquer

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 50
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #5 on: August 20, 2007, 01:38 PM »
Lmfao I actually made it! Still fixing minor bugs

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #6 on: August 20, 2007, 04:33 PM »
gimme!  :up:

fowmow

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 46
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #7 on: August 20, 2007, 09:35 PM »
Ever since reviewing ronriel's nifty little r4r media player, I have found a renewed love for AutoIt.

Here is that application in only 5 lines of AutoIt.

Code: AutoIt [Select]
  1. $o = ObjCreate("SAPI.SpVoice")
  2. For $i = 1 To 10
  3.         $o.Speak($i)
  4.         Sleep(50)

Oh, I forgot to mention I am running AutoIt 3.2.4.9 and Windows XP SP2.
I code.  Therefore I am.
« Last Edit: August 22, 2007, 10:14 AM by fowmow »

Cpilot

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 293
    • View Profile
    • Bite Notes
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #8 on: August 21, 2007, 12:01 AM »
In FBSL
Code: Text [Select]
  1. $apptype console
  2. Dim %t
  3. Dim oSpeak = CreateObject("SAPI.SpVoice")
  4. ?"Close console to quit......."
  5. for t = 0 to 15
  6. CallMethod(oSpeak,".Speak %d",t)
  7. next
  8. ReleaseObject(oSpeak)
  9. Pause

Here it is with the dreaded Microsoft agent:
Code: Text [Select]
  1. '$apptype console
  2.  
  3. dim %oAgent,%oCharacter,%objRequest,%t
  4.  
  5. oAgent = CreateObject("Agent.Control.2")
  6. PutValue(oAgent,".Connected %b",TRUE)
  7. CallMethod(oAgent,".Characters.Load %s,%s","Merlin","merlin.acs")
  8. oCharacter = GetValue("%o",oAgent,".Characters.Character %s","Merlin")
  9.  
  10. CallMethod(oCharacter,".Show")
  11. CallMethod(oCharacter,".MoveTo %d,%d",500,300)
  12.  
  13. CallMethod(oCharacter,".Play %s","Confused")
  14. For t = 0 to 15
  15. CallMethod(oCharacter,".Speak %s",$t)
  16. next
  17. CallMethod(oCharacter,".Hide")
  18. While GetValue("%d",oCharacter,"Visible")
  19. Sleep(250)
  20. Wend
  21. ReleaseObject(oCharacter)
  22. ReleaseObject(oAgent)
« Last Edit: May 23, 2009, 01:28 AM by Cpilot »

fowmow

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 46
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #9 on: August 22, 2007, 10:13 AM »
Following Cpilot's lead, the *dreaded* Microsoft Agent, Merlin.

I mixed it up a bit with the Sleep()'s so it didn't appear as if he paused too long.  And for the record... I believe I could have done this with events, but honestly, I was too lazy to read any more of the Agent SDK.  So it could definitely be done better.

Code: AutoIt [Select]
  1. $o = ObjCreate("Agent.Control.2")
  2. $o.Connected = "True"
  3. $o.Characters.Load("Merlin", @WindowsDir & "\msagent\chars\merlin.acs")
  4. $c = $o.Characters.Character("Merlin")
  5. $c.Show()
  6. $c.Play("Confused")
  7. Sleep(3000)
  8. $c.Speak("Count to 10?")
  9. Sleep(6000)
  10. For $i = 1 To 10
  11.         $c.Speak("" & $i & "")
  12.         Sleep(1500)
  13. Sleep(2500)
  14. $c.Think("Well... that was weird.")
  15. Sleep(3000)
  16. $c.Hide()
  17. Sleep(2000)

All of the Sleep()'s are necessary to allow Merlin enough time to speak.  And for those of you who might go, "Hey, I thought these guys were supposed to speak?"

You need a Text-To-Speech engine and SAPI 4.0.

I sat there myself for a time thinking, "Why won't Merlin talk to me?"

*sigh*

Hey Cpilot, they have a code block for FBSL too (in case you didn't already know).
I code.  Therefore I am.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #10 on: August 22, 2007, 12:07 PM »
Cool stuff! i'm going to try these and report  :Thmbsup:

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #11 on: August 23, 2007, 03:41 PM »
Clever idea CPilot  :up: :up:
Now where is that online fbsl to exe  service that used to be available?

fowmow -- works perfectly  :up: :up:  very fun stuff.

I'm going to try setting this thing to count to 10,000 and see if it helps me go to sleep.

Conquer

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 50
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #12 on: August 23, 2007, 05:49 PM »
Well, heres the version I finished a few days ago
#NoTrayIcon
#SingleInstance, Force
;SetTimer, RealTime, 1000
Active = False
Count = 0
Gui, Add, Button, w100 h25 gStart vStartWp, Start
Gui, Add, Button, w100 h25 yp xp+102 gPause, Pause
Gui, Add, Button, w100 yp xp+102 h25 gStop, Stop
Gui, Add, Text, vCountWp x10 w300 , Current Number: %Count%
;Gui, Add, Text, vCountSWp x10 w300 , Actual Elapsed Seconds: 0
Gui, +AlwaysOnTop
Gui, Show
return

Stop:
!s::
BreakLoop = True
Count = 0
GuiControl,,CountWp,Current Number: 0 (Stopped)
GuiControl,,StartWp,Start
SoundBeep
Active = False
return

Pause:
!p::
BreakLoop = True
GuiControl,,StartWp,Resume
SoundBeep
Active = False
GuiControl,,CountWp,Current Number: %Count% (Paused)
return

Start:
GuiControl,,StartWp,Start
Active = True
BreakLoop = False
SetTimer, CountTime, 1000
return

CountTime:
If BreakLoop = True
{
    SetTimer, CountTime, Off
    Active = False
}
If Active = False
    return
Count += 1
GuiControl,,CountWp,Current Number: %Count%
;return
;RealTime:
If Active = False
    return
RealCount += 1
;GuiControl,,CountSWp,Actual Elapsed Seconds: %RealCount%
TTS(Count)
return   




TTS(sSpeechText, dwFlags=0)
{
    ;For info on the dwFlags bitmask see the SAPI helpfile:
    ;http://download.microsoft.com/download/speechSDK/SDK/5.1/WXP/EN-US/sapi.chm

    static TTSInitialized, ppSpVoice, pSpeak

    wSpeechTextBufLen:=VarSetCapacity(wSpeechText, StrLen(sSpeechText)*2+2,0)
    DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "Str", sSpeechText, "Int", -1, "UInt", &wSpeechText, "Int", wSpeechTextBufLen/2)

    if !TTSInitialized
    {
        ComInit := DllCall("ole32\CoInitialize", "Uint", 0)
        if ComInit not in 0,1
            return "CoInitialize() failed: " ComInit

        sCLSID_SpVoice:="{96749377-3391-11D2-9EE3-00C04F797396}"
        sIID_ISpeechVoice:="{269316D8-57BD-11D2-9EEE-00C04F797396}"
        ;Make space for unicode representations.
       wCLSID_SpVoiceBufLen:=VarSetCapacity(wCLSID_SpVoice, StrLen(sCLSID_SpVoice)*2+2)
       wIID_ISpeechVoiceBufLen:=VarSetCapacity(wIID_ISpeechVoice, StrLen(sIID_ISpeechVoice)*2+2)
       ;Convert to unicode
       DllCall("MultiByteToWideChar", "UInt",0, "UInt",0, "Str",sCLSID_SpVoice, "Int",-1, "UInt",&wCLSID_SpVoice, "Int",wCLSID_SpVoiceBufLen/2)
       DllCall("MultiByteToWideChar", "UInt",0, "UInt",0, "Str",sIID_ISpeechVoice, "Int",-1, "UInt",&wIID_ISpeechVoice, "Int",wIID_ISpeechVoiceBufLen/2)
       
        ;Convert string representations to originals.
        VarSetCapacity(CLSID_SpVoice, 16)
        VarSetCapacity(IID_ISpeechVoice, 16)
        if ret:=DllCall("ole32\CLSIDFromString", "str", wCLSID_SpVoice, "str", CLSID_SpVoice)
        {
            DllCall("ole32\CoUninitialize")
            return "CLSIDFromString() failed: " ret
        }
        if ret:=DllCall("ole32\IIDFromString", "str", wIID_ISpeechVoice, "str", IID_ISpeechVoice)
        {
            DllCall("ole32\CoUninitialize")
            return "IIDFromString() failed: " ret
        }
   
        ;Obtain ISpeechVoice Interface.
        if ret:=DllCall("ole32\CoCreateInstance", "Uint", &CLSID_SpVoice, "Uint", 0, "Uint", 1, "Uint", &IID_ISpeechVoice, "UintP", ppSpVoice)
        {
            DllCall("ole32\CoUninitialize")
            return "CoCreateInstance() failed: " ret
        }
        ;Get pointer to interface.
        DllCall("ntdll\RtlMoveMemory", "UintP", pSpVoice, "Uint", ppSpVoice, "Uint", 4)
        ;Get pointer to Speak().
        DllCall("ntdll\RtlMoveMemory", "UintP", pSpeak, "Uint", pSpVoice + 4*28, "Uint", 4)

       
        if ret:=DllCall(pSpeak, "Uint", ppSpVoice, "str" , wSpeechText, "Uint", dwFlags, "Uint", 0)
        {
            DllCall("ole32\CoUninitialize")
            return "ISpeechVoice::Speak() failed: " ret
        }

        DllCall("ole32\CoUninitialize")

        TTSInitialized = 1
        return
    }

    if ret:=DllCall(pSpeak, "Uint", ppSpVoice, "str" , wSpeechText, "Uint", dwFlags, "Uint", 0)
        return "ISpeechVoice::Speak() failed: " ret
}

Features:
- Press start to make it start counting. It will keep going forever just as long as the script doesn't close
- The pause key is now fully functional
- There is also a little counter at the bottom that displays the current number.
- And one more thing - hotkeys. Alt+P to pause counting, Alt+S to stop counting

Known Limitations:
- If the script is counting a very large number (ex. one trillion, ten billion, one million, ten thousand, three hundred and fifty four.  ;D ) the script will take a few seconds to pause/stop (it will first finish saying the current number)

http://i22.photobucket.com/albums/b331/ConquerFa/Counter.jpg
Silly Idea? A program that counts out loud
« Last Edit: August 23, 2007, 06:46 PM by Conquer »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #13 on: August 23, 2007, 06:12 PM »
Nice work conquer  :up:

I wonder if there is a nicer speech engine i could get to make the speaker a bit smoother.

Thanks everyone for the great work on this, this is pretty cool actually.

Conquer

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 50
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #14 on: August 23, 2007, 06:56 PM »
attached in my above post is now a zipped version for anyone who doesn't have an AutoHotkey installation.

fowmow

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 46
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #15 on: August 23, 2007, 08:27 PM »
I wonder if there is a nicer speech engine i could get to make the speaker a bit smoother.

The only things I know of offhand are these (in no particular order):

1.  Use SAPI 5.1, or 5.3 instead of 4.0.  [1, 2, 3]

2.  AT&T Natural Voices

3.  A bunch of other voice libraries.

Thanks everyone for the great work on this, this is pretty cool actually.

And thank you, very much!
I code.  Therefore I am.

fowmow

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 46
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #16 on: August 23, 2007, 08:29 PM »
attached in my above post is now a zipped version for anyone who doesn't have an AutoHotkey installation.

Very cool.  What language was this written in?  Don't forget to use the appropriate codebox.   :)

EDIT:  Duh, I see now "ahk" in the title and you said it was AutoHotKey.  Jeez.  Maybe I should pay better attention!

Now I wonder if GeSHi has any plans to support AutoHotKey?
I code.  Therefore I am.
« Last Edit: August 23, 2007, 10:44 PM by fowmow »

fowmow

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 46
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #17 on: August 23, 2007, 10:53 PM »
Clever idea CPilot  :up: :up:
Now where is that online fbsl to exe  service that used to be available?

http://gedd123.free.fr/studio/
I code.  Therefore I am.

Cpilot

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 293
    • View Profile
    • Bite Notes
    • Read more about this member.
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #18 on: August 23, 2007, 10:59 PM »
Hey Cpilot, they have a code block for FBSL too (in case you didn't already know).
-fowmow
No I didn't fowmow, I'll check it out.
Usually I just open an instance of notepad and throw a script together.

Thanks for the Link to the FBSL ONLINE STUDIO COMPILER, I'd lost it actually.  :Thmbsup:

fowmow

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 46
    • View Profile
    • Donate to Member
Re: Silly Idea? A program that counts out loud
« Reply #19 on: August 24, 2007, 01:20 AM »
Hey Cpilot, they have a code block for FBSL too (in case you didn't already know).
-fowmow
No I didn't fowmow, I'll check it out.
Usually I just open an instance of notepad and throw a script together.

Oh!  By "code block" I meant when you put source code here.  Instead of just using:

[ code ][ /code ]

...you can use:

[ code=fbsl ]...[ /code ]

Minus all the spaces of course!

Thanks for the Link to the FBSL ONLINE STUDIO COMPILER, I'd lost it actually.  :Thmbsup:

No problem, Cpilot!
I code.  Therefore I am.