WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-18-2008, 05:38 AM
djdesmangles djdesmangles is offline
Member
 
Join Date: Nov 2006
Posts: 88
Lightbulb lip-synching + Progress Bar

Hello Wizards !!

The "viz.ACTION_END_EVENT" is working fine. Now I would like to optimize one of my functions.

1) My Avatar is lip-synched with a .wav file.
2) I got a progress bar displaying to the user the position in the .wav file while the Avatar is speaking.

So, to do that, I've loaded the .wav for the Avatar with the vizact.speak('intro.wav'). But, for the Progress Bar, I must loaded the file again as a VizAudio object to access the getTime() and the getDuration() functions. It's working, but is there a better way to do that ?

viz.FOREVER,
D.
Reply With Quote
  #2  
Old 02-19-2008, 01:30 PM
djdesmangles djdesmangles is offline
Member
 
Join Date: Nov 2006
Posts: 88
Unhappy You're there ??

Hello ?

I guess that you've forgot about me...

D.
Reply With Quote
  #3  
Old 02-19-2008, 02:26 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Don't worry, we haven't forgot about you. Yesterday was a holiday.

Here is sample code that will update a progress bar while a speech action is running. It works by starting a timer when the speech begins. The timer uses the action instance to determine the current time of the speech.
Code:
import viz
viz.go()

#Create avatar
avatar = viz.add('female.cfg',pos=(0,0,1),euler=(180,0,0))

#Create speech action
speak = vizact.speak('speech.wav',sync=True)

#Create progress bar
progress = viz.addProgressBar('',pos=(0.5,0.1,0))

#Function that will update progress of speech while it is running
def updateSpeechProgress(progress,instance):
	progress.set( instance.elapsed / instance.length )

#Start update timer when speech action begins
def onActionBegin(e):
	if e.object is avatar and e.action is speak:
		avatar.speechProgress = vizact.ontimer(0,updateSpeechProgress,progress,e.instance)
viz.callback(viz.ACTION_BEGIN_EVENT,onActionBegin)

#Stop update timer when speech action ends
def onActionEnd(e):
	if e.object is avatar and e.action is speak:
		vizact.removeEvent(avatar.speechProgress)
viz.callback(viz.ACTION_END_EVENT,onActionEnd)

#Start speech when spacebar pressed
vizact.onkeydown(' ',avatar.runAction,speak)
Reply With Quote
  #4  
Old 02-21-2008, 12:37 PM
djdesmangles djdesmangles is offline
Member
 
Join Date: Nov 2006
Posts: 88
Talking Coooool !!!

Yeah Man !!!

I'll try it !!! Thanks !!

viz.FOREVER !!
D.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Avatars creation........ k_iwan Vizard 23 06-02-2007 04:35 AM
Progress bar Jerry Vizard 1 10-16-2006 11:22 AM


All times are GMT -7. The time now is 05:49 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC