7

I tried espeak but didn't succeed and some functionalities only supported in python 2.

2 Answers 2

17

For offline use in Windows, use SAPI directly.

You can use SpVoice.

import win32com.client speaker = win32com.client.Dispatch("SAPI.SpVoice") speaker.Speak("Jumpman Jumpman Jumpman Them boys up to something!") 
Sign up to request clarification or add additional context in comments.

1 Comment

pip install pywin32 if ModuleNotFoundError: No module named 'win32com'.
4

Have you tried using Google Text-to-Speech via gTTS?

The syntax for using it in Python 3.x is as follows:

from gtts import gTTS my_tts = "Text you want to process" tts = gTTS(text=my_tts, lang='en') tts.save("Absolute/path/to/file.mp3") 

Here is the github repo of gTTS.

4 Comments

If I use gTTS my application would have to run online,right?I want some offline solution of text to speech.
gTTS sadly is online. I'll look for offline solutions but till then gTTS is your best bet. Also @kingforever your question didn't specify the requirement for it to work offline. And using TTS offline would frankly be a bad choice as you'd have to have tons of data (for each word) for working of TTS. So why not leave it on Google'e behalf? Plus for each language you choose to implement you'd have yet more data. It simply won't be worth the time or effort.
I am making talking calculator in tkinter GUI and I am very new to GUI. If there are not any other option I better try gTTS.Thanks a lot!
@kingforever : Accept this answer by clicking on the tick mark below the voting button as it has solved your problem so that others facing this problem would then know the solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.