Hi,
My granddaughter is dyslexic. Give her algebra, su-doku, fractions and the like, and she beats me! But Times Tables - oh dear, she just doesn't get them. She came for tea last night, bringing her maths homework, and she struggled a bit with some of the answers, mainly with the multiplication side
So I sat down today and wrote this little program. Dead simple and works. Just enter a number and press enter. But it would be nice if the numbers all lined up nicely, but I can't get my head around the USING call
Feel free to mess about with it, but please let me know if you crack it!
I think I will probably add a print window so that she can maybe print them out for further reference
Brian
Added USING's to your code and then fixed a problem you had not foreseen. Veranda is a pretty font, but not good if you want things to line up. So added Courier New to where it shows the equations, that way they line up and made the font a little bigger.
Bill
Great idea Brian!
My youngest granddaughter liked this one, so I converted the text into norwegian.
When I was her age, we had to learn stuff like this by heart, but she says they do not do that any more. Instead they use calculators.
They call it progress, but I'm not so sure about that...
Egil
Bill,
I will take a look at your improvements in the morning. Thank you. It should be interesting
Egil,
I also had to leatn them off by heart. Maybe I could look at turning the displayed results into speech, for the computer to say them back to her in some kind of rhyming meter
Brian
Bill,
Love the number alignment - thanks very much
I was messing with the speech just now, and I found a sample program in my old EBDev folder, but it won't compile, with these errors:
Compiling...
simple speech.iwb
No Errors
Linking...
IWBasic Linker v1.11 Copyright © 2011 Ionic Wind Software
Unresolved external __imp__gmtime64
Error: C:\Program Files (x86)\iwbdev\libs\disphelper.lib\disphelper.obj - Unresolved extern __imp__gmtime64
Error: C:\Program Files (x86)\iwbdev\libs\disphelper.lib\disphelper.obj - Unresolved extern __imp__mktime64
Error: C:\Program Files (x86)\iwbdev\libs\disphelper.lib\disphelper.obj - Unresolved extern __imp__localtime64
Error(s) in linking C:\Users\Public\Documents\IWBasic\projects\Rachel\simple speech.exe
I have attached the program listing
Funnily enough, the .exe that was compiled ages ago that was sitting in my EBDev folder runs perfectly, and speaks correctly as well. I am missing something, I know, but don't know what. The disphelper.inc is there, and also the disphelper.lib
Brian
Brian,
You are not the first person having this trouble: http://www.ionicwind.com/forums/index.php?topic=2412.msg42056#msg42056
I don't know if they ever found out what happened?
Egil
Try this...
$use "msvcrt.lib"
DECLARE CDECL EXTERN dhPutRef(pointer pDisp, WSTRING szMember, ...),int
WINDOW w1
INT run=0
CONST VoiceList=1
OPENWINDOW w1,100,100,400,340,@TOOLWINDOW|@TOPMOST,0,"TTS Test",&main
CONTROL w1,@LISTBOX,"",10,10,200,100,@TABSTOP|@CTLISTNOTIFY|@VSCROLL,VoiceList
SETFONT w1,"Times New Roman",10,500,0,VoiceList
GetVoices(w1,VoiceList)
WAITUNTIL run=1
CLOSEWINDOW w1
END
SUB main
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
run=1
CASE @IDCONTROL
SELECT @CONTROLID
CASE VoiceList
SELECT @NOTIFYCODE
CASE 0
ENDSELECT
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB
SUB Speak (string a,INT VoiceID)
IDispatch speech
IDispatch spvoice
speech = createComObject("Sapi.SPVoice")
IF speech+0 <> NULL
GetComProperty(speech,"%o",&spvoice,".GetVoices.Item(%d)",VoiceID)
IF (spvoice <> NULL)
dhPutRef(speech,L".Voice = %o",spvoice)
ENDIF
callObjectMethod(speech,".Speak(%s,0)",a)
speech->release()
ENDIF
ENDSUB
SUB GetVoices(WINDOW win,INT vList)
'clear list
WHILE GETSTRINGCOUNT(win,vList)>0
DELETESTRING win,vList,0
ENDWHILE
IDispatch speech
IDispatch spvoice
string text
pointer pText
int count,x
speech = CreateComObject("Sapi.SpVoice")
if speech+0 <> NULL
GetComProperty(speech,"%d",&count,".GetVoices.Count")
FOR x = 1 TO count
GetComProperty(speech,"%o",&spvoice,".GetVoices.Item(%d)",x-1)
GetComProperty(spvoice,"%s",&pText,".GetDescription")
text=#<STRING>pText
ADDSTRING win,vList,text
FreeCOMString(pText)
NEXT x
speech->release()
endif
ENDSUB
Later,
Clint
Clint,
Compiles perfectly. Thank you very much. I can now get on with the rest of this program. There was something stopping my original efforts that had to do with the 64-bit OS I am using, but this works perfectly
Click the "Try it!" button for a personal message
Brian
Right, attached is the latest version - with speech. You can change the amount of lines displayed by changing the HowMany variable before compiling. It gets a bit tedious to listen to 20 lines without being able to stop it!
There is also a print window button, but I don't know how to get that to work. There is also an icon for the program
Also, I would like to know how you can change the inflection of the voice, to make it more friendly and meaningful. Can't find any calls to adjust that
Brian
I think the only changes were these:
Changed all: _dhPutRef to dhPutRef, this was from Sapero (the code that I had this)
Added: $use "msvcrt.lib" at the top, this came from LarryMc
The top two changes allowed it to compile without errors, but it still didn't work.
Changed all: speech = CreateComObject("Sapi.SpVoice","") to speech = CreateComObject("Sapi.SpVoice"), this was from Sapero
The last change allowed it to work.
Later,
Clint
You can make the TTS engine pronounce words by spelling them a certain way. "Larry" actually sounds better if you spell it like "Lary". You could do a search and replace on known words before "speaking" them. Just a thought.
Here is a link for the SpVoice method if you're interested: https://msdn.microsoft.com/en-us/library/ms723602(v=vs.85).aspx (https://msdn.microsoft.com/en-us/library/ms723602(v=vs.85).aspx)
It looks like the common things you can change would be the rate and volume.
Later,
Clint
Thanks, Clint,
Added a couple of flags to make the speech run asynchronously and speak punctuations. Didn't make a lot
of difference, but it ticked a little box for me. Still working on it - just added tooltips
Really would like to be able to print the whole window . . .
Brian
The reason nothing is printing is because nothing has been printed to the window. It is all in controls.
You could open another window and "PRINT" to it with the "PRINT" statement. Below is the sub that I have made and use to print to a window.
SUB PrintText(WINDOW wp, STRING txt, INT x, INT y, INT pos)
INT pw,ph,px,py
GETTEXTSIZE wp,txt,pw,ph
py=y:px=x
SELECT pos
CASE 0 'line up the left side
py-=ph/2
CASE 1 'line up the right side
px-=pw
py-=ph/2
CASE 2 'center it
px-=pw/2
py-=ph/2
CASE 3 'line up the decimal point
IF INSTR(txt,".",1)>0
GETTEXTSIZE wp,LEFT$(txt,INSTR(txt,".",1)),pw,ph
ENDIF
px-=pw
py-=ph/2
DEFAULT 'where it is
ENDSELECT
MOVE wp,px,py
PRINT wp,txt
ENDSUB
Later,
Clint
Clint,
I'll take a look at your code later. What I have managed to do so far is to get the program window
saved to the Clipboard in bitmap format, by simulating the LeftAlt + PrintScrn keys, by code
All I need now is a method to print the contents of the bitmap in the Clipboard to a printer.
Looking through the forums doesn't really make anything jump out at me. I'll keep on looking
Brian