Adityadn commited on
Commit
d8ff09c
·
verified ·
1 Parent(s): 1b78952

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -43,21 +43,29 @@ def identify_audio(file):
43
  buf = f.read()
44
  buffer_result = acr.recognize_by_filebuffer(buf, 0)
45
 
46
- # Convert results into Markdown format
47
- result_md = """
48
- ### Partial Results:
49
- {}
50
-
51
- ### Full Result:
52
- ```json
53
- {}
54
- ```
55
 
56
- ### Buffer Result:
57
- ```json
58
- {}
59
- ```
60
- """.format("\n".join(results), json.dumps(json.loads(full_result), indent=4), json.dumps(json.loads(buffer_result), indent=4))
 
 
 
 
 
 
 
 
 
61
 
62
  return gr.Markdown(result_md)
63
 
 
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)
71