EmmaGao8
EmmaGao8

Reputation: 83

Saying words in a given language in Python

How can Python be used to say words in a given language?

When I tried this:

import os

os.system("say 'hi'")

Python displayed:

sh: 1: say: not found

When I tried this:

import pyttsx3;

engine = pyttsx3.init();
engine.say("I will speak this text");
engine.runAndWait();

Python said that there was no such file/directory as libespeak.so.1 while running the __init__().

At last, I tried:

import win32com.client as wincl

speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak("This is the pc voice speaking")

Python told me that there was no such thing as win32com.

Upvotes: 0

Views: 207

Answers (1)

IcedLawyer
IcedLawyer

Reputation: 26

Try installing pypiwin32

pip install pypiwin32

This is for

import win32com.client as wincl
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak("This is the pc voice speaking")

Upvotes: 1

Related Questions