pythonpython-2.7gnome-terminalfestival

How do I take a string and make festival say it


How do I take a string such as: K = "Hello User" and use it in the code that says it using festival tts: os.system('echo "Hello user." | festival --tts')? Is there a way to do it some other way (1st way would be better) I tried searching to do this on Google, Youtube and StackOverflow but I guess that there is very less info on festival tts. If anyone can help it would nice. Thank you. The complete code is:

import os        
K = "Hello user."        
os.system('echo "X" | festival --tts') 

I want to enter the text from string K to the Marked 'X' in the last line. Also I use linux-Terminal to run the code.


Solution

  • You should just be able to do something like this:

    os.system('echo %s | festival --tts' % K)
    

    That should replace the %s with the string K