Welcome Guest.   Make a donation to an author on the site July 30, 2014, 10:19:28 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Silly Idea? A program that counts out loud  (Read 12926 times)
mouser
First Author
Administrator
*****
Posts: 33,184



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: August 09, 2007, 10:10:20 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).
Logged
Armando
Charter Member
***
Posts: 2,674



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #1 on: August 09, 2007, 11:44:22 PM »

Crazy man. smiley
Logged

"I suppose it can be said that I'm an absent-minded driver. It's true that I've driven through a number of red lights on occasion, but on the other hand, I've stopped at a lot of green ones but never gotten credit for it."
Glenn Gould
AbteriX
Charter Honorary Member
***
Posts: 1,039


Member #520

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: August 10, 2007, 02:00:53 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"
Logged

Greetings, Stefan.
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: August 10, 2007, 05:32:08 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 Wink ).
Logged

- carpe noctem
app103
That scary taskbar girl
Global Moderator
*****
Posts: 5,117



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: August 10, 2007, 06:02:33 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.
Logged

Conquer
Honorary Member
**
Posts: 50



View Profile Give some DonationCredits to this forum member
« Reply #5 on: August 20, 2007, 01:38:41 PM »

Lmfao I actually made it! Still fixing minor bugs
Logged
mouser
First Author
Administrator
*****
Posts: 33,184



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: August 20, 2007, 04:33:11 PM »

gimme!  thumbs up
Logged
fowmow
Charter Member
***
Posts: 46


View Profile Give some DonationCredits to this forum member
« Reply #7 on: August 20, 2007, 09:35:10 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.

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  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.
« Last Edit: August 22, 2007, 10:14:59 AM by fowmow » Logged

I code.  Therefore I am.
Cpilot
Charter Honorary Member
***
Posts: 293



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #8 on: August 21, 2007, 12:01:52 AM »

In FBSL
Formatted for UNKNOWN with the GeSHI Syntax Highlighter [copy or print]
  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:
Formatted for UNKNOWN with the GeSHI Syntax Highlighter [copy or print]
  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:57 AM by Cpilot » Logged
fowmow
Charter Member
***
Posts: 46


View Profile Give some DonationCredits to this forum member
« Reply #9 on: August 22, 2007, 10:13:11 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.

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  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).
Logged

I code.  Therefore I am.
mouser
First Author
Administrator
*****
Posts: 33,184



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #10 on: August 22, 2007, 12:07:18 PM »

Cool stuff! i'm going to try these and report  Thmbsup
Logged
mouser
First Author
Administrator
*****
Posts: 33,184



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: August 23, 2007, 03:41:30 PM »

Clever idea CPilot  thumbs up thumbs up
Now where is that online fbsl to exe  service that used to be available?

fowmow -- works perfectly  thumbs up thumbs 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.
Logged
Conquer
Honorary Member
**
Posts: 50



View Profile Give some DonationCredits to this forum member
« Reply #12 on: August 23, 2007, 05:49:43 PM »

Well, heres the version I finished a few days ago
[copy or print]
#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.  Grin ) the script will take a few seconds to pause/stop (it will first finish saying the current number)


* Counter.zip (192.72 KB - downloaded 426 times.)
« Last Edit: August 23, 2007, 06:46:32 PM by Conquer » Logged
mouser
First Author
Administrator
*****
Posts: 33,184



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #13 on: August 23, 2007, 06:12:08 PM »

Nice work conquer  thumbs 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.
Logged
Conquer
Honorary Member
**
Posts: 50



View Profile Give some DonationCredits to this forum member
« Reply #14 on: August 23, 2007, 06:56:34 PM »

attached in my above post is now a zipped version for anyone who doesn't have an AutoHotkey installation.
Logged
fowmow
Charter Member
***
Posts: 46


View Profile Give some DonationCredits to this forum member
« Reply #15 on: August 23, 2007, 08:27:05 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!
Logged

I code.  Therefore I am.
fowmow
Charter Member
***
Posts: 46


View Profile Give some DonationCredits to this forum member
« Reply #16 on: August 23, 2007, 08:29:17 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.   smiley

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?
« Last Edit: August 23, 2007, 10:44:55 PM by fowmow » Logged

I code.  Therefore I am.
fowmow
Charter Member
***
Posts: 46


View Profile Give some DonationCredits to this forum member
« Reply #17 on: August 23, 2007, 10:53:21 PM »

Clever idea CPilot  thumbs up thumbs up
Now where is that online fbsl to exe  service that used to be available?

http://gedd123.free.fr/studio/
Logged

I code.  Therefore I am.
Cpilot
Charter Honorary Member
***
Posts: 293



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #18 on: August 23, 2007, 10:59:04 PM »

Quote from: fowmow
Hey Cpilot, they have a code block for FBSL too (in case you didn't already know).
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
Logged
fowmow
Charter Member
***
Posts: 46


View Profile Give some DonationCredits to this forum member
« Reply #19 on: August 24, 2007, 01:20:27 AM »

Quote from: fowmow
Hey Cpilot, they have a code block for FBSL too (in case you didn't already know).
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!
Logged

I code.  Therefore I am.
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.18s | Server load: 0.1 ]