Reputation: 1
I am using text-to-speech in my python project but not getting any way to increase or decrease the pitch level of the local machine voice in python. Here is my basic code:
import pyttsx3
import datetime
import speech_recognition as sr
import random
print("Intializing Toretto")
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice',voices[1].id)
engine.setProperty('rate', 210)
def speak(audio):
engine.say(audio)
engine.runAndWait()
Upvotes: 0
Views: 2805
Reputation: 31
Pyttx3 fortunately do not strip xml sapi tags on Windows. You can use them like this
engine.say('<pitch middle="10">Hello there!</pitch>')
It depends on your TTS engine which tags are supported though.
https://www.clarosoftware.com/help/using-microsoft-xml-tags-with-sapi5/
Upvotes: 3
Reputation: 11
you should add a getProperty for the rate like this:
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
rate = engine.getProperty('rate')
engine.setProperty('voice',voices[1].id)
engine.setProperty('rate', 210)
Upvotes: 1