Skip to content

Instantly share code, notes, and snippets.

@tin2tin
Created March 11, 2021 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tin2tin/9b24dff1ab4294e9562724614e450599 to your computer and use it in GitHub Desktop.
Save tin2tin/9b24dff1ab4294e9562724614e450599 to your computer and use it in GitHub Desktop.
Import and select a sound strip in the sequencer
import bpy
# Import and select a sound strip in the sequencer, then run scipt.
# A speaker object and a sound data-block will be created and linked.
active = bpy.context.scene.sequence_editor.active_strip
if active and active.type == "SOUND":
path = bpy.path.abspath(active.sound.filepath)
bpy.ops.object.speaker_add()
speaker = bpy.context.object
speaker.data.sound = bpy.data.sounds.load(path)
speaker.data.update_tag()
bpy.context.collection.objects.unlink(speaker)
bpy.context.collection.objects.link(speaker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment