|
|
@ -2727,6 +2727,7 @@ class SEQUENCER_OT_generate_audio(Operator): |
|
|
|
movie_num_inference_steps = scene.movie_num_inference_steps |
|
|
|
movie_num_inference_steps = scene.movie_num_inference_steps |
|
|
|
movie_num_guidance = scene.movie_num_guidance |
|
|
|
movie_num_guidance = scene.movie_num_guidance |
|
|
|
audio_length_in_s = scene.audio_length_in_f / (scene.render.fps / scene.render.fps_base) |
|
|
|
audio_length_in_s = scene.audio_length_in_f / (scene.render.fps / scene.render.fps_base) |
|
|
|
|
|
|
|
pipe = None |
|
|
|
#try: |
|
|
|
#try: |
|
|
|
import torch |
|
|
|
import torch |
|
|
|
import torchaudio |
|
|
|
import torchaudio |
|
|
@ -2751,6 +2752,7 @@ class SEQUENCER_OT_generate_audio(Operator): |
|
|
|
import numpy as np |
|
|
|
import numpy as np |
|
|
|
try: |
|
|
|
try: |
|
|
|
from whisperspeech.pipeline import Pipeline |
|
|
|
from whisperspeech.pipeline import Pipeline |
|
|
|
|
|
|
|
from resemble_enhance.enhancer.inference import denoise, enhance |
|
|
|
except ModuleNotFoundError: |
|
|
|
except ModuleNotFoundError: |
|
|
|
print("Dependencies needs to be installed in the add-on preferences.") |
|
|
|
print("Dependencies needs to be installed in the add-on preferences.") |
|
|
|
self.report( |
|
|
|
self.report( |
|
|
@ -2865,6 +2867,7 @@ class SEQUENCER_OT_generate_audio(Operator): |
|
|
|
|
|
|
|
|
|
|
|
start_time = timer() |
|
|
|
start_time = timer() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find free space for the strip in the timeline. |
|
|
|
if i > 0: |
|
|
|
if i > 0: |
|
|
|
empty_channel = scene.sequence_editor.active_strip.channel |
|
|
|
empty_channel = scene.sequence_editor.active_strip.channel |
|
|
|
start_frame = ( |
|
|
|
start_frame = ( |
|
|
@ -2876,11 +2879,12 @@ class SEQUENCER_OT_generate_audio(Operator): |
|
|
|
) |
|
|
|
) |
|
|
|
else: |
|
|
|
else: |
|
|
|
empty_channel = find_first_empty_channel( |
|
|
|
empty_channel = find_first_empty_channel( |
|
|
|
scene.frame_current, |
|
|
|
scene.sequence_editor.active_strip.frame_final_start, |
|
|
|
100000000000000000000, |
|
|
|
(scene.movie_num_batch * (len(prompt) * 4)) + scene.frame_current, |
|
|
|
) |
|
|
|
) |
|
|
|
start_frame = scene.frame_current |
|
|
|
start_frame = scene.frame_current |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Bark. |
|
|
|
# Bark. |
|
|
|
if addon_prefs.audio_model_card == "bark": |
|
|
|
if addon_prefs.audio_model_card == "bark": |
|
|
|
print("Generate: Speech (Bark)") |
|
|
|
print("Generate: Speech (Bark)") |
|
|
@ -2976,6 +2980,7 @@ class SEQUENCER_OT_generate_audio(Operator): |
|
|
|
|
|
|
|
|
|
|
|
pipe.generate_to_file(filename, prompt, speaker=speaker, lang='en', cps=int(scene.audio_speed)) |
|
|
|
pipe.generate_to_file(filename, prompt, speaker=speaker, lang='en', cps=int(scene.audio_speed)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Musicgen. |
|
|
|
# Musicgen. |
|
|
|
elif addon_prefs.audio_model_card == "facebook/musicgen-stereo-medium": |
|
|
|
elif addon_prefs.audio_model_card == "facebook/musicgen-stereo-medium": |
|
|
|
print("Generate: MusicGen Stereo") |
|
|
|
print("Generate: MusicGen Stereo") |
|
|
@ -3080,11 +3085,12 @@ class SEQUENCER_OT_generate_audio(Operator): |
|
|
|
filename = solve_path(str(seed) + "_" + prompt + ".wav") |
|
|
|
filename = solve_path(str(seed) + "_" + prompt + ".wav") |
|
|
|
write_wav(filename, rate, audio.transpose()) |
|
|
|
write_wav(filename, rate, audio.transpose()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add Audio Strip |
|
|
|
filepath = filename |
|
|
|
filepath = filename |
|
|
|
if os.path.isfile(filepath): |
|
|
|
if os.path.isfile(filepath): |
|
|
|
empty_channel = find_first_empty_channel( |
|
|
|
# empty_channel = find_first_empty_channel( |
|
|
|
start_frame, start_frame + scene.audio_length_in_f |
|
|
|
# start_frame, start_frame + scene.audio_length_in_f |
|
|
|
) |
|
|
|
# ) |
|
|
|
strip = scene.sequence_editor.sequences.new_sound( |
|
|
|
strip = scene.sequence_editor.sequences.new_sound( |
|
|
|
name=prompt, |
|
|
|
name=prompt, |
|
|
|
filepath=filepath, |
|
|
|
filepath=filepath, |
|
|
|