Adityadn commited on
Commit
1ca9b39
·
verified ·
1 Parent(s): be50ddb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -24
app.py CHANGED
@@ -30,41 +30,18 @@ def identify_audio(file):
30
 
31
  results = []
32
 
33
- # Process audio in 10-second chunks
34
- for i in range(0, duration_ms // 1000, 10):
35
- res = acr.recognize_by_file(file_path, i, 10)
36
- results.append(f"**Time {i}s**: {res.strip()}")
37
-
38
  # Full recognition result
39
  full_result = acr.recognize_by_file(file_path, 0)
40
-
41
- # Recognize using file buffer
42
- with open(file_path, 'rb') as f:
43
- buf = f.read()
44
- buffer_result = acr.recognize_by_filebuffer(buf, 0)
45
-
46
- # Convert JSON results to dictionary
47
  full_result_dict = json.loads(full_result)
48
- buffer_result_dict = json.loads(buffer_result)
49
-
50
  # Format the results as markdown
51
  result_md = f"""
52
- ### **Partial Results**:
53
- {'\\n'.join(results)}
54
-
55
  ### **Full Result**:
56
  - **Track**: {full_result_dict['metadata']['music'][0]['title']}
57
  - **Artist**: {full_result_dict['metadata']['music'][0]['artists'][0]['name']}
58
  - **Album**: {full_result_dict['metadata']['music'][0]['album']['name']}
59
  - **Release Date**: {full_result_dict['metadata']['music'][0]['release_date']}
60
  - **Score**: {full_result_dict['metadata']['music'][0]['score']}%
61
-
62
- ### **Buffer Result**:
63
- - **Track**: {buffer_result_dict['metadata']['music'][0]['title']}
64
- - **Artist**: {buffer_result_dict['metadata']['music'][0]['artists'][0]['name']}
65
- - **Album**: {buffer_result_dict['metadata']['music'][0]['album']['name']}
66
- - **Release Date**: {buffer_result_dict['metadata']['music'][0]['release_date']}
67
- - **Score**: {buffer_result_dict['metadata']['music'][0]['score']}%
68
  """
69
 
70
  return gr.Markdown(result_md)
 
30
 
31
  results = []
32
 
 
 
 
 
 
33
  # Full recognition result
34
  full_result = acr.recognize_by_file(file_path, 0)
 
 
 
 
 
 
 
35
  full_result_dict = json.loads(full_result)
36
+
 
37
  # Format the results as markdown
38
  result_md = f"""
 
 
 
39
  ### **Full Result**:
40
  - **Track**: {full_result_dict['metadata']['music'][0]['title']}
41
  - **Artist**: {full_result_dict['metadata']['music'][0]['artists'][0]['name']}
42
  - **Album**: {full_result_dict['metadata']['music'][0]['album']['name']}
43
  - **Release Date**: {full_result_dict['metadata']['music'][0]['release_date']}
44
  - **Score**: {full_result_dict['metadata']['music'][0]['score']}%
 
 
 
 
 
 
 
45
  """
46
 
47
  return gr.Markdown(result_md)