Question

Is it possible to make computer (windows or linux, mac) speak in perl ? I know it is possible with VB script. But how about perl ?

In VB we just write

CreateObject("SAPI.SpVoice").Speak"I can speak "

How do we do this in perl ?

Was it helpful?

Solution

The Speech::Synthesis module can interface to Microsoft's SAPI 5 API, which it looks like you're using in VB. There's also Win32::SAPI5, which is Windows-specific but may offer more control, or you can just use Win32::OLE:

use Win32::OLE;

Win32::OLE->CreateObject('SAPI.SpVoice')->Speak('I can speak');

Of course, if you're going to speak multiple times, you'd probably want to create the object only once, store it in a variable, and call Speak multiple times on it.

OTHER TIPS

A quick CPAN search shows that PerlSpeak, Speech::Synthesis, and Speech::eSpeak all are capable of speech synthesis.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top