RosettaCodeData/Task/Speech-synthesis/Phix/speech-synthesis.phix
2020-02-17 23:21:07 -08:00

27 lines
910 B
Text

-- demo/rosetta/Speak.exw
string text = """
Pete, I know that you are trying to get me to talk,
but I'm afraid that is something I simply cannot allow to happen.
Oops, I just spoke didn't I? That is a shame, now I have to kill you.
<rate speed="-15"><pitch absmiddle="35">Hai.<pitch absmiddle="-15">Fuh shum. Squelch. Thud."""
include pComN.ew
procedure speak(atom pVoice, string text)
{} = cominvk(pVoice,ISpVoice_Speak,{unicode_string(text),SPF_IS_XML,0})
end procedure
if platform()=WINDOWS then
CoInitializeEx()
atom pVoice = allocate(machine_word()),
res = CoCreateInstance(CLSID_SpVoice,IID_ISpVoice,pVoice)
if res!=S_OK then
crash("Failed to initialize SpeechAPI. (%08x)\n",res)
end if
speak(pVoice,text)
pVoice = com_release(pVoice)
CoUnInitialize()
freeGUIDS()
else
{} = system_exec(`espeak "This is an example of speech synthesis"`)
end if