开发者

speech synthesis in perl

开发者 https://www.devze.com 2023-04-01 04:02 出处:网络
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 ?

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开发者_StackOverflow "

How do we do this in perl ?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号