import numpy as np import subprocess import cv2 # with subprocess and an extra argument 'scene' and a 'resized image saved as png' we can call the server # yt-dlp is instaled in .d4 # Download Part of Video # yt-dlp https://www.youtube.com/watch?v=UZ9uyQI3pF0 --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 997 -to 2512" # ffmpeg -i Sandra\ Kotevska\,\ Painting\ Rose\ bush\,\ mixed\ media\,\ 2017.\ \[NMzC_036MtE\].mkv -f mp3 -ar 22050 -vn out44.wav -ac 1 # https://superuser.com/questions/583393/how-to-extract-subtitle-from-video-using-ffmpeg #___________________________________________________________________________________________________ # VIDEO FROM IMAGE with CAPTIONS # # UPLOAD to: Simaviro: Documents General WORK PACKAGES WP1 ContentRepository ANBPR_ROMANIA TTSvideos # __________________________________________________________________________________________________ # TO DONLOAD SRT for youtub # yt-dlp --write-sub --sub-lang en --convert-subs "srt" https://www.youtube.com/watch?v=F1Ib7TAu7eg&list=PL4x2B6LSwFewdDvRnUTpBM7jkmpwouhPv&index=2 # _voice = 'en_US/vctk_low#p330' # _voice = 'en_US/cmu-arctic_low#lnh' #en_US/vctk_low#p249' # 'en_US/vctk_low#p282' # _voice = ''en_US/vctk_low#p351'' # _voice = 'en_US/vctk_low#p351' # avoid 318 it does the ghhhhhh # _voice = 'en_US/m-ailabs_low#judy_bieber' # Nice voice for ('Arta culinara romaneasca - Groza Irina [phIF0NxgwlQ].mkv' 'Arta culinara romaneasca - Groza Irina [phIF0NxgwlQ].en-GB.srt'), # _voice = 'en_UK/apope_low' # _voice = 'en_US/m-ailabs_low#mary_ann' # _voice = 'en_US/vctk_low#p351' # _voice = 'en_US/hifi-tts_low#92' # voice_str = f'_{_voice.replace("/", "")}' # image/descriptions provided by other SHIFT tool or Human curator # https://simaviro.sharepoint.com/sites/SHIFT/Shared%20Documents/Forms/AllItems.aspx?csf=1&web=1&e=JNK8dQ&cid=363c253d%2D4d61%2D4db1%2D8ffd%2Ddedda749da2d&RootFolder=%2Fsites%2FSHIFT%2FShared%20Documents%2FGENERAL%2FWORK%20PACKAGES%2FWP1%2FContent%20Repository%2Fshift%5FSPK%5Fuse%5Fcases%5Fshare%2F02%5Fuc%5Fspk%5FLandscape2Soundscape%2FLandscape2Soundscape%5F12%5FMasterpieces&FolderCTID=0x01200058F5037C0101524B82F6F0788C02A563 # STATIC_FRAME = 'uc_spk_Landscape2Soundscape_Masterpieces_pics/01_Schick_AII840_001.jpg' #'assets/image_from_T31.jpg' PIC_DIR = 'uc_spk_Landscape2Soundscape_Masterpieces_pics/' DESCRIPTIONS = [ # 1 [ '01_Schick_AII840_001.jpg', # image '01_Schick_AII840_001.txt', # text 'statue in shire, hill river, vogels.', # audiocraft 'G. Schick, Bildnis der Heinrike Dannecker, 1802', # cv2 puttext title 'en_UK/apope_low', #'en_US/m-ailabs_low#judy_bieber', #'en_US/m-ailabs_low#mary_ann', ], # 2 [ '02_Constable_AI555_001.jpg', '02_Constable_AI555_001.txt', 'Meadows country farm village in sight', 'J. Constable, Dorf An Dem Flusse Stour, 1804', 'en_US/m-ailabs_low#elliot_miller', ], # 3 [ '03_Schinkel_WS200-002.jpg', '03_Schinkel_WS200-002.txt', 'Arriving at the valley on galloping horses', 'K. Schinkel Gotische Kirche Auf Einem Felsen 1815', 'en_US/hifi-tts_low#6097', ], # [ '04_Friedrich_FV317_001.jpg', '04_Friedrich_FV317_001.txt', 'Land steppes', 'C. D. Friedrich, Der Watzmann, 1824', 'en_US/m-ailabs_low#mary_ann', ], # [ '05_Blechen_FV40_001.jpg', '05_Blechen_FV40_001.txt', 'fjords', 'C. Blechen, Unwetter In Der Romischen Campagna, 1829', 'en_US/m-ailabs_low#mary_ann', ], # 6 [ '06_Menzel_AI900_001.jpg', '06_Menzel_AI900_001.txt', 'Olive scenery roman Colloseum', 'A. Menzel, Bauplatz mit Weiden, 1846', 'en_US/cmu-arctic_low#aup', ], # 7 [ '07_Courbet_AI967_001.jpg', '07_Courbet_AI967_001.txt', 'Storm at the strand of waves Tsunami', 'G. Courbet, Die Welle, 1870', 'en_US/m-ailabs_low#mary_ann', ], # 8 [ '08_Monet_AI1013_001.jpg', '08_Monet_AI1013_001.txt', 'Mai flowers blossom picnic', 'C. Monet, Sommertag, 1874', 'en_US/cmu-arctic_low#axb', ], # 9 [ '09_Blechen_AII823_001.jpg', '09_Blechen_AII823_001.txt', 'Cascade in Africa', 'C. Blechen, Wasserfalle Bei Tivoli, 1832', 'en_US/m-ailabs_low#mary_ann', ], # 10 [ '10_Boecklin_967648_NG2-80_001_rsz.jpg', '10_Boecklin_967648_NG2-80_001.txt', 'Hades ades at it sisland', 'A. Bocklin, Toteninsel, 1883', 'en_US/cmu-arctic_low#jmk', ], # 11 [ '11_Liebermann_NG4-94_001.jpg', '11_Liebermann_NG4-94_001.txt', 'Tavern at the waterfront', 'M. Tiebermann, Gartenlokal An Der Havel Nikolskoe, 1916', 'en_US/cmu-arctic_low#ljm', ], # 12 [ '12_Slevogt_AII1022_001.jpg', '12_Slevogt_AII1022_001.txt', 'sailing yachts pool fluss', 'M. Slevogt, Segelboote Auf Der Alster Am Abend, 1905', 'en_US/m-ailabs_low#mary_ann', ], ] SILENT_VIDEO = '_silent_video.mp4' # SILENT CLIP for img, text, scene, title, voice in DESCRIPTIONS[2:4]: # TITLE BANNER im = cv2.imread(PIC_DIR + img) # IMG must have EVEN shape h, w, _ = im.shape im = im[(h%2):, (w%2):, :] # assure even image print(im.shape, "GLOBAL IM\n\n\n\n") fram = np.zeros((94, im.shape[1], 3), dtype=np.uint8) h, w, _ = fram.shape font = cv2.FONT_HERSHEY_SIMPLEX bottomLeftCornerOfText = (4, 74) # OFFSET IN BANNER (240, 74) # w,h fontScale = 2 fontColor = (255, 255, 255) thickness = 4 lineType = 2 cv2.putText(fram, title, bottomLeftCornerOfText, font, fontScale, fontColor, thickness, lineType) offset_h = 24 im[offset_h:h+offset_h, :w, :] = (.4 * im[offset_h:h+offset_h, :w, :] + .6 * fram).astype(np.uint8) cv2.imwrite('_tmp_banner.png', im) print('save 2nd',PIC_DIR + 'thumb____' + img) cv2.imwrite(PIC_DIR + 'thumb____' + img, cv2.resize(im, (im.shape[1]//4, im.shape[0]//4))) OUT_FILE = img.split('/')[-1].replace('.','__') + '.mp4' # assets / -1 print(f'{OUT_FILE=}\n') subprocess.run( [ "python", "tts.py", "--text", PIC_DIR + text, '--image', '_tmp_banner.png', '--scene', scene, '--voice', voice, '--out_file', OUT_FILE, # save to correct location is handled in client ])