antonelli commited on
Commit
8a709b9
·
1 Parent(s): 5ab10e4
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -37,10 +37,12 @@ def send_to_deepgram(audio_file_path):
37
  audio_data = audio_file.read()
38
 
39
  response = requests.post(endpoint, headers=headers, data=audio_data)
40
- print(response.json()) # Print the response here
41
- return response.json()
 
42
 
43
  def analyze_audio(audio_file_path):
 
44
  last_frame = None
45
  y, sr = librosa.load(audio_file_path)
46
  chunk_length = 10 * sr # 10 seconds
@@ -55,6 +57,7 @@ def analyze_audio(audio_file_path):
55
  moods.append(mood)
56
 
57
  for i, start in enumerate(range(0, len(y), chunk_length)):
 
58
  chunk = y[start:start + chunk_length]
59
  lyrics_summary = lyrics_chunks[i] if i < len(lyrics_chunks) else 'Instrumental or silence'
60
  previous_mood = moods[i - 1] if i > 0 else None
@@ -63,8 +66,11 @@ def analyze_audio(audio_file_path):
63
  _, tempo, chroma_mean, spectral_contrast_mean, zero_crossing_rate_mean, mfcc_mean = analyze_chunk(chunk)
64
  prompt = generate_video_prompt(previous_mood, current_mood, next_mood, tempo, chroma_mean, spectral_contrast_mean, zero_crossing_rate_mean, mfcc_mean, lyrics_summary)
65
  description = f"Chunk starting at {start / sr} seconds:<br>Mood: {current_mood}<br>Video Prompt: {prompt}<br><br>"
 
66
  video = generate_video(prompt, last_frame)
67
  last_frame = extract_last_frame(video)
 
 
68
 
69
  # Yield the result for this chunk
70
  yield (description, video)
 
37
  audio_data = audio_file.read()
38
 
39
  response = requests.post(endpoint, headers=headers, data=audio_data)
40
+ response_json = response.json()
41
+ print("Deepgram API Response:", response_json) # Log the response
42
+ return response_json
43
 
44
  def analyze_audio(audio_file_path):
45
+ print("Analyzing audio...") # Log start of analysis
46
  last_frame = None
47
  y, sr = librosa.load(audio_file_path)
48
  chunk_length = 10 * sr # 10 seconds
 
57
  moods.append(mood)
58
 
59
  for i, start in enumerate(range(0, len(y), chunk_length)):
60
+ print(f"Analyzing chunk {i + 1}...") # Log chunk analysis
61
  chunk = y[start:start + chunk_length]
62
  lyrics_summary = lyrics_chunks[i] if i < len(lyrics_chunks) else 'Instrumental or silence'
63
  previous_mood = moods[i - 1] if i > 0 else None
 
66
  _, tempo, chroma_mean, spectral_contrast_mean, zero_crossing_rate_mean, mfcc_mean = analyze_chunk(chunk)
67
  prompt = generate_video_prompt(previous_mood, current_mood, next_mood, tempo, chroma_mean, spectral_contrast_mean, zero_crossing_rate_mean, mfcc_mean, lyrics_summary)
68
  description = f"Chunk starting at {start / sr} seconds:<br>Mood: {current_mood}<br>Video Prompt: {prompt}<br><br>"
69
+ print(f"Generating video for chunk {i + 1}...")
70
  video = generate_video(prompt, last_frame)
71
  last_frame = extract_last_frame(video)
72
+ print(f"Description for chunk {i + 1}: {description}")
73
+ print(f"Video for chunk {i + 1}: {video}")
74
 
75
  # Yield the result for this chunk
76
  yield (description, video)