0
#!/usr/bin/python3
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()

When i am running this above code on my server CentOS 7, it is showing no output. I just want to know how would I get sound at client side when its playing on server side.

Another try:

When I am runnning this below code:

#!/usr/bin/python3
#print("Content-type: text/html")
print("")
import pyttsx3
import comtypes
engine = pyttsx3.init('sapi5')     # <--- sapi 5 is for Win 10
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def speak(audio):
    engine.say(audio)
    engine.runAndWait()

It gives error:

Traceback (most recent call last):
  File "test_speech.py", line 7, in <module>
    import comtypes as ctypes
  File "/usr/local/lib/python3.6/site-packages/comtypes/__init__.py", line 23, in <module>
    from _ctypes import COMError
ImportError: cannot import name 'COMError'
Enix
  • 4,415
  • 1
  • 24
  • 37
  • Duplicate? https://askubuntu.com/questions/371687/how-to-carry-audio-over-ssh What OS are you sitting in front of? It's probably easier if it's Linux. – dstromberg Mar 19 '20 at 20:22
  • At server side it is linux and at client side I am on Windows 10. – Rahul Nagpal Mar 20 '20 at 03:26
  • You might want to get a web server and browser involved then. Unless someone can pull a "PulseAudio for Windows" out a hat :) – dstromberg Mar 20 '20 at 23:01

1 Answers1

0

Try this program...

engine = pyttsx3.init('sapi5')     # <--- sapi 5 is for Win 10
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)


def speak(audio):
    engine.say(audio)
    engine.runAndWait()
Redgar Tech
  • 347
  • 3
  • 13
  • It gives error: Traceback (most recent call last): File "test_speech.py", line 7, in import comtypes as ctypes File "/usr/local/lib/python3.6/site-packages/comtypes/__init__.py", line 23, in from _ctypes import COMError ImportError: cannot import name 'COMError' – Rahul Nagpal May 27 '20 at 12:28
  • That's strange... This has worked for me and everyone else I have helped. Double check you have all packages including pyaudio. Check if you have an input mic. – Redgar Tech May 27 '20 at 17:29
  • If that doesn't work I will give you another sample. It also might be that it isnt indented correctly. – Redgar Tech May 27 '20 at 17:29