Adityadn commited on
Commit
568f753
·
verified ·
1 Parent(s): 4f55526

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -31,7 +31,7 @@ def identify_audio(file):
31
  # Process audio in 10-second chunks
32
  for i in range(0, duration_ms // 1000, 10):
33
  res = acr.recognize_by_file(file_path, i, 10)
34
- results.append(f"Time {i}s: {res.strip()}")
35
 
36
  # Full recognition result
37
  full_result = acr.recognize_by_file(file_path, 0)
@@ -47,7 +47,10 @@ def identify_audio(file):
47
  album = music_data.get('album', {}).get('name', 'Unknown Album')
48
  release_date = music_data.get('release_date', 'Unknown Release Date')
49
 
50
- full_result_text = f"Title: {title}\nArtists: {artists}\nAlbum: {album}\nRelease Date: {release_date}"
 
 
 
51
  else:
52
  full_result_text = "No music metadata found in the result."
53
 
@@ -57,7 +60,7 @@ def identify_audio(file):
57
  buffer_result = acr.recognize_by_filebuffer(buf, 0)
58
 
59
  return {
60
- "Partial Results": results,
61
  "Full Result": full_result_text,
62
  "Buffer Result": buffer_result
63
  }
@@ -66,7 +69,7 @@ def identify_audio(file):
66
  iface = gr.Interface(
67
  fn=identify_audio,
68
  inputs=gr.File(label="Upload Audio File"),
69
- outputs=gr.JSON(label="Audio Metadata"),
70
  title="Audio Search by File",
71
  description="Upload an audio file to identify it using ACRCloud."
72
  )
 
31
  # Process audio in 10-second chunks
32
  for i in range(0, duration_ms // 1000, 10):
33
  res = acr.recognize_by_file(file_path, i, 10)
34
+ results.append(f"**Time {i}s:** {res.strip()}")
35
 
36
  # Full recognition result
37
  full_result = acr.recognize_by_file(file_path, 0)
 
47
  album = music_data.get('album', {}).get('name', 'Unknown Album')
48
  release_date = music_data.get('release_date', 'Unknown Release Date')
49
 
50
+ full_result_text = f"### **Title**: {title}\n\n" \
51
+ f"**Artists**: {artists}\n\n" \
52
+ f"**Album**: {album}\n\n" \
53
+ f"**Release Date**: {release_date}\n"
54
  else:
55
  full_result_text = "No music metadata found in the result."
56
 
 
60
  buffer_result = acr.recognize_by_filebuffer(buf, 0)
61
 
62
  return {
63
+ "Partial Results": "\n".join(results),
64
  "Full Result": full_result_text,
65
  "Buffer Result": buffer_result
66
  }
 
69
  iface = gr.Interface(
70
  fn=identify_audio,
71
  inputs=gr.File(label="Upload Audio File"),
72
+ outputs=gr.Markdown(label="Audio Metadata"), # Change output to Markdown
73
  title="Audio Search by File",
74
  description="Upload an audio file to identify it using ACRCloud."
75
  )