WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Avatar speaking problem (https://forum.worldviz.com/showthread.php?t=1925)

Uttama_vizard 03-20-2009 12:40 PM

Avatar speaking problem
 
Hello,

My application requires interacting with an avatar (speaking) while wearing an eye tracking. What I want is that if my gaze goes towards the avatar, then the character should speak, but, when my gaze goes away from the avatar, the avatar should stop speaking or say something else.

But, the problem I am facing is that I am not being able to interrupt the avatar's previous action (before its scheduled completion).

I am using:
sound = vizact.speak("words.wav", scale= 0.007, sync=True)
character1.addAction(sound, pool=pool_number); pool_number = pool_number+1;

Then when I am using character1.clearActions(), it seems to me that I am not being able to interrupt the avatar's speech before its sceduled end point.

Any suggestion would be really appreciated.

Thanks

Uttama

Gladsomebeast 03-20-2009 07:04 PM

What you gotta do is write your own speak action.

Actions are defined in Python code, the vizact module actualy. There is an user defined action example in the Vizard help. Check that doc out, then open up vizact.py and examine the speak action. Copy the speak code into your own action module and modify it to stop the sound when the end action function is called.

Uttama_vizard 03-21-2009 02:50 PM

Avatar Speaking Problem
 
Hello,

As per your reply, I was actually trying to update the speak function in this way:

def speak(filename, scale=1.0, morph='mouth_open', threshold = 0, sync = False):
import vizwave

#Get wave data
fname = viz.res.getFullPath(filename) or filename
avnumbers,length = vizwave.getsamples(fname,400,5)

if len(avnumbers) > 0 and threshold < 0:
# calculate default threshold, otherwise provided threshold is used
sum = 0
for value in avnumbers:
sum = sum + value
threshold = sum / len(avnumbers) # average value of the array

bla = viz.ActionData()
bla.data = [avnumbers,length,morph,fname,scale,threshold,sync]
bla.actionclass = VizSpeakAction
return bla

def end(self,object):
if not self.finished():
if self.audio:
self.audio.stop()
self.audio.remove()
if self.bone:
self.bone.unlock()
elif self.morphObj:
self.morphObj.morph(self.morph,0)
viz.ActionClass.end(self,object)

def pause(self,state):
viz.ActionClass.pause(self,state)
if self.audio:
if state:
self.audio.pause()
else:
self.audio.play()

But, it is not working properly. Actually, I feel I am not updating the speak action properly.

If you can help me in this updating of the speak function (that is stopping and pausing it as required), it would be really great.

Thanks in advance for your valuable time.

Uttama

Gladsomebeast 03-22-2009 09:16 AM

Dear Mr.Uttama,

Just checked out the speak code in vizact and it looks like if you call vizact.speak with undocumented keyword 'sync' set to True then the audio stops when the action is canceled.

Code:

vizact.speak('jfk.wav', sync=True)
The 'sync' code keeps the mouth flapping and audio syncronized on long speak files. To do this, the code creates an audio object, rather than just calling viz.playsound, the default behevor you were seeing.

Farshizo, perhaps the next release should include viz.playsound(self.filename, viz.STOP) in the end method of VizSpeakAction?

Uttama_vizard 03-23-2009 11:29 AM

Avatar_speaking problem
 
Hello,

Thank you so much for your time. Yes, I have also noted that without the sync set to true, the flapping of the avatar's lips with the sound file is not synchronized.

When can we expect the next release with this feature built in? It would be really helpful.

Thanks

Uttama


All times are GMT -7. The time now is 01:25 AM.

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