File size: 6,841 Bytes
966f861 0572d9a 966f861 972caea 966f861 0572d9a 966f861 972caea 966f861 972caea 966f861 972caea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
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 on autumn beach.', # audiocraft
'Gottlieb Schick - Bildnis der Heinrike Dannecker - 1802', # cv2 puttext title
'en_US/m-ailabs_low#mary_ann',
],
# 2
[
'02_Constable_AI555_001.jpg',
'02_Constable_AI555_001.txt',
'Meadows country farm village in sight',
'John Constable - Dorf an dem Flusse Stour - 1804',
'en_US/m-ailabs_low#mary_ann',
],
# 3
[
'03_Schinkel_WS200-002.jpg',
'03_Schinkel_WS200-002.txt',
'Arriving at the shore on horses',
'Karl Friedrich Schinkel - Gotische Kirche auf einem Felsen am Meer - 1815',
'en_US/m-ailabs_low#mary_ann',
],
#
[
'04_Friedrich_FV317_001.jpg',
'04_Friedrich_FV317_001.txt',
'Land steppes',
'Friedrich Caspar David - Der Watzmann - 1824/1825',
'en_US/m-ailabs_low#mary_ann',
],
#
[
'05_Blechen_FV40_001.jpg',
'05_Blechen_FV40_001.txt',
'fjords',
'Blechen - Carl Unwetter in der römischen Campagna - 1829',
'en_US/m-ailabs_low#mary_ann',
],
# 6
[
'06_Menzel_AI900_001.jpg',
'06_Menzel_AI900_001.txt',
'Olive trees in Seville',
'Adolph Menzel - Bauplatz mit Weiden - 1846',
'en_US/m-ailabs_low#mary_ann',
],
# 7
[
'07_Courbet_AI967_001.jpg',
'07_Courbet_AI967_001.txt',
'Storm at the strand of waves Tsunami',
'Gustave Courbet - Die Welle - 1869/1870',
'en_US/m-ailabs_low#mary_ann',
],
# 8
[
'08_Monet_AI1013_001.jpg',
'08_Monet_AI1013_001.txt',
'Mai flowers blossom picnic',
'Claude Monet - Sommertag - 1874',
'en_US/m-ailabs_low#mary_ann',
],
# 9
[
'09_Blechen_AII823_001.jpg',
'09_Blechen_AII823_001.txt',
'Cascade in Africa',
'Carl Blechen - Wasserfälle 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',
'Arnold Böcklin - Toteninsel - 1883',
'en_US/m-ailabs_low#mary_ann',
],
# 11
[
'11_Liebermann_NG4-94_001.jpg',
'11_Liebermann_NG4-94_001.txt',
'Tavern at the waterfront',
'Max Tiebermann - Gartenlokal an der Havel. Nikolskoe - 1916',
'en_US/m-ailabs_low#mary_ann',
],
# 12
[
'12_Slevogt_AII1022_001.jpg',
'12_Slevogt_AII1022_001.txt',
'toy sailing yachts pool',
'Max 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_, soundscape_text, _title_, _voice_ in DESCRIPTIONS[:20]:
# cv2put txt
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 = (240, 74) # w,h
fontScale = 2
fontColor = (255, 255, 255)
thickness = 4
lineType = 2
cv2.putText(fram, _title_, #'LandScape 2 SoundScape',
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.imshow('i', im); cv2.waitKey(); cv2.destroyAllWindows()
cv2.imwrite('_tmp_banner.png', im)
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',
# "--title", _title_,
# '--soundscape_text', soundscape_text,
'--voice', _voice_,
'--out_file', OUT_FILE, # save to correct location is handled in client
]) |