Create function from the code that can be called from other file. function should use text_center, main_video_path as atributes and return final clip.
Use ' instead of “ in final code
 This is the code :import os
from moviepy.editor import *
from moviepy.video import fx
from moviepy.video.fx import all as fx
from PIL import ImageOps
from create_image_with_text import create_image_with_text

# Set the size of the final video
size = (1080, 1920)

# Time to delay top attributes
delayins=2
fps_size=10

# Set the directory where all the files are stored
dir_path = "C:/Python/VideoCreationTiktok/Source/"
dir_path_output = "C:/Python/VideoCreationTiktok/Output/"
#File to edit
main_video_path = os.path.join(dir_path, "main_video1.mp4")




# Set the paths to the source files
background_path = os.path.join(dir_path, "Background.jpg")
frame_path = os.path.join(dir_path, "Frame.png")
reaction_video_path = os.path.join(dir_path, "Reaction1.mov")
tools_path = os.path.join(dir_path, "tools.png")
gif_path = os.path.join(dir_path,"arrow.gif")

# Get the length of the main video
main_video = VideoFileClip(main_video_path)
main_video_length = main_video.duration

# Load the background image and resize it to fit the final video size while preserving aspect ratio
background = ImageClip(background_path)
background_resized = background.resize(height=size[1])
background_resized = background_resized.set_position('center')

# Resize and position the main video
main_video_resized = main_video.resize(height=size[1]*0.73)
main_video_resized = main_video_resized.set_position((60, 40))

# Load and resize the frame image
frame = ImageClip(frame_path)
frame_resized = frame.resize(height=size[1]*0.82)
frame_resized = frame_resized.set_position((10, 20))
frame_resized = frame_resized.set_duration(main_video_length)

# Load and trim the reaction video to the same length as the main video
reaction_video = VideoFileClip(reaction_video_path, has_mask=True).subclip(0, main_video_length)

# Load and resize the tools image
tools = ImageClip(tools_path)
tools_resized = tools.resize(width=int(size[0]*0.70))
tools_resized = tools_resized.set_position(('right', 'top'))

# Add the text to the final clip
txt_clip = TextClip("All Links", fontsize=tools_resized.h*0.8, font="Impact", color='white',stroke_width=3, stroke_color="black")
txt_clip = txt_clip.set_position(('left', 'top'))
#txt_clip = txt_clip.set_position((tools_resized.pos[0] + tools_resized.size[0]*0.1 + 5, tools_resized.pos[1] + tools_resized.size[1]*0.1))
txt_clip = txt_clip.set_duration(main_video_length)

# Load the gif file as a video clip
gif = VideoFileClip(gif_path, has_mask=True)


# Create a custom resizing function that ignores the aspect ratio
def custom_resize_ignore_aspect_ratio(clip, width, height):
    return clip.resize((width, height))

# Set the dimensions for the resized gif
gif_width = size[0]-tools_resized.w-txt_clip.w # desired width of the GIF
gif_height = tools_resized.h

# Resize the gif using the custom function
gif = custom_resize_ignore_aspect_ratio(gif, gif_width, gif_height)

gif = gif.loop(duration=main_video_length)

gif = gif.set_fps(fps_size)

# Set the position of the gif between the text and tools image
txt_clip_position = ('left', 'top')
txt_clip_x = 0
txt_clip_y = 0
gif_x = txt_clip_x + txt_clip.size[0]
tools_position = ('right', 'top')
tools_x = size[0] - tools_resized.size[0]
tools_y = 0
gif_y = tools_y
gif = gif.set_position((gif_x, gif_y))

# DELAY parameter
tools_resized = tools_resized.set_start(delayins)
gif = gif.set_start(delayins)
txt_clip = txt_clip.set_start(delayins)

# Create text clip overlay

image_path = create_image_with_text("AI CREATES WEBSITES OMG wow wow, omg...")
text_clip_red = ImageClip(image_path)





# Apply the "Summer" color effect to the final clip
final_clip = CompositeVideoClip([background_resized, main_video_resized, frame_resized, reaction_video.set_audio(None), tools_resized.set_duration(main_video_length), txt_clip, 
                                 gif,text_clip_red.set_position(("center", "center"))], size=size)


final_clip = fx.lum_contrast(final_clip, lum=0, contrast=0.2, contrast_thr=190)


# Get the audio from the main video
main_audio = main_video.audio


# Combine the clips into a final composition with the main video audio
final_clip = final_clip.set_audio(main_audio)

# Set the duration of the final clip to the length of the main video
final_clip.duration = main_video_length

#Preview
final_clip.resize(0.5).preview()

# # Write the final composition to a file with an unused number if file already exists
# i = 1
# while os.path.exists(os.path.join(dir_path_output, f"my_tiktok_video_{i}.mp4")):
#     i += 1
# final_clip.write_videofile(os.path.join(dir_path_output, f"my_tiktok_video_{i}.mp4"), fps=fps_size)