Vizard tech tip: Text to Speech
By connecting to Microsoft's Speech API(SAPI) using their Component Object Model(COM) you can bring text to speech capability into Python and your Vizard script. This post descibes how to install pywin32, the Python for Windows extensions that you need for COM to work. There is also a sample script included that shows this being used within a Vizard environment.
Installation: If you are running on Windows XP or Vista, SAPI5Speech should already be installed. This allows you to use text to speech on your Windows machine. Click here to download Go to the pywin32 download page. Download the pywin32 version of the installer for the version of Python used by Vizard. Use the table below to determine which version of Python your Vizard installation uses: Vizard 2.x uses Python 2.3 Vizard 3.x uses Python 2.4 Run the installer. It should automatically detect Vizard's Python installation. If you have multiple Python installations on your computer, make sure you select the Vizard Python installation. About voices: If you are running Windows XP the default voice is 'Sam'. By installing SAPIVoice you can add the voices of 'Mary' and 'Mike' for use with XP. Follow this link to download the installer Windows Vista provides the default voice of 'Anna'. Speak method: When you call the Speak method on your SAPI voice object you tell it whether or not to return immediately(asynchronously) or wait until the speech is completed(synchronously). Here, since we want rendering and user interaction to continue while the text is spoken we call it asynchronously and pass in a value of 1 after the text. If you remove that flag, the user is blocked out and everything will freeze until the speech is done. Code:
#This is an example showing how to connect to the speech API within Code:
speak.Voice = speak.GetVoices('Name=Microsoft Mary').Item(0) |
What a fun tip.
I got a mouth-flapping avatar speaking via the API after some fiddling around. Check it out: Code:
import viz This Python Speech API wrapper code helped me figure this out. http://archives.seul.org/pygame/user.../msg00038.html |
All times are GMT -7. The time now is 10:59 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC