1

I am trying to use pyttsx for text-to-speech. I would like it to tell the french 'é' :

# -*- coding: utf8 -*-

import pyttsx
engine = pyttsx.init()
voice = engine.getProperty('voices')[26] # the french voice
engine.setProperty('voice', voice.id)

engine.say('Je lui ai dit, fait gaffe a ton nez') # perfect

engine.say('Tu as bien mangé?') # not saying anything

engine.runAndWait()

2 Answers2

1

I tried with pyttsx3 because it's what I've installed. It runs under python 2.7.

Here is the code (for me french voice is 0). Just prefixing the string with u (for unicode) is doing the trick.

# -*- coding: utf8 -*
import pyttsx3
engine = pyttsx3.init()
voice = engine.getProperty('voices')[0] # the french voice
engine.setProperty('voice', voice.id)

engine.say('Je lui ai dit, fait gaffe a ton nez') # perfect

engine.say(u'Tu as bien mangé?') # it works!!

engine.runAndWait()    
Pilip
  • 25
  • 4
0

Personnally for me it is the 29th.

If you print voice.id in your code, it'll be written 'french' (or an other language depending on the number you put in).

so you should better write:

engine.setProperty('voice', 'french')

Which is also more elegant

starball
  • 20,030
  • 7
  • 43
  • 238
Beefr
  • 59
  • 6