Animation doesn't play at the same time with a micrphone ouput

I have 2 animations one is eyes blinking the second one is mouth movements. i puted the animation of eyes blinking in the init contructor to be by default. but when i want to play mouth movement with microhpne output it doesn’t play just after the microphone output terminated

self.talk("%s"%answer)
self.face.loop(“mouth”)

talk is a function that read a text message and i want to start the animatio exactly with microphone output and stop it when it is done

i used this lines to control the animations but nothing hppend, when i use anim.stop no animation plays again :

actor.play(‘Animation Name’)
actor.loop(‘Animation Name’)
actor.stop()

Do you mean that you have those lines one directly after the other in your code?

If so, then note that calling “play” before “loop” is redundant: “loop” should play your animation, I believe.

As to “stop”, well, that should indeed stop the animation, meaning that the loop won’t continue.

Unless you mean that subsequent calls to “loop” or “play” also don’t work after calling “stop”?

i used this line to manipulate the animations now

self.face.enableBlend()

self.face.setControlEffect(‘blink’, 3)

self.face.setControlEffect(‘mouth’, 0.8)

but when the micrphone output saying a vocal message no animation is playing i do not know why

i am trying to play the mouth animation at the sqme time with microphone output, but when it plays it freeze the animations

I don’t see anything playing the animations there?

How are you playing your microphone output? If it’s a method that doesn’t return until playback is done then Panda may not be getting a chance to update, and thus to animate.

If that’s the case, then perhaps a threaded approach is called for, with the microphone output–if feasible–being handled in a worker thread.

Hmm… I don’t know “pyttsx3”. However, the name of the method “runAndWait” does raise my suspicion that said module is blocking the rest of the program.

I’d suggest having a shot at running the audio stuff in a separate thread, and seeing whether that helps. (See the manual for information on threading with Panda.)

However, if might be worth checking whether it’s safe to do so what that module–whether by checking any documentation that came with it, or finding a relevant community, or checking the module’s website (if any), or asking the developers. Not all modules are safe to put into a non-main thread, I believe!

i think you are alright about that runAndWait function it stops everything but when i remove it, it says nothing. if there is a method with task manager can handle it or not ?

I’m not quite sure of what you mean by this. Are you asking whether the task-manager provides a method that would allow “runAndWait” to function without halting the program?

If so, did you read the section of the manual regarding threading? That should give you a direction to investigate, I think.

(Bearing in mind the caution that I gave above.)

Yes, i had a look on threading in panda but it has only definitions wihout sample code. Have you work with that before so you can provide a sample code please

Threading has never been a strength of mine, I fear, and in any case it’s a little late here.

Based on what I’m seeing in the manual, it looks like Panda’s threading functionality works (from the developer’s point of view, if not internally) much the same as does the standard Python threading functionality. Thus you might be able to look up a Python threading tutorial to learn from.

i used now Python threading it works somehow but it interrompts the console

th = threading.Thread(target=talk, args=(text,))

th.start()

print(‘ok’)

th.join()

Erm… I intended that you use a Python threading tutorial to learn the use of Panda’s threading system. While I forget the specifics, I believe that there’s some reason that Panda has its own implementation of threading. Thus, I recommend that you stick to Panda’s version.

Otherwise… what do you mean by “it interrupts the console”? (Presuming that I’m inferring that second word accurately–if not, please correct me!)

i mean that when the threads done it breaks the console

interopmtConsole

so i cannot use any other actions. if i used this in panda application it will break the console and nothing will happen if i click some button in that interface

Those just look like empty lines are being printed–are you sure that it’s not just that?

If it is just empty lines, you might be able to look for calls to “print” in your code and determine which is causing the issue. If it’s not in your code… then I honestly don’t know what might be causing it.

It is weird, i tried to call another animation at the same time but the anim doesn’t play inside a function. it is like the code i provided in the firsts comments. Does animations play inside a function when it called?

It should play, indeed.

However:

Are you saying that you have both the animation and the microphone audio in the same thread?

If so, then you may simply be running into the same problem as before: the microphone stuff is blocking the animation. In that case, perhaps just move the animation-code out of the thread and into the main program.

i removed the threads sections and i called the animation inside a function but it doesn’t play

Ah, I see.

In this case, I think that the problem lies here:

You’re calling “stop” immediately after calling “loop”. As a result, the animation to be looped doesn’t get a chance to play before it’s stopped.

yes that is right, but i want it to be closed just after the sound finish. i do not one it to play with non-stop. Can i do that?