manasch commited on
Commit
bd36795
·
verified ·
1 Parent(s): beb58d8

add instrument as inputs

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from pathlib import Path
2
 
3
  import numpy as np
@@ -24,7 +25,7 @@ class AudioPalette:
24
  "Slow": "low"
25
  }
26
 
27
- def generate(self, input_image: PIL.Image.Image, ngrok_endpoint: str):
28
  pace = self.pace_model.predict(input_image)
29
  print("Pace Prediction Done")
30
 
@@ -33,7 +34,13 @@ class AudioPalette:
33
 
34
  generated_text = generated_text if generated_text is not None else ""
35
  # prompt = f"Generate a soundtrack for {generated_text} with {pace} beats and the instrument of choice is the guitar, High quality"
36
- prompt = f"A soundtrack for {generated_text} with {self.pace_map[pace]} beats per minute. High quality."
 
 
 
 
 
 
37
 
38
  audio_file = self.audio_generation.generate(prompt, ngrok_endpoint)
39
  print("Audio Generation Done")
@@ -54,6 +61,12 @@ def main():
54
  show_label=True,
55
  container=True
56
  ),
 
 
 
 
 
 
57
  gr.Textbox(
58
  lines=1,
59
  placeholder="ngrok endpoint",
@@ -72,7 +85,7 @@ def main():
72
  show_label=True,
73
  container=True,
74
  type="text",
75
- visible=True
76
  ),
77
  gr.Textbox(
78
  lines=1,
 
1
+ import typing
2
  from pathlib import Path
3
 
4
  import numpy as np
 
25
  "Slow": "low"
26
  }
27
 
28
+ def generate(self, input_image: PIL.Image.Image, instrument: typing.Union[str, None], ngrok_endpoint: str):
29
  pace = self.pace_model.predict(input_image)
30
  print("Pace Prediction Done")
31
 
 
34
 
35
  generated_text = generated_text if generated_text is not None else ""
36
  # prompt = f"Generate a soundtrack for {generated_text} with {pace} beats and the instrument of choice is the guitar, High quality"
37
+
38
+ if instrument is None:
39
+ prompt = f"A soundtrack for {generated_text} with {self.pace_map[pace]} beats per minute. High quality."
40
+ else:
41
+ prompt = f"A soundtrack for {generated_text} with {self.pace_map[pace]} beats per minute with a {instrument}. High quality."
42
+
43
+ print("Generated Prompt:", prompt)
44
 
45
  audio_file = self.audio_generation.generate(prompt, ngrok_endpoint)
46
  print("Audio Generation Done")
 
61
  show_label=True,
62
  container=True
63
  ),
64
+ gr.Radio(
65
+ choices=["Piano", "Drums", "Guitar", "Violin", "Flute"],
66
+ label="Instrument",
67
+ show_label=True,
68
+ container=True
69
+ ),
70
  gr.Textbox(
71
  lines=1,
72
  placeholder="ngrok endpoint",
 
85
  show_label=True,
86
  container=True,
87
  type="text",
88
+ visible=False
89
  ),
90
  gr.Textbox(
91
  lines=1,