How run "bake sound to F-curve" without change area.type (bpy.context.area.type)

I try create a external graphics user interface, which will do a visualization music.
I have problem, because i can’t run script python to blender in command line level (The blender is supposed to run in the background). I have error about bpy.context.area.type:

AttributeError: ‘NoneType’ object has no attribute ‘type’

Without the change area, i can’t run function ‘bake sound to F-curve’.

Is there another way to run ‘bake sound to F-curve’ without change area ?