debug cv2 puttext
Browse files- README.md +7 -7
- api.py +1 -1
- landscape2soundscape.py +26 -24
README.md
CHANGED
@@ -19,17 +19,17 @@ tags:
|
|
19 |
---
|
20 |
|
21 |
|
22 |
-
# Affective TTS -
|
23 |
-
- Affective TTS via [SHIFT TTS tool](https://github.com/audeering/shift)
|
24 |
- Soundscapes, e.g. trees, water, leaves, generations via [AudioGen](https://huggingface.co/dkounadis/artificial-styletts2/discussions/3)
|
25 |
-
- `landscape2soundscape.py` shows how to
|
26 |
-
- `134` build-in
|
27 |
|
28 |
-
|
29 |
|
30 |
-
<a href="https://audeering.github.io/shift/">Listen
|
31 |
|
32 |
-
|
33 |
|
34 |
Install
|
35 |
|
|
|
19 |
---
|
20 |
|
21 |
|
22 |
+
# Affective TTS - SoundScape
|
23 |
+
- Affective TTS via [SHIFT TTS tool](https://github.com/audeering/shift)
|
24 |
- Soundscapes, e.g. trees, water, leaves, generations via [AudioGen](https://huggingface.co/dkounadis/artificial-styletts2/discussions/3)
|
25 |
+
- `landscape2soundscape.py` shows how to overlay TTS & Soundscape to Images
|
26 |
+
- `134` build-in voices
|
27 |
|
28 |
+
Available Voices
|
29 |
|
30 |
+
<a href="https://audeering.github.io/shift/">Listen Voices!</a>
|
31 |
|
32 |
+
**Flask API**
|
33 |
|
34 |
Install
|
35 |
|
api.py
CHANGED
@@ -396,7 +396,7 @@ def serve_wav():
|
|
396 |
print(f'\n=SERVER saved as {OUT_FILE=}\n')
|
397 |
response = send_from_directory(CACHE_DIR, path=OUT_FILE)
|
398 |
response.headers['suffix-file-type'] = OUT_FILE
|
399 |
-
print('
|
400 |
return response
|
401 |
|
402 |
|
|
|
396 |
print(f'\n=SERVER saved as {OUT_FILE=}\n')
|
397 |
response = send_from_directory(CACHE_DIR, path=OUT_FILE)
|
398 |
response.headers['suffix-file-type'] = OUT_FILE
|
399 |
+
print('________________\n ? \n_______________')
|
400 |
return response
|
401 |
|
402 |
|
landscape2soundscape.py
CHANGED
@@ -46,7 +46,7 @@ DESCRIPTIONS = [
|
|
46 |
'01_Schick_AII840_001.jpg', # image
|
47 |
'01_Schick_AII840_001.txt', # text
|
48 |
'Statue in shire hill on autumn beach.', # audiocraft
|
49 |
-
'Gottlieb Schick - Bildnis der Heinrike Dannecker
|
50 |
'en_US/m-ailabs_low#mary_ann',
|
51 |
],
|
52 |
# 2
|
@@ -54,7 +54,7 @@ DESCRIPTIONS = [
|
|
54 |
'02_Constable_AI555_001.jpg',
|
55 |
'02_Constable_AI555_001.txt',
|
56 |
'Meadows country farm village in sight',
|
57 |
-
'John Constable - Dorf
|
58 |
'en_US/m-ailabs_low#mary_ann',
|
59 |
],
|
60 |
# 3
|
@@ -62,7 +62,7 @@ DESCRIPTIONS = [
|
|
62 |
'03_Schinkel_WS200-002.jpg',
|
63 |
'03_Schinkel_WS200-002.txt',
|
64 |
'Arriving at the shore on horses',
|
65 |
-
'Karl Friedrich Schinkel - Gotische Kirche
|
66 |
'en_US/m-ailabs_low#mary_ann',
|
67 |
],
|
68 |
#
|
@@ -70,7 +70,7 @@ DESCRIPTIONS = [
|
|
70 |
'04_Friedrich_FV317_001.jpg',
|
71 |
'04_Friedrich_FV317_001.txt',
|
72 |
'Land steppes',
|
73 |
-
'Friedrich Caspar David - Der Watzmann
|
74 |
'en_US/m-ailabs_low#mary_ann',
|
75 |
],
|
76 |
#
|
@@ -78,7 +78,7 @@ DESCRIPTIONS = [
|
|
78 |
'05_Blechen_FV40_001.jpg',
|
79 |
'05_Blechen_FV40_001.txt',
|
80 |
'fjords',
|
81 |
-
'Blechen -
|
82 |
'en_US/m-ailabs_low#mary_ann',
|
83 |
],
|
84 |
# 6
|
@@ -86,7 +86,7 @@ DESCRIPTIONS = [
|
|
86 |
'06_Menzel_AI900_001.jpg',
|
87 |
'06_Menzel_AI900_001.txt',
|
88 |
'Olive trees in Seville',
|
89 |
-
'Adolph Menzel - Bauplatz mit Weiden
|
90 |
'en_US/m-ailabs_low#mary_ann',
|
91 |
],
|
92 |
# 7
|
@@ -94,7 +94,7 @@ DESCRIPTIONS = [
|
|
94 |
'07_Courbet_AI967_001.jpg',
|
95 |
'07_Courbet_AI967_001.txt',
|
96 |
'Storm at the strand of waves Tsunami',
|
97 |
-
'Gustave Courbet - Die Welle
|
98 |
'en_US/m-ailabs_low#mary_ann',
|
99 |
],
|
100 |
# 8
|
@@ -102,7 +102,7 @@ DESCRIPTIONS = [
|
|
102 |
'08_Monet_AI1013_001.jpg',
|
103 |
'08_Monet_AI1013_001.txt',
|
104 |
'Mai flowers blossom picnic',
|
105 |
-
'Claude Monet - Sommertag
|
106 |
'en_US/m-ailabs_low#mary_ann',
|
107 |
],
|
108 |
# 9
|
@@ -110,7 +110,7 @@ DESCRIPTIONS = [
|
|
110 |
'09_Blechen_AII823_001.jpg',
|
111 |
'09_Blechen_AII823_001.txt',
|
112 |
'Cascade in Africa',
|
113 |
-
'Carl Blechen - Wasserfälle
|
114 |
'en_US/m-ailabs_low#mary_ann',
|
115 |
],
|
116 |
# 10
|
@@ -118,7 +118,7 @@ DESCRIPTIONS = [
|
|
118 |
'10_Boecklin_967648_NG2-80_001_rsz.jpg',
|
119 |
'10_Boecklin_967648_NG2-80_001.txt',
|
120 |
'Hades ades at it sisland',
|
121 |
-
'Arnold Böcklin - Toteninsel
|
122 |
'en_US/m-ailabs_low#mary_ann',
|
123 |
],
|
124 |
# 11
|
@@ -126,7 +126,7 @@ DESCRIPTIONS = [
|
|
126 |
'11_Liebermann_NG4-94_001.jpg',
|
127 |
'11_Liebermann_NG4-94_001.txt',
|
128 |
'Tavern at the waterfront',
|
129 |
-
'Max Tiebermann - Gartenlokal
|
130 |
'en_US/m-ailabs_low#mary_ann',
|
131 |
],
|
132 |
# 12
|
@@ -134,7 +134,7 @@ DESCRIPTIONS = [
|
|
134 |
'12_Slevogt_AII1022_001.jpg',
|
135 |
'12_Slevogt_AII1022_001.txt',
|
136 |
'toy sailing yachts pool',
|
137 |
-
'Max Slevogt - Segelboote
|
138 |
'en_US/m-ailabs_low#mary_ann',
|
139 |
],
|
140 |
]
|
@@ -146,10 +146,13 @@ SILENT_VIDEO = '_silent_video.mp4'
|
|
146 |
# SILENT CLIP
|
147 |
|
148 |
|
149 |
-
for
|
|
|
|
|
150 |
|
151 |
-
#
|
152 |
-
|
|
|
153 |
h, w, _ = im.shape
|
154 |
im = im[(h%2):, (w%2):, :] # assure even image
|
155 |
print(im.shape, "GLOBAL IM\n\n\n\n")
|
@@ -161,27 +164,26 @@ for _img_, _text_, soundscape_text, _title_, _voice_ in DESCRIPTIONS[:20]:
|
|
161 |
fontColor = (255, 255, 255)
|
162 |
thickness = 4
|
163 |
lineType = 2
|
164 |
-
cv2.putText(fram,
|
165 |
bottomLeftCornerOfText,
|
166 |
font,
|
167 |
fontScale,
|
168 |
fontColor,
|
169 |
thickness,
|
170 |
lineType)
|
171 |
-
offset_h =
|
172 |
-
im[offset_h:h+offset_h, :w, :] = (.4 * im[offset_h:h+offset_h, :w, :] + .6 * fram).astype(np.uint8)
|
173 |
-
|
174 |
cv2.imwrite('_tmp_banner.png', im)
|
175 |
-
OUT_FILE =
|
176 |
print(f'{OUT_FILE=}\n')
|
177 |
subprocess.run(
|
178 |
[
|
179 |
"python",
|
180 |
"tts.py",
|
181 |
-
"--text", PIC_DIR +
|
182 |
'--image', '_tmp_banner.png',
|
183 |
-
|
184 |
-
|
185 |
-
'--voice', _voice_,
|
186 |
'--out_file', OUT_FILE, # save to correct location is handled in client
|
187 |
])
|
|
|
46 |
'01_Schick_AII840_001.jpg', # image
|
47 |
'01_Schick_AII840_001.txt', # text
|
48 |
'Statue in shire hill on autumn beach.', # audiocraft
|
49 |
+
'Gottlieb Schick 1802 - Bildnis der Heinrike Dannecker', # cv2 puttext title
|
50 |
'en_US/m-ailabs_low#mary_ann',
|
51 |
],
|
52 |
# 2
|
|
|
54 |
'02_Constable_AI555_001.jpg',
|
55 |
'02_Constable_AI555_001.txt',
|
56 |
'Meadows country farm village in sight',
|
57 |
+
'John Constable 1804 - Dorf An Dem Flusse Stour',
|
58 |
'en_US/m-ailabs_low#mary_ann',
|
59 |
],
|
60 |
# 3
|
|
|
62 |
'03_Schinkel_WS200-002.jpg',
|
63 |
'03_Schinkel_WS200-002.txt',
|
64 |
'Arriving at the shore on horses',
|
65 |
+
'Karl Friedrich Schinkel 1815 - Gotische Kirche Auf Einem Felsen Am Meer',
|
66 |
'en_US/m-ailabs_low#mary_ann',
|
67 |
],
|
68 |
#
|
|
|
70 |
'04_Friedrich_FV317_001.jpg',
|
71 |
'04_Friedrich_FV317_001.txt',
|
72 |
'Land steppes',
|
73 |
+
'Friedrich Caspar David 1824 - Der Watzmann',
|
74 |
'en_US/m-ailabs_low#mary_ann',
|
75 |
],
|
76 |
#
|
|
|
78 |
'05_Blechen_FV40_001.jpg',
|
79 |
'05_Blechen_FV40_001.txt',
|
80 |
'fjords',
|
81 |
+
'Carl Blechen 1829 - Unwetter In Der Romischen Campagna',
|
82 |
'en_US/m-ailabs_low#mary_ann',
|
83 |
],
|
84 |
# 6
|
|
|
86 |
'06_Menzel_AI900_001.jpg',
|
87 |
'06_Menzel_AI900_001.txt',
|
88 |
'Olive trees in Seville',
|
89 |
+
'Adolph Menzel 1846 - Bauplatz mit Weiden',
|
90 |
'en_US/m-ailabs_low#mary_ann',
|
91 |
],
|
92 |
# 7
|
|
|
94 |
'07_Courbet_AI967_001.jpg',
|
95 |
'07_Courbet_AI967_001.txt',
|
96 |
'Storm at the strand of waves Tsunami',
|
97 |
+
'Gustave Courbet 1870 - Die Welle',
|
98 |
'en_US/m-ailabs_low#mary_ann',
|
99 |
],
|
100 |
# 8
|
|
|
102 |
'08_Monet_AI1013_001.jpg',
|
103 |
'08_Monet_AI1013_001.txt',
|
104 |
'Mai flowers blossom picnic',
|
105 |
+
'Claude Monet 1874 - Sommertag',
|
106 |
'en_US/m-ailabs_low#mary_ann',
|
107 |
],
|
108 |
# 9
|
|
|
110 |
'09_Blechen_AII823_001.jpg',
|
111 |
'09_Blechen_AII823_001.txt',
|
112 |
'Cascade in Africa',
|
113 |
+
'Carl Blechen 1832 - Wasserfälle Bei Tivoli',
|
114 |
'en_US/m-ailabs_low#mary_ann',
|
115 |
],
|
116 |
# 10
|
|
|
118 |
'10_Boecklin_967648_NG2-80_001_rsz.jpg',
|
119 |
'10_Boecklin_967648_NG2-80_001.txt',
|
120 |
'Hades ades at it sisland',
|
121 |
+
'Arnold Böcklin 1883 - Toteninsel',
|
122 |
'en_US/m-ailabs_low#mary_ann',
|
123 |
],
|
124 |
# 11
|
|
|
126 |
'11_Liebermann_NG4-94_001.jpg',
|
127 |
'11_Liebermann_NG4-94_001.txt',
|
128 |
'Tavern at the waterfront',
|
129 |
+
'Max Tiebermann 1916 - Gartenlokal An Der Havel. Nikolskoe',
|
130 |
'en_US/m-ailabs_low#mary_ann',
|
131 |
],
|
132 |
# 12
|
|
|
134 |
'12_Slevogt_AII1022_001.jpg',
|
135 |
'12_Slevogt_AII1022_001.txt',
|
136 |
'toy sailing yachts pool',
|
137 |
+
'Max Slevogt 1905 - Segelboote Auf Der Alster Am Abend',
|
138 |
'en_US/m-ailabs_low#mary_ann',
|
139 |
],
|
140 |
]
|
|
|
146 |
# SILENT CLIP
|
147 |
|
148 |
|
149 |
+
for img, text, scene, title, voice in DESCRIPTIONS[:20]:
|
150 |
+
|
151 |
+
|
152 |
|
153 |
+
# TITLE BANNER
|
154 |
+
|
155 |
+
im = cv2.imread(PIC_DIR + img) # IMG must have EVEN shape
|
156 |
h, w, _ = im.shape
|
157 |
im = im[(h%2):, (w%2):, :] # assure even image
|
158 |
print(im.shape, "GLOBAL IM\n\n\n\n")
|
|
|
164 |
fontColor = (255, 255, 255)
|
165 |
thickness = 4
|
166 |
lineType = 2
|
167 |
+
cv2.putText(fram, title,
|
168 |
bottomLeftCornerOfText,
|
169 |
font,
|
170 |
fontScale,
|
171 |
fontColor,
|
172 |
thickness,
|
173 |
lineType)
|
174 |
+
offset_h = 0
|
175 |
+
im[offset_h:h+offset_h, :w, :] = (.4 * im[offset_h:h+offset_h, :w, :] + .6 * fram).astype(np.uint8)
|
176 |
+
|
177 |
cv2.imwrite('_tmp_banner.png', im)
|
178 |
+
OUT_FILE = img.split('/')[-1].replace('.','__') + '.mp4' # assets / -1
|
179 |
print(f'{OUT_FILE=}\n')
|
180 |
subprocess.run(
|
181 |
[
|
182 |
"python",
|
183 |
"tts.py",
|
184 |
+
"--text", PIC_DIR + text,
|
185 |
'--image', '_tmp_banner.png',
|
186 |
+
'--scene', scene,
|
187 |
+
'--voice', voice,
|
|
|
188 |
'--out_file', OUT_FILE, # save to correct location is handled in client
|
189 |
])
|