Apocalypse Posted March 25, 2007 Posted March 25, 2007 (edited) I am writing a program that will allow you to right-click on a text file and choose to have it read to you. I will add the right-click part later, for now I am having trouble stopping the reading mid-sentence.Main.exeOpt("OnExitFunc", "endscript") HotKeySet("{ESC}", "endscript") If $CmdLine[0] == 0 Then Exit EndIf $file = FileOpen($CmdLine[1], 0) Dim $handle If $file = -1 Then $speech = ObjCreate("SAPI.SPVOICE") $speech.Rate = 7 $speech.Speak("Error, unable to open file.", 7) Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $handle = RunWait("TextToSpeech.exe " & $line) Wend Func endscript() If ProcessExists($handle) Then ProcessClose($handle) FileClose($file) Exit EndFuncTextToSpeech.exeIf $CmdLine[0] == 0 Then Exit EndIf $speech = ObjCreate("SAPI.SPVOICE") $speech.Speak($CmdLineRaw)Main.exe calls TextToSpeech.exe with each line of text in the given file, so that I could kill it mid-sentence. Unfortunately it waits until the sentence is completed before exiting.Also, while I'm on the subject: if anyone has a good tutorial on parsing *.rtf and/or *.doc files, I would really appreciate them.Thanks Edited March 25, 2007 by Apocalypse
Uten Posted March 25, 2007 Posted March 25, 2007 I think you would attract more response if you used a proper heading. Something along the line: How do I terminate SAPI.SPVOICE in the middle of a sentence? Any suggestions appreciated! Oh well hope that fixed your code.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
jvanegmond Posted March 25, 2007 Posted March 25, 2007 As far as I know, you can't terminate it once called.. You may want to consider splitting the file in parts that are no larger then 300 characters for instance, if you are having trouble with something reading into infinity.. github.com/jvanegmond
tAKTelapis Posted March 25, 2007 Posted March 25, 2007 see what happens when you read it one word at a time, considering that as a story, a " " (space) will be the universal splitter for each word, you could read in a line, split it at the spaces into an array, and read each word individually.look at regular expressions, i can imagine there would be a way to read everything upto a "." with that being a line, and you can add a hotkey / button on a small toolbar to "stop" the script, seeing as it is going 1 word at a time, it should stop after its current word is read.. unlike the sentence where it needs to read the sentence first.
Uten Posted March 25, 2007 Posted March 25, 2007 A little searching turned up this topic. Try to figure out SVSFlagsAsync Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now