animikhaich commited on
Commit
99896f8
2 Parent(s): 5254bd1 ae68709

Merge branch 'web-app-dev' of github.com:animikhaich/VidTune into web-app-dev

Browse files
engine/audio_generator.py CHANGED
@@ -72,8 +72,14 @@ class GenerateAudio:
72
  prompts = self.prompts_sanity_check(prompts)
73
 
74
  try:
75
- self.model.set_generation_params(duration=duration)
76
- result = self.model.generate(prompts, progress=False)
 
 
 
 
 
 
77
  self.result = result.cpu().numpy().T
78
  self.result = self.result.transpose((2, 0, 1))
79
  self.sampling_rate = self.model.sample_rate
 
72
  prompts = self.prompts_sanity_check(prompts)
73
 
74
  try:
75
+ if duration <= 30:
76
+ self.model.set_generation_params(duration=duration)
77
+ result = self.model.generate(prompts, progress=False)
78
+ elif duration > 30:
79
+ self.model.set_generation_params(duration=30)
80
+ result = self.model.generate(prompts, progress=False)
81
+ self.model.set_generation_params(duration=duration)
82
+ result = self.model.generate_with_chroma(prompts, result, melody_sample_rate=self.sampling_rate, progress=False)
83
  self.result = result.cpu().numpy().T
84
  self.result = self.result.transpose((2, 0, 1))
85
  self.sampling_rate = self.model.sample_rate
engine/video_descriptor.py CHANGED
@@ -47,7 +47,7 @@ class DescribeVideo:
47
 
48
  logging.info(f"Initialized DescribeVideo with model: {self.model}")
49
 
50
- def describe_video(self, video_path):
51
  video_file = genai.upload_file(video_path)
52
  logging.info(f"Uploaded video: {video_path}")
53
 
@@ -58,9 +58,11 @@ class DescribeVideo:
58
  if video_file.state.name == "FAILED":
59
  logging.error(f"Failed to upload video: {video_file.state.name}")
60
  raise ValueError(f"Failed to upload video: {video_file.state.name}")
 
 
61
 
62
  response = self.mllm_model.generate_content(
63
- [video_file, "Explain what is happening in this video"],
64
  request_options={"timeout": 600},
65
  safety_settings=self.safety_settings,
66
  )
 
47
 
48
  logging.info(f"Initialized DescribeVideo with model: {self.model}")
49
 
50
+ def describe_video(self, video_path, genre, bpm, user_keywords):
51
  video_file = genai.upload_file(video_path)
52
  logging.info(f"Uploaded video: {video_path}")
53
 
 
58
  if video_file.state.name == "FAILED":
59
  logging.error(f"Failed to upload video: {video_file.state.name}")
60
  raise ValueError(f"Failed to upload video: {video_file.state.name}")
61
+
62
+ additional_keywords = ", ".join([genre, user_keywords, bpm]) + "bpm"
63
 
64
  response = self.mllm_model.generate_content(
65
+ [video_file, f"Explain what is happening in this video. The following keywords are provided by the user for generating the music prompt: {additional_keywords}"],
66
  request_options={"timeout": 600},
67
  safety_settings=self.safety_settings,
68
  )