0

I would like to get python pyttsx to read extracts from Wikipedia.

This works but not entirely as it prints out the wiki extracts but it does not says, it just repeat my variable (question). I guess because the variables are not global and only relating to the single functions.

So how do I get pyttsx to read the extract from Wikipedia?

import wikipedia
import pyttsx

question = raw_input('what would you like to know? ')


print wikipedia.summary("question")


engine = pyttsx.init()

engine.say(question)
engine.runAndWait()
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

to refer to the question variable you must not put it into quotes. This works:

question = raw_input('what would you like to know?')
summary = wikipedia.summary(question)
print summary

about the pyttsx part: I could not get it installed, but this should work

engine = pyttsx.init()
engine.say(summary)
engine.runAndWait()
hansaplast
  • 11,007
  • 2
  • 61
  • 75