Closed SajanaW closed 4 years ago
I think you should be able to do this by using a simple wrapper python script. Something like:
import bpy;
bpy.context.context.object.pose_library.mouth_shapes.sound_file = "<your sound file>"
bpy.ops.object.rhubarb_lipsync()
Check here for info on to how to pass arguments to a python script from the command line.
Hope this gets you started in the right direction at least.
I have a problem with a similar approach.
I want to do everything from a script, adding the pose library and populating it with the basic mouth shapes. After that, I load the audio and script files and perform the lip syncing in rhubarb. All of this I do in a python script that I call using
> blender --python myscript -- audio.wav script.txt output
When the blender GUI opens, I see that all works fine and the character is animated. Also the handles for the face rig bones appear in the timeline. When I save this using the GUI (File -> SaveAs) everything works as expected and when I open the blend file, the handles are still present.
However, when I add the commands to store the blend file into the python script and run it without the GUI (using -b
), then the blend file is stored and the pose library is constructed and contains the basic mouth shapes, correctly associated to the rhubarb names but the handles for the face rig bones do not appear, i.e. the animation of the mouth is not present.
Do you have any idea what could go wrong? One thing I noticed was that I had to manually look for the process rhubarb.exe
to finish as the call of bpy.ops.object.rhubarb_lipsync()
does return immediately RUNNING_MODAL
even though rhubarb
does not seem to be done in the background. (When I don't look for the process to end manually and for example change mode from "POSE" to "OBJECT", I get errors.) Now I am wondering whether a similar thing might be happening with the handles and that maybe they are added in a background process but are not yet present when I store the blend file. I tried adding time.sleep()
's but so far without success.
Off the top of my head I'm not sure. RUNNING_MODAL is the expected behaviour - this prevents Blender locking up while the process runs. Eventually it will return FINISHED, but I'm not sure how to access that from your script. Waiting for the exe to end seems like a reasonable approach, but the addon is still processing the data returned from Rhubarb after it exits, so maybe your sleep needs to be longer.
Or maybe you'd be better off just copying some of the code from the addon directly into your script so you can run it non-modally. The relevant parts are all in op_blender_rhubarb.py.
Thanks a lot for your reply. I'll try it out!
Hi,
I'm new to blender but have a decent amount of python experience. I have a .blend file saved with pose library and all. I want to be able to run this add-on with a different audio file each time from the command line. Is there an easy way for your code to be extended for this to be done?
I notice that when I click on the 'Rhubarb lipsync' button in the properties window, a message is sent to the Rhubarb Lip sync Operator, like so: "{ "type": "start", "file": "...416MECoutput.wav", "log": { "level": "Info", "message": "Application startup. Input file: \"416MECoutput.wav\"." } }" Is there a way to send this kind of message over CLI?
Any help is deeply appreciated! Also major props for setting this up! It's super useful