youngtsai commited on
Commit
3ebeb3e
·
1 Parent(s): 4bd8415

with open(audio, "rb") as f:

Browse files
Files changed (1) hide show
  1. main.py +15 -16
main.py CHANGED
@@ -34,23 +34,22 @@ async def score_audio_plus(
34
  url = "https://api.elsanow.io/api/v1/score_audio_plus"
35
  headers = {"Authorization": f"ELSA {ELSA_API_TOKEN}"}
36
 
37
- # Read file content
38
- file_content = await audio.read()
39
-
40
- # Prepare files and data for POST request
41
- files = {
42
- 'audio_file': (audio.filename, file_content, audio.content_type)
43
- }
44
- data = {
45
- 'api_plan': api_plan,
46
- 'return_json': "true" if return_json else "false"
47
- }
48
-
49
- # Send POST request
50
- response = requests.post(url, files=files, data=data, headers=headers)
51
 
52
- print("====response===")
53
- print(response)
54
 
55
  if response.status_code == 200:
56
  # Successfully made the request
 
34
  url = "https://api.elsanow.io/api/v1/score_audio_plus"
35
  headers = {"Authorization": f"ELSA {ELSA_API_TOKEN}"}
36
 
37
+ # Read file content
38
+ with open(audio, "rb") as f:
39
+ files = {
40
+ 'audio_file': (os.path.basename(audio), f, 'audio/wav')
41
+ }
42
+ data = {
43
+ 'api_plan': api_plan,
44
+ 'return_json': "true" if return_json else "false"
45
+ }
46
+
47
+ # Send POST request
48
+ response = requests.post(url, files=files, data=data, headers=headers)
49
+
 
50
 
51
+ print("====response===")
52
+ print(response)
53
 
54
  if response.status_code == 200:
55
  # Successfully made the request