File size: 6,823 Bytes
966f861
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
faf666f
1fc3525
faf666f
966f861
 
 
 
 
 
1fc3525
 
966f861
 
 
 
 
23acb9e
7184f5f
1fc3525
966f861
 
 
 
 
 
1fc3525
966f861
 
 
 
 
 
 
1fc3525
966f861
 
 
 
972caea
966f861
23acb9e
1fc3525
4b59bb9
966f861
 
 
 
 
 
1fc3525
966f861
 
 
 
 
 
 
1fc3525
4b59bb9
966f861
 
 
 
 
 
2a2d5c1
966f861
 
 
 
 
 
 
2a2d5c1
4b59bb9
966f861
 
 
 
 
 
faf666f
4b59bb9
966f861
 
 
 
 
faf666f
1fc3525
966f861
 
 
 
 
 
 
 
 
 
 
7184f5f
ceb19de
 
966f861
ceb19de
 
 
966f861
 
 
 
 
 
1fc3525
966f861
 
 
 
ceb19de
966f861
 
 
 
 
 
1fc3525
ceb19de
 
972caea
2a2d5c1
 
ceb19de
966f861
 
 
 
 
ceb19de
972caea
ceb19de
 
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
188
189
190
191
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
                ])