text to speech - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: text to speech (/thread-27934.html) Pages:
1
2
|
text to speech - Heyjoe - Jun-27-2020 Fellow Python Users, I want to put several words in a list. Then tell Python to say the word. I did some searches on text to speech. I found 2 lines of code which do not work. Does anyone have an idea of what is wrong? #This is a way to use text to speech from a windows PC from win32com.client import Dispatch speak = Dispatch("SAPI.SpVoice") speak.Speak("Ciao") #This is a way to use text to speech if you have windows 10 and Python 3 import win32com.client as wincl speak = wincl.Dispatch("SAPI.SpVoice") speak.Speak("This is the pc voice speaking")The error message I get is: C:\Users\Joe\AppData\Local\Programs\Python\Python38-32\python.exe: can't open file 'C:/Users/Joe/PycharmProjects/myproj.py/ran.py': [Errno 2] No such file or directory I have no idea what the file ran.py is. RE: text to speech - snippsat - Jun-27-2020 You done a double name .py extension save,can not have both myproj.py and ran.py .Create and run your first Python project RE: text to speech - Heyjoe - Jun-28-2020 I couldn't find the double name extension save so I uninstalled Python and Pycharm, installed them again and started a new file. Now the error message is that there is no 'win32com' module. I have Windows 10. Shouldn't I have that module? Traceback (most recent call last): File "C:/Users/Joe/PycharmProjects/Myproject/texttospeech.py", line 2, in <module> from win32com.client import Dispatch ModuleNotFoundError: No module named 'win32com' Process finished with exit code 1 RE: text to speech - snippsat - Jun-28-2020 (Jun-28-2020, 06:18 PM)Heyjoe Wrote: I have Windows 10. Shouldn't I have that module?No most install pywin32. pip install pywin32 RE: text to speech - Heyjoe - Jun-30-2020 I did the following installation as instructed by snippsat. pip install pywin32 It installed successfully. It told me that the installation was an older version, so I did the installation of the newer version. I ran the following two codes. #This is a way to use text to speech if you have python 3 and windows 10 import win32com.client as wincl speak = wincl.Dispatch("SAPI.SpVoice") speak.Speak("This is the pc voice speaking") #This is a way to use text to speech from a windows PC from win32com.client import Dispatch speak = Dispatch("SAPI.SpVoice") speak.Speak("Ciao")Both codes gave me an error saying that win32 was not installed. I tried to install pywin32 again and it told me it was already installed. Anyone have an idea of what I did wrong? RE: text to speech - menator01 - Jun-30-2020 Have you tried espeak? It't works well on linux. Haven't tried on windows. RE: text to speech - snippsat - Jun-30-2020 As you use PyCharm most choose right interpreter. Configure a Python interpreter PyCharm So for you this is the path. C:\Users\Joe\AppData\Local\Programs\Python\Python38-32\python.exeAlso look here,make sure that python and pip command work from cmd. Learn to run and install from command line,it's a important part of basic programming skill. Quick example in cmder,same in cmd. C:\ λ cd code # Test python C:\code λ python -V Python 3.8.3 # Test pip C:\Code λ pip -V pip 20.1.1 from c:\python38\lib\site-packages\pip (python 3.8) # Install C:\code λ pip install pywin32 Requirement already satisfied: pywin32 in c:\python38\lib\site-packages (228) # Look at code,use <more> in cmd C:\code λ cat ciao.py from win32com.client import Dispatch speak = Dispatch("SAPI.SpVoice") speak.Speak("Ciao") # Run code and it works C:\code λ python ciao.py RE: text to speech - Heyjoe - Jun-30-2020 Snippsat I tried to run the C prompt commands that you gave me. I believe the output is the same as yours until I tried to run cat ciao.py. As you can see this resulted in an error. I changed the directory to where this file is located and it also resulted in an error. So I understand the first 3 commands, but I don't understand cat ciao.py. C:\Users\Joe>cd\ C:\>python -V Python 3.8.3 C:\>pip -V pip 20.1.1 from c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8) C:\>pip install pywin32 Requirement already satisfied: pywin32 in c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages (228) C:\>cat ciao.py 'cat' is not recognized as an internal or external command, operable program or batch file. C:\>cd\users\joe\pycharmprojects\myproject C:\Users\Joe\PycharmProjects\Myproject>cat ciao.py 'cat' is not recognized as an internal or external command, operable program or batch RE: text to speech - snippsat - Jun-30-2020 (Jun-30-2020, 09:44 PM)Heyjoe Wrote: but I don't understand cat ciao.py.Look one more time what i write snippsat Wrote:# Look at code,use <more> in cmdSo it's like this in cmd. C:\>cd code # look at file C:\code>more ciao.py from win32com.client import Dispatch speak = Dispatch("SAPI.SpVoice") speak.Speak("Ciao") # Run file C:\code>python ciao.py C:\code>cat is Linux command,so when i use cmder can use cat as it feel much more natural than the cmd commands for me.
RE: text to speech - Heyjoe - Jul-01-2020 The file ciao is in the directory \Users\Joe\PycharmProjects\Myproject So I did the following 2 command prompts commands from that directory. C:\Users\Joe\PycharmProjects\Myproject>more ciao.py #This is a way to use text to speech from a windows PC from win32com.client import Dispatch speak = Dispatch("SAPI.SpVoice") speak.Speak("Ciao") C:\Users\Joe\PycharmProjects\Myproject>python ciao.py So for the first command it showed what my code is. And the second command did work & I heard the word "ciao". I am wondering if it has to do if how I have my interpreter set up in Pycharm. |