Dionyssos commited on
Commit
9bcbe02
1 Parent(s): 2e6c69d

berlin demo

Browse files
api.py CHANGED
@@ -16,14 +16,16 @@ from types import SimpleNamespace
16
  from flask import Flask, request, send_from_directory
17
  from flask_cors import CORS
18
  from moviepy.editor import *
19
- from audiocraft.audiogen import AudioGen, audio_write
20
  CACHE_DIR = 'flask_cache/'
21
- SOUNDSCAPE_DURATION = 6
22
  sound_generator = AudioGen.get_pretrained('facebook/audiogen-medium')
23
  sound_generator.set_generation_params(duration=SOUNDSCAPE_DURATION)
24
  print(f'{sound_generator.sample_rate=}')
25
  Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
26
 
 
 
27
 
28
  # SSH AGENT
29
  # eval $(ssh-agent -s)
@@ -43,6 +45,7 @@ def _shift(x):
43
  return x #* fade_in # silence this
44
 
45
  def overlay(x, scene=None):
 
46
  if scene is not None:
47
 
48
  # generate 4
@@ -51,7 +54,7 @@ def overlay(x, scene=None):
51
  [scene]
52
  )[0].detach().cpu().numpy()[0, :] for _ in range(1)]
53
 
54
- print([j.shape for j in back], len(back), 'BACK')
55
 
56
  # upsample to 24kHZ of StyleTTS
57
  print('Resampling')
@@ -78,7 +81,7 @@ def overlay(x, scene=None):
78
  back = _shift(back)
79
  print(f'\n====SOUND BACKGROUND SHAPE\n{back.shape=}',
80
  f'{np.abs(back.max())=}\n{x.shape=}')
81
- x = .9 * x + .1 * back[:len(x)]
82
  else:
83
  print('sound_background = None')
84
  return x
@@ -157,7 +160,7 @@ def serve_wav():
157
  voice=r.get('voice')[0],
158
  native=None if r.get('native') is None else CACHE_DIR + r.get('native')[0].replace("/",""),
159
  affective = r.get('affective')[0],
160
- scene=r.get('scene')[0]
161
  )
162
  # print('\n==RECOMPOSED as \n',request.data,request.form,'\n==')
163
 
 
16
  from flask import Flask, request, send_from_directory
17
  from flask_cors import CORS
18
  from moviepy.editor import *
19
+ from audiocraft.audiogen import AudioGen
20
  CACHE_DIR = 'flask_cache/'
21
+ SOUNDSCAPE_DURATION = 4.4
22
  sound_generator = AudioGen.get_pretrained('facebook/audiogen-medium')
23
  sound_generator.set_generation_params(duration=SOUNDSCAPE_DURATION)
24
  print(f'{sound_generator.sample_rate=}')
25
  Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
26
 
27
+ import nltk
28
+ nltk.download('punkt')
29
 
30
  # SSH AGENT
31
  # eval $(ssh-agent -s)
 
45
  return x #* fade_in # silence this
46
 
47
  def overlay(x, scene=None):
48
+ print(f'{scene=} OVERLAY')
49
  if scene is not None:
50
 
51
  # generate 4
 
54
  [scene]
55
  )[0].detach().cpu().numpy()[0, :] for _ in range(1)]
56
 
57
+ #print([j.shape for j in back], len(back), 'BACK')
58
 
59
  # upsample to 24kHZ of StyleTTS
60
  print('Resampling')
 
81
  back = _shift(back)
82
  print(f'\n====SOUND BACKGROUND SHAPE\n{back.shape=}',
83
  f'{np.abs(back.max())=}\n{x.shape=}')
84
+ x = .1 * x + .9 * back[:len(x)]
85
  else:
86
  print('sound_background = None')
87
  return x
 
160
  voice=r.get('voice')[0],
161
  native=None if r.get('native') is None else CACHE_DIR + r.get('native')[0].replace("/",""),
162
  affective = r.get('affective')[0],
163
+ scene=r.get('scene')[0] if r.get('scene') is not None else None
164
  )
165
  # print('\n==RECOMPOSED as \n',request.data,request.form,'\n==')
166
 
berlin_30_Oct_2024/lamma400b_children.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Meet Georg Gisze, a super cool and rich merchant who lived a long time ago. Look at him sitting in his awesome office, wearing a bright red shirt and a fancy black cape - he looks like a superhero! Check out all the amazing things around him, like the colorful carpet, the shiny watch, and the beautiful glass vase. And have you noticed all the letters on the wall? Georg was a very busy man, and these letters show just how much work he had to do. Can you imagine what it would be like to be a merchant like Georg, traveling the world and collecting cool things? Maybe one day you'll have an amazing office like his too!
berlin_30_Oct_2024/lamma400b_professionals.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ Portrait of Georg Gisze, a paradigmatic exemplar of 16th-century mercantile
2
+ portraiture, presents a sumptuously attired merchant amidst the accoutrements of
3
+ his profession. The subject's opulent red silk sleeves and voluminous black cape,
4
+ complemented by a beret, underscore his elevated social standing. The
5
+ fastidiously rendered setting, replete with an exquisite Anatolian carpet and a
6
+ delicate Venetian glass vase, serves as a visual testament to Gisze's considerable
7
+ wealth and mercantile prowess. The incorporation of epistolary documents on the
8
+ wall, meanwhile, provides a narrative anchor, emphasizing the subject's vocational identity as a merchant. Through the masterful deployment of symbolic objects and meticulous attention to detail, the artist crafts a nuanced portrait that
9
+ not only captures the likeness of the sitter but also provides a fascinating glimpse
10
+ into the rarefied world of Renaissance commerce.”
berlin_30_Oct_2024/lamma400b_visualimpair.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ A portrait of Georg Gisze, a wealthy merchant, sitting in his office.
2
+ Georg Gisze is positioned centrally in the painting, seated in a three-quarter view.
3
+ He wears a black cape draped over his right shoulder, with vibrant red silk sleeves visible underneath. His facial expression appears calm focused. To his left, a delicate glass vase sits on a nearby shelf while a pocket watch lies
4
+ open on the table in front of him. The table is covered with a patterned carpet that adds a pop of color to the scene.
5
+ The walls behind Georg Gisze are adorned with numerous letters, some of which are folded, while others are open and appear to be in the process of being written. These letters serve as a testament to his profession as a merchant. The overall atmosphere of the painting is one of quiet contemplation, inviting the viewer to step into the serene and organized world of Georg Gisze's office.
berlin_30_Oct_2024/lamma70b_children.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Meet Georg Gisze, a
2
+ super cool and rich
3
+ merchant from a long
4
+ time ago. Look at him
5
+ sitting in his fancy
6
+ office, wearing a
7
+ bright red shirt and a
8
+ big, fancy black cape.
9
+ Can you spot all the
10
+ awesome things around him? There's a
11
+ colorful carpet on the
12
+ floor, a shiny watch on
13
+ the table, and a
14
+ beautiful glass vase.
15
+ And check out all the
16
+ letters on the wall -
17
+ Georg must have been
18
+ very busy with his
19
+ work, sending and
20
+ receiving messages
21
+ from all around the
22
+ world. What do you
23
+ think Georg's job was
24
+ like?”
berlin_30_Oct_2024/lamma70b_professionals.txt ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This exquisite oil on oak
2
+ panel portrait,
3
+ attributed to the
4
+ renowned German
5
+ artist Hans Holbein the
6
+ Younger, presents a
7
+ captivating
8
+ representation of Georg
9
+ Gisze, a prominent
10
+ Hanseatic merchant. Executed with
11
+ remarkable attention to
12
+ detail, the painting
13
+ showcases the
14
+ subject's opulent attire,
15
+ comprising crimson silk
16
+ sleeves and a
17
+ voluminous black cape,
18
+ adorned with a beret,
19
+ thereby underscoring
20
+ his elevated social
21
+ standing.
22
+ The meticulously
23
+ rendered setting,
24
+ replete with symbols of
25
+ Gisze's affluence and
26
+ mercantile prowess,
27
+ serves as a testament
28
+ to the artist's mastery
29
+ of still life composition.
30
+ The incorporation of an
31
+ Anatolian carpet, a
32
+ Venetian glass vase,
33
+ and a pocket watch not
34
+ only demonstrates the
35
+ subject's refined taste
36
+ but also alludes to the
37
+ burgeoning global trade
38
+ networks of the
39
+ Renaissance era.
40
+ Furthermore, the
41
+ presence of letters on
42
+ the wall, presumably
43
+ correspondence related
44
+ to Gisze's mercantile
45
+ activities, injects a
46
+ sense of dynamism into
47
+ the composition, while
48
+ simultaneously highlighting the
49
+ subject's profession
50
+ and the concomitant
51
+ responsibilities that
52
+ accompany it. Through
53
+ this portrait, Holbein
54
+ offers a nuanced
55
+ exploration of the
56
+ intricate relationships
57
+ between material
58
+ wealth, social status,
59
+ and personal identity,
60
+ thereby providing a
61
+ fascinating glimpse into
62
+ the rarefied world of
63
+ 16th-century mercantile
64
+ elites
berlin_30_Oct_2024/lamma70b_visualimpair.txt ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This 16th-century
2
+ portrait painting
3
+ depicts Georg Gisze,
4
+ a prosperous
5
+ merchant, seated in
6
+ his office. He is
7
+ dressed in attire that
8
+ reflects his wealth,
9
+ wearing vibrant red
10
+ silk sleeves and a black cape draped
11
+ over his shoulders.
12
+ The subject is
13
+ situated in a cluttered
14
+ yet organized
15
+ workspace,
16
+ surrounded by
17
+ various objects that
18
+ highlight his
19
+ profession and
20
+ interests. A richly
21
+ patterned carpet
22
+ covers the floor, while
23
+ a delicate glass vase
24
+ sits atop a nearby
25
+ surface, adding a
26
+ touch of elegance to
27
+ the space. A pocket
28
+ watch is also visible,
29
+ symbolizing the
30
+ importance of time in
31
+ Gisze's line of work.
32
+ The walls of the
33
+ office are adorned
34
+ with letters, which
35
+ serve as a testament
36
+ to Gisze's occupation
37
+ as a merchant. These
38
+ letters likely represent
39
+ correspondence with
40
+ business associates,
41
+ suppliers, or clients,
42
+ providing insight into
43
+ the merchant's daily
44
+ activities.
45
+ The overall
46
+ atmosphere of the
47
+ painting is one of refinement and
48
+ sophistication,
49
+ offering a glimpse
50
+ into the life of a
51
+ successful merchant
52
+ during this time
53
+ period.
berlin_30_Oct_2024/lamma8b_children.txt ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Hey kids, let's explore
2
+ this cool painting
3
+ together!
4
+ Look at the rich man,
5
+ Georg Gisze, sitting in
6
+ his office. He's
7
+ wearing a super cool
8
+ red shirt and a big,
9
+ fancy black cape. Can
10
+ you spot the colorful
11
+ carpet, the shiny
12
+ watch, and the
13
+ beautiful glass vase
14
+ around him?
15
+ Georg is a merchant,
16
+ which means he buys
17
+ and sells things.
18
+ That's why you see
19
+ lots of letters on the
20
+ wall - he's busy
21
+ working on his business!
22
+ What do you think
23
+ Georg is selling?
24
+ Maybe it's something
25
+ shiny, like the watch?
26
+ Or maybe it's
27
+ something colorful,
28
+ like the carpet?
29
+ Let's use our
30
+ imagination and see
31
+ what kind of
32
+ adventures Georg
33
+ might be having in his
34
+ office!
berlin_30_Oct_2024/lamma8b_professionals.txt ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This captivating halflength portrait,
2
+ attributed to the Dutch
3
+ master Hans Holbein
4
+ the Younger, presents a
5
+ visually striking,
6
+ representation of Georg
7
+ Gisze, a prominent
8
+ merchant, of the 16th
9
+ century. The subject is
10
+ depicted in a
11
+ sumptuous red silk, doublet, adorned with
12
+ voluminous black cape,
13
+ and a characteristic
14
+ beret, evoking an air, of
15
+ opulence and
16
+ refinement.
17
+ The meticulously
18
+ rendered background,
19
+ replete with an
20
+ intricately patterned Anatolian carpet, a
21
+ delicate Venetian glass
22
+ vase, and a precisioncrafted pocket watch,
23
+ serves as a testament
24
+ to Gisze's considerable
25
+ wealth and status. The
26
+ inclusion of letters on
27
+ the wall, referencing his
28
+ occupation as a
29
+ merchant, underscores
30
+ the subject's profession
31
+ and reinforces the
32
+ notion of his mercantile
33
+ pursuits.
34
+ Through this masterful
35
+ portrayal, Holbein the
36
+ Younger skillfully
37
+ captures the essence
38
+ of Gisze's person
39
+ imbuing the subject
40
+ with a sense of gravitas
41
+ and authority. The
42
+ painting's masterful
43
+ execution,
44
+ characterized by its
45
+ precise attention, to
46
+ detail and nuanced use
47
+ of color, serves as a
48
+ testament to the artists
49
+ exceptional skill and
50
+ artistry.
berlin_30_Oct_2024/lamma8b_visualimpair.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Main Subject:
2
+ The painting features
3
+ a man, Georg Gisze,
4
+ seated in his office.
5
+ He is dressed in a
6
+ distinctive outfit,
7
+ which includes red
8
+ silk sleeves and a
9
+ black cape. This attire
10
+ suggests his wealth
11
+ and status as a
12
+ merchant.
13
+ Background:
14
+ The room is filled with
15
+ various objects that
16
+ reflect Georg's
17
+ profession. You'll
18
+ notice a patterned
19
+ carpet beneath his
20
+ feet, which adds a
21
+ sense of luxury to the
22
+ space. On a nearby table, a delicate glass
23
+ vase sits elegantly,
24
+ showcasing the
25
+ craftsmanship of the
26
+ era. A pocket watch
27
+ hangs from his waist,
28
+ symbolizing the
29
+ importance of
30
+ timekeeping in
31
+ business.
32
+ Visual Elements:
33
+ The walls of the
34
+ office are adorned
35
+ with letters, which are
36
+ a testament to
37
+ Georg's work as a
38
+ merchant. These
39
+ letters likely contain
40
+ important business
41
+ correspondence,
42
+ highlighting his role in
43
+ the trade.
44
+ Additional Details:
45
+ As you imagine this
46
+ scene, consider the
47
+ atmosphere of a 16thcentury merchant's
48
+ office. The painting
49
+ invites you to step
50
+ into Georg's world,
51
+ where commerce,
52
+ and the values of his
53
+ time.
54
+ Accessibility
55
+ Features:
56
+ This description is
57
+ designed to be
58
+ accessible to visually impaired individuals.
59
+ The text is structured
60
+ to provide a clear
61
+ understanding of the
62
+ image, with a focus
63
+ on the main subject,
64
+ background, and
65
+ visual elements.
berlin_demo.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # make berlin wavs
2
+ import subprocess
3
+
4
+ BERLIN_DIR = 'berlin_30_Oct_2024/'
5
+
6
+ pairs = [
7
+ ['en_US/hifi-tts_low#9017', 'lamma8b_children.txt', False],
8
+ ['en_US/hifi-tts_low#9017' , 'lamma70b_children.txt', False],
9
+ ['en_US/hifi-tts_low#9017' , 'lamma400b_children.txt', False],
10
+ ['en_US/cmu-arctic_low#jmk', 'lamma8b_professionals.txt', True],
11
+ ['en_US/cmu-arctic_low#jmk', 'lamma70b_professionals.txt', True],
12
+ ['en_US/cmu-arctic_low#jmk', 'lamma400b_professionals.txt', True],
13
+ ['en_US/cmu-arctic_low#eey' , 'lamma70b_visualimpair.txt', True],
14
+ ['en_US/cmu-arctic_low#eey' , 'lamma8b_visualimpair.txt', True],
15
+ ['en_US/cmu-arctic_low#eey' , 'lamma400b_visualimpair.txt', True],
16
+ ]
17
+
18
+ for vox, text_file, affect in pairs:
19
+ print(vox, text_file)
20
+ subprocess.run(
21
+ [
22
+ "python",
23
+ "tts.py",
24
+ "--text", BERLIN_DIR + text_file,
25
+ # "--affect",
26
+ #'--image', '_tmp_banner.png',
27
+ # '--scene', 'calm sounds of castle',
28
+ '--voice', vox,
29
+ '--out_file', text_file[:-4], # save to correct location is handled in client
30
+ ])
31
+
demo.py CHANGED
@@ -7,7 +7,7 @@ print('\n\n\n\n___________________')
7
  txt = 'dogs in street'
8
 
9
  sound_generator = AudioGen.get_pretrained('facebook/audiogen-medium')
10
- sound_generator.set_generation_params(duration=1.7) # why is generating so long at 14 seconds
11
 
12
  x = sound_generator.generate([txt])[0].detach().cpu().numpy()[0, :]
13
  x /= np.abs(x).max() + 1e-7
 
7
  txt = 'dogs in street'
8
 
9
  sound_generator = AudioGen.get_pretrained('facebook/audiogen-medium')
10
+ sound_generator.set_generation_params(duration=.7) # why is generating so long at 14 seconds
11
 
12
  x = sound_generator.generate([txt])[0].detach().cpu().numpy()[0, :]
13
  x /= np.abs(x).max() + 1e-7
tts.py CHANGED
@@ -3,6 +3,8 @@ import numpy as np
3
  import argparse
4
  import os
5
  import requests
 
 
6
 
7
  # SSH AGENT
8
  # eval $(ssh-agent -s)
@@ -71,7 +73,7 @@ def command_line_args():
71
  '--scene',
72
  help='Sound scene description.',
73
  type=str,
74
- default='calm background sounds of a castle'
75
  )
76
  return parser
77
 
@@ -148,7 +150,7 @@ def cli():
148
 
149
  with open(
150
  # args.out_file is not send to server - server writes tmp - copied by client
151
- args.out_file + '.' + response.headers['suffix-file-type'].split('.')[-1],
152
  'wb'
153
  ) as f:
154
  f.write(response.content)
 
3
  import argparse
4
  import os
5
  import requests
6
+ from pathlib import Path
7
+ Path('out/').mkdir(parents=True, exist_ok=True)
8
 
9
  # SSH AGENT
10
  # eval $(ssh-agent -s)
 
73
  '--scene',
74
  help='Sound scene description.',
75
  type=str,
76
+ default=None, #'calm background sounds of a castle'
77
  )
78
  return parser
79
 
 
150
 
151
  with open(
152
  # args.out_file is not send to server - server writes tmp - copied by client
153
+ './out/' + args.out_file + '.' + response.headers['suffix-file-type'].split('.')[-1],
154
  'wb'
155
  ) as f:
156
  f.write(response.content)