keivalya commited on
Commit
8570956
·
verified ·
1 Parent(s): f55de23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -3,6 +3,7 @@ from gradio.themes import Soft
3
  import os
4
  # from dotenv import load_dotenv
5
  from transcript import transcribe_audio # Import the transcription function
 
6
  import numpy as np
7
  import requests
8
  from scipy.io.wavfile import write
@@ -60,17 +61,26 @@ def analyze_song(mp3_file):
60
  genre = ", ".join(genre_list)
61
  image_url = result.json()['result']['spotify']['album']['images'][0]['url']
62
  else:
63
- artist, title, genre, image_url = None, None, None, None
64
-
 
 
 
 
 
 
 
65
  # Placeholder for song analysis logic
66
- # title = "Sample Title"
67
- # artist = "Sample Artist"
68
- # genre = "Sample Genre"
69
- instrumentation = "Sample Instrumentation"
70
  lyrics = transcription # Use the transcription as lyrics
71
- tempo_key = "Sample Tempo/Key"
 
 
 
 
 
72
  # history = "History"
73
- history = song_history(title)
74
  return title, artist, genre, instrumentation, lyrics, tempo_key, history, image_url # Return the mp3 file for replay
75
 
76
  # Custom CSS to set a fun musical theme image as background
 
3
  import os
4
  # from dotenv import load_dotenv
5
  from transcript import transcribe_audio # Import the transcription function
6
+ from metadata import info
7
  import numpy as np
8
  import requests
9
  from scipy.io.wavfile import write
 
61
  genre = ", ".join(genre_list)
62
  image_url = result.json()['result']['spotify']['album']['images'][0]['url']
63
  else:
64
+ image_url = None
65
+ genre = None
66
+ genius_response = get_song_info_from_lyrics(transcription)
67
+ title = genius_response["title"]
68
+ artist = genius_response["artist"]
69
+ song_data = json.loads(info(title, artist))
70
+ if (genre == None):
71
+ genre = song_data["genre"]
72
+ # print(song_data)
73
  # Placeholder for song analysis logic
74
+ instrumentation = str(song_data["instrumentation"])[1:-2].replace('\'', '')
 
 
 
75
  lyrics = transcription # Use the transcription as lyrics
76
+ tempo_key = song_data["tempo"] + ", " + song_data["key"]
77
+ history = song_data["historical"]
78
+
79
+ # instrumentation = "Sample Instrumentation"
80
+ # lyrics = transcription # Use the transcription as lyrics
81
+ # tempo_key = "Sample Tempo/Key"
82
  # history = "History"
83
+ # history = song_history(title)
84
  return title, artist, genre, instrumentation, lyrics, tempo_key, history, image_url # Return the mp3 file for replay
85
 
86
  # Custom CSS to set a fun musical theme image as background