0

I had to use text to speech recently on python. This code worked just fine.

import pyttsx3
converter = pyttsx3.init()
converter.setProperty('rate', 150)
converter.setProperty('volume', 0.7)


# For Zira's voice uncomment this part of code
# voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0"

# converter.setProperty('voice', voice_id)

converter.say("Hello I convert text to speech")
converter.say("I am Zira")

Now I want to output whatever text I gave to it in mp3 form i.e. "Hello David" would be saved in mp3 file.

from gtts import gTTS
from playsound import  playsound

mytext="Hello Geek! How are you doing??"
language='en'
myobj=gTTS(text=mytext,lang=language,slow=False)
myobj.save("welcome1.mp3")
playsound("welcome1.mp3")

This code works great excluding the fact the voice used is neither of Zira nor David.

How can I make to export text in voice of David/Zira?

Couldn't find in docs so posted here.

dbmitch
  • 5,361
  • 4
  • 24
  • 38
  • I should be able to choose between David or Zira. – Blaack Work Apr 26 '22 at 15:12
  • Where did you get information that you can use registry setting for voiceid? Everything seems to indicate `voices = converter.getProperty('voices')` will show you what voices (and IDs) are available on your system – dbmitch Jun 26 '22 at 19:11
  • Unfortunately, you cannot use Microsoft voices like in this case DAVID/ZIRA. Google has its own voices. You can see this [documentation](https://cloud.google.com/text-to-speech/docs/voices) with the voices you can use with Google’s Text-To-Speech. – Raul Saucedo Jun 28 '22 at 17:07

0 Answers0