There are several ways this might be accomplished in Photoshop or Lightroom Classic/Lightroom, but which solution is best depends on what it is you want to do exactly.
Do you want it to be automated to the point where it simply applies each aspect ratio crop from the center of the image, or do you want to customize the crop for each aspect ratio in each image? Either might be possible using some combination of artboards and frames. You would set up a template using artboards and frames in advance, with each artboard representing one aspect ratio. You would then drag or import the image into each frame and edit the text layer. If you need the text to be the same for all aspect ratios, set up the text layer as a Smart Object duplicated multiple times, so that editing just one Smart Object instances updates all of the copies of it to match. If you needed to recompose any image within its frame, you could select it and push it around.

Photoshop can export all artboards at once, to separate image files, using the Export > Export As command.

Do you want it to automatically load up both the photos and the text into each aspect ratio? That might be possible using the Variables feature in Photoshop, if you have a spreadsheet listing all of the file paths and the text to go with each image. But I’m not sure how well Variables works with artboards and frames.
If that’s what you’re thinking, to tie it all together for maximum automation might require a scripting wizard on this forum, like @JJMack. If you have something different in mind, fill us in on more of the details.