keivalya commited on
Commit
6113e88
·
verified ·
1 Parent(s): 37d3a38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -25
app.py CHANGED
@@ -1,10 +1,19 @@
1
- import numpy as np
2
  import gradio as gr
3
- import requests
4
  import os
 
 
 
 
5
  from scipy.io.wavfile import write
6
 
7
- def main_function(audio):
 
 
 
 
 
 
8
  os.makedirs("out", exist_ok=True)
9
  write('test.wav', audio[0], audio[1])
10
  data = {
@@ -22,31 +31,43 @@ def main_function(audio):
22
  image_url = result.json()['result']['spotify']['album']['images'][0]['url']
23
  else:
24
  artist, title, genre, image_url = None, None, None, None
25
- return artist, title, genre, image_url
26
 
27
- def reverse_audio(audio):
28
- sr, data = audio
29
- return (sr, np.flipud(data))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- input_audio = gr.Audio(
32
- sources=["upload", "microphone"],
33
- waveform_options=gr.WaveformOptions(
34
- waveform_color="#01C6FF",
35
- waveform_progress_color="#0066B4",
36
- skip_length=2,
37
- show_controls=False,
38
- ),
39
- )
40
  demo = gr.Interface(
41
- fn=main_function,
42
- inputs=input_audio,
43
  outputs=[
44
- gr.Textbox(label="Artist", show_copy_button=True),
45
- gr.Textbox(label="Music", show_copy_button=True),
46
- gr.Textbox(label="Genre", show_copy_button=True),
47
- gr.Image(label="Cover")
48
- ]
 
 
 
 
 
 
 
49
  )
50
 
51
- if __name__ == "__main__":
52
- demo.launch()
 
 
1
  import gradio as gr
2
+ 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
9
 
10
+ # Load environment variables from .env file
11
+ # load_dotenv()
12
+
13
+ def analyze_song(mp3_file):
14
+ # Call the transcription function and get the transcription
15
+ transcription = transcribe_audio(mp3_file) # Pass the mp3 filename to transcript.py
16
+
17
  os.makedirs("out", exist_ok=True)
18
  write('test.wav', audio[0], audio[1])
19
  data = {
 
31
  image_url = result.json()['result']['spotify']['album']['images'][0]['url']
32
  else:
33
  artist, title, genre, image_url = None, None, None, None
 
34
 
35
+ # Placeholder for song analysis logic
36
+ # title = "Sample Title"
37
+ # artist = "Sample Artist"
38
+ # genre = "Sample Genre"
39
+ instrumentation = "Sample Instrumentation"
40
+ lyrics = transcription # Use the transcription as lyrics
41
+ tempo_key = "Sample Tempo/Key"
42
+ history = "History"
43
+ return title, artist, genre, instrumentation, lyrics, tempo_key, mp3_file, image_url, history # Return the mp3 file for replay
44
+
45
+ # Custom CSS to set a fun musical theme image as background
46
+ css = """
47
+ body {
48
+ background-image: url('https://example.com/path/to/your/musical-theme-image.jpg'); /* Replace with your image URL */
49
+ background-size: cover; /* Cover the entire background */
50
+ background-repeat: no-repeat; /* Prevent repeating the image */
51
+ background-position: center; /* Center the image */
52
+ }
53
+ """
54
 
 
 
 
 
 
 
 
 
 
55
  demo = gr.Interface(
56
+ fn=analyze_song,
57
+ inputs=gr.Audio(label="Record Audio", type="filepath", format="mp3"), # Record audio in MP3 format
58
  outputs=[
59
+ gr.Textbox(label="Title"),
60
+ gr.Textbox(label="Artist"),
61
+ gr.Textbox(label="Genre"),
62
+ gr.Textbox(label="Instrumentation"),
63
+ gr.Textbox(label="Lyrics"),
64
+ gr.Textbox(label="Tempo/Key"),
65
+ gr.Textbox(label="History"),
66
+ gr.Audio(label="Replay Recorded Audio") # Add an output for replaying the recorded audio
67
+ gr.Image(label="Cover") # Gives the Cover image
68
+ ],
69
+ theme=Soft(), # Apply the Soft theme
70
+ title="Concert Buddy 😄🎵🪩" # Apply custom CSS for background image
71
  )
72
 
73
+ demo.launch()