Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#1 Post by PaperTronics » 02 Apr 2017 06:41

Hi Guys! Today I'm gonna be posting one of my most glamorous creations "Speecher". Usually when you don't know how to pronounce any word, you go to Google, type that word and click the volume icon that appears with the meaning (At least that's what I do :mrgreen: ) But what to do when you have no Internet connection?? Google won't help you then :(

That's where Speecher comes in, Speecher is basically a program which says what you write in to it. In technical words, it's a Text-to-Speech engine 8). Although you can use Speecher for other purposes too. It all depends on your intelligence :idea: .

About me:
I'm currently working on Batch Projects but I know Python, HTML and CSS too. I'm one on of the admins on thebateam.org. My next project is BatchStore which is basically an App Store in Batch. This was my first post on dostips.com.. Tell me how would you rate it on a scale of 1/10? Also some tips for writing posts on dostips would be very appreciated. What do you think of my program?

Download link:
http://www.mediafire.com/file/4tovbku6kcercc7/Speecher.rar

Thanks for your attention
Bye Bye!

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#2 Post by Samir » 09 Apr 2017 14:22

So how exactly does this work? Batch file never had direct access to anything that could produce sound other than the speaker (BEEP command).

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#3 Post by ShadowThief » 09 Apr 2017 14:40

Samir wrote:So how exactly does this work? Batch file never had direct access to anything that could produce sound other than the speaker (BEEP command).

I haven't actually downloaded it yet, but I'm betting it's a batch/vbscript hybrid.

EDIT: Yep, VBScript and BatBox.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#4 Post by ShadowThief » 09 Apr 2017 14:48

It's a bit over-complicated for my taste, especially when you can just make a batch/vbscript hybrid script and get the same end result, but for people who don't know how to run things without clicking buttons, I guess this is nice. I'm still unclear about why you have to hit enter before you can click the button, and it would be nice if there was a way to close the program without just closing the window.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#5 Post by aGerman » 09 Apr 2017 14:56

It uses the SpVoice Interface that you can access via ActiveX (e.g. using JScript or in this case VBScript).

Simplified JS hybrid:

Code: Select all

@if (@a)==(@b) @end /* Batch part:
@echo off
cscript //nologo //e:jscript "%~f0" "Hello, world!"

exit /b &rem JScript part: */
WScript.CreateObject('SAPI.SpVoice').Speak(WScript.Arguments(0));

Steffen

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#6 Post by PaperTronics » 10 Apr 2017 07:31

ShadowThief wrote:It's a bit over-complicated for my taste, especially when you can just make a batch/vbscript hybrid script and get the same end result, but for people who don't know how to run things without clicking buttons, I guess this is nice. I'm still unclear about why you have to hit enter before you can click the button, and it would be nice if there was a way to close the program without just closing the window.


Thnx for your suggestion ShadowThief, the reason you have to hit enter before you can click the "GO" button is because of the set /p command which requires pressing enter for the user input to be taken into the program. However, I'll fix this in the next version. Currently, I'm working on another project so the next version won't be coming out that much soon.

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#7 Post by PaperTronics » 10 Apr 2017 07:37

aGerman wrote:It uses the SpVoice Interface that you can access via ActiveX (e.g. using JScript or in this case VBScript).

Simplified JS hybrid:

Code: Select all

@if (@a)==(@b) @end /* Batch part:
@echo off
cscript //nologo //e:jscript "%~f0" "Hello, world!"

exit /b &rem JScript part: */
WScript.CreateObject('SAPI.SpVoice').Speak(WScript.Arguments(0));

Steffen


The problem is I don't know JS. I only know a bit of VBScript and a few other languages like Python,HTML and CSS.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#8 Post by aGerman » 10 Apr 2017 10:12

It's actually not a matter of JScript. The only advantage is that you can combine it with the batch code in the same .bat file (as shown above).
You could also write the the line as VBScript in a manner that you can reuse it without writing it new all the time. All you have to do is passing the text to the script. WScript.Arguments(0) represents the first argument in every language that runs in wscrip.exe or cscript.exe (such as VBS and JS). E.g.

DataSpeecher.vbs

Code: Select all

CreateObject("SAPI.SpVoice").Speak WScript.Arguments(0)



Example.bat

Code: Select all

@echo off &setlocal
set "speech=Hello, World!"
start "" "DataSpeecher.vbs" "%speech%"

That's it. I'm quite sure you can change your tool in order to work accordingly :wink:

Steffen

Aacini
Expert
Posts: 1910
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#9 Post by Aacini » 10 Apr 2017 13:03

I wrote this program some time ago:

Code: Select all

@if (@CodeSection == @Batch) @then

@echo off

for %%a in ("Twinkle twinkle little star"
            "HowÿI wonder whatÿyou are"
            "Upÿa boveÿthe worldÿso high"
            "Likeÿa diamond inÿthe sky"
            "Twinkle twinkle little star"
            "HowÿI wonder whatÿyou are") do (
   CScript //nologo //E:JScript "%~F0" "%%~a"
)
goto :EOF

@end

// JScript section

var sapi = WScript.CreateObject("SAPI.SpVoice"),
    word = WScript.Arguments(0).split(" ");


// Select the last available voice
// (to select an English voice in my Spanish computer)
// Remove this part for native English voices
var v = new Enumerator(sapi.GetVoices());
while ( ! v.atEnd() ) {
   var voice = v.item();
   v.moveNext();
}
sapi.Voice = voice;


// Show and speech the line word-by-word
for ( var i = 0; i < word.length; i++ ) {
   WScript.Stdout.Write(word[i]+" ");
   sapi.Speak(word[i]);
}
WScript.Stdout.WriteLine();

Antonio

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#10 Post by einstein1969 » 10 Apr 2017 13:59

with mshta:

Code: Select all

@echo off

set /p "to_say=enter a text :"

mshta "javascript:code(close((V=(v=new ActiveXObject('SAPI.SpVoice')).GetVoices()).count&&v.Speak('%to_say%')))"

Thor
Posts: 43
Joined: 31 Mar 2016 15:02

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#11 Post by Thor » 10 Apr 2017 13:59

"Twinkle.txt":

Code: Select all

Twinkle twinkle little star.
How I wonder what you are.
Up above the world so high,
Like a diamond in the sky.
Twinkle twinkle little star.
How I wonder what you are.


Apply aGerman batch/javascript hybrid :D :
"talk.bat"

Code: Select all

@if (@a)==(@b) @end /* Batch part:
@echo off
for /f "tokens=*" %%A in (twinkle.txt) do (
   echo %%A
   call :sapi "%%A"
)
exit /b

:sapi
cscript //nologo //e:jscript "%~f0" "%~1"
goto :eof

exit /b &rem JScript part: */
WScript.CreateObject('SAPI.SpVoice').Speak(WScript.Arguments(0));

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#12 Post by penpen » 10 Apr 2017 14:13

You could also modify emphasize, volume, and ... , see:
http://www.dostips.com/forum/viewtopic.php?p=34981#p34981

penpen

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#13 Post by PaperTronics » 16 Apr 2017 02:53

Thank you so much for all your suggestions guys. I'll make sure to apply all of them in the next ver of Speecher after I finish my current project. I never thought Batch Legends with the likes of Aacini, aGerman,einstein1969 etc. will see my program. Thanks to all of you guys. Also be sure to check out my website thebateam.org. I think all Batch Programmers will like it alot

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#14 Post by aGerman » 16 Apr 2017 05:47

Also be sure to check out my website thebateam.org.

Yeah I already did. I was surprised to find my old insertbmp utility. I wasn't even aware that I shared it that early :lol:
Meanwhile I gave the source code to misol101 (besides of another function to make the console window transparent). He developed a tremendously improved utility: CmdBkg.

Steffen

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Speecher | A Pro Text-to-Speech Engine in Batch | By PaperTronics

#15 Post by ShadowThief » 16 Apr 2017 09:00

PaperTronics wrote:I never thought Batch Legends with the likes of Aacini, aGerman,einstein1969 etc. will see my program.

You didn't think the guys who hang out on this site would see your code?

PaperTronics wrote:Also be sure to check out my website thebateam.org

As a batch enthusiast, it's nice. As a website enthusiast, it's a bit cluttered and the random colorization of various parts of the blog entries seems arbitrary.

Post Reply