I can run the python code as below correctly on my windows7 with python3.4. But when I run it by python as cgi from apache client, Internal Server Error 500 was caused by engine.speak.
from comtypes.client import CreateObject
from comtypes.gen import SpeechLib
engine = CreateObject("SAPI.SpVoice", dynamic=False)
stream = CreateObject("SAPI.SpFileStream", dynamic=False)
stream.Open("Test.mp3", SpeechLib.SSFMCreateForWrite)
engine.AudioOutputStream = stream
engine.speak("Hello, Keynes")
stream.Close()
Q1: What reason cause this error happend? How can I fix it?
I try another way to get audio from text by balcon.exe. I can get the correct test.mp3 file by command line as below in cmd.exe
balcon -t hello -w test.mp3
I want return the created auido file to client when a user apply it by browser. So I put the command line in a bat file. And user's request will execute by a cgi python file thourgh apache.
os.system("translate.bat")
Then test.mp3 was created with no content. Q2: Why the same operate caused the diffrient result? How can I fix it?
Q3: How can I provide text to sound service for apache clinet by python3.