Hello and thank you for taking a look at this post.
I first want to thank all those involved with the creation and continued development of autohotkey. This program has greatly helped in my time management through automation.
Now on to the challenge.
I have a program called "Swifttalker" that (amongst other things) gives me the capability to convert txt files into wav files so I can listen to the words in the file aloud. A text to speech program. It makes this possible through manual efforts (manual clicking) and from command line submission.
I have been using the manual side for a while now and it works great for one or two files at a time.
Unfortunately I now have 219 pages (files) to convert and don't want to be sitting in front of my computer for days to complete this task.
So I started writing a script that would automate this process.
The challenge I'm having is with the loop (possibly other areas too).
If anyone would be willing to help it would be greatly appreciated. By the way, i have search the forum prior to this post to find and answer and found many answer regarding loops. Unfortunately, I did not find any related to this specific challenge.
Any and all suggestions are welcome. Thank you in advance for any actions and/or suggestions you may have.
Short script that has been tested and works:
Code:
^#!s:: ;;swifttalker speaks
Run, swift -n Callie -f "g:\ebook\adwords_beginning of page_008.txt" -o g:\ebook\wav_version\adwords_page_008.wav
return
Here is the current loop script that doesn't work:
Code:
Esc::ExitApp ;This exits the script whenever you press Escape
^#!s:: ;;swifttalker converts txt to wav
#SingleInstance, Force
#NoEnv
text_to_wav_folder = G:\ebook\ ;Source text_to_wav_folder
wav_folder = %text_to_wav_folder%\wav_version\ ;Destination folder
IfExist, %wav_folder%\*.* ;If the wav files already exists in wav_folder,
FileDelete, %wav_folder%*.* ;deletes any files from earlier converts
;Loop, %text_to_wav_folder%*.txt, , 0 ;Find all txt files, do not include subfolders
Loop, %ItemCount%
{
Run, swift -n Callie -f "%text_to_wav_folder%%A_LoopFileName%.txt" -o %wav_folder%%A_LoopFileName%.wav
Sleep, 200000
If ( ItemCount <= A_Index )
break ; Terminate the loop
}
MsgBox, Txt To Wav Coversion Is Done...
ExitApp
Last two things:
1. Having the ability to stop a run away loop like the below code included shows would be wonderful (I've already had to shut my computer down several time due to this one):
Code:
Esc::ExitApp ;This exits the script whenever you press Escape
^#!s:: ;;swifttalker converts txt to wav
#SingleInstance, Force
#NoEnv
text_to_wav_folder = G:\ebook\ ;Source text_to_wav_folder
wav_folder = %text_to_wav_folder%\wav_version\ ;Destination folder
IfExist, %wav_folder%\*.* ;If the wav files already exists in wav_folder,
FileDelete, %wav_folder%*.* ;deletes any files from earlier converts
;Loop, %text_to_wav_folder%*.txt, , 0 ;Find all txt files, do not include subfolders
Loop, %ItemCount%
{
Run, swift -n Callie -f "%text_to_wav_folder%%A_LoopFileName%.txt" -o %wav_folder%%A_LoopFileName%.wav
Sleep, 200000
If ( ItemCount <= A_Index )
break ; Terminate the loop
}
MsgBox, Txt To Wav Coversion Is Done...
ExitApp
And last one:
2. Replacing the msgbox at the end with a tooltip balloon that displays for a few seconds then goes away would bring about the quan (watch Jerry McGuire movie to find out; although I most likely misspelled it)
Thanks again and make sure you have a fantastic day!