janasumit2911 commited on
Commit
d997fc9
1 Parent(s): d6a4b9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -3,14 +3,14 @@ import whisper
3
  import requests
4
  large_v3 = whisper.load_model("large-v3")
5
 
6
- def send_results_to_api(data, result_url):
7
- headers = {"Content-Type":"application/json"}
8
- response = requests.post(result_url, json= data, headers=headers)
9
 
10
- if response.status_code == 200:
11
- return response.json()
12
- else:
13
- return {"error": f"Failed to send results to API: {response.status_code}"}
14
 
15
  def process_audio(params):
16
  try:
@@ -18,9 +18,9 @@ def process_audio(params):
18
  except json.JSONDecodeError as e:
19
  return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
20
 
21
- audio_files = params.get("audio_files", [])
22
- api = params.get("api","")
23
- job_id = params.get("job_id","")
24
 
25
  solutions=[]
26
 
@@ -29,17 +29,17 @@ def process_audio(params):
29
  text = result_large['text']
30
 
31
  answer_dict = {}
32
- answer_dict.update({'file_name':audio, 'text':text})
33
  solutions.append(answer_dict)
34
 
35
- result_url = f"{api}/{job_id}"
36
  # send_results_to_api(solutions, result_url)
37
 
38
- return json.dumps({"solutions":solutions}, indent=4)
39
 
40
  import gradio as gr
41
  inputt = gr.Textbox(label = "Parameter in json format Eg. {'audio_files':['file1.mp3','file2.wav'], 'api':'https://api.example.com', 'job_id':'1001'}")
42
  outputt = gr.JSON()
43
 
44
  application = gr.Interface(fn=process_audio, inputs = inputt, outputs= outputt, title="Hindi 2 Hindi Audio transcription with API Intergration")
45
- application.launch(share=True)
 
3
  import requests
4
  large_v3 = whisper.load_model("large-v3")
5
 
6
+ # def send_results_to_api(data, result_url):
7
+ # headers = {"Content-Type":"application/json"}
8
+ # response = requests.post(result_url, json= data, headers=headers)
9
 
10
+ # if response.status_code == 200:
11
+ # return response.json()
12
+ # else:
13
+ # return {"error": f"Failed to send results to API: {response.status_code}"}
14
 
15
  def process_audio(params):
16
  try:
 
18
  except json.JSONDecodeError as e:
19
  return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
20
 
21
+ audio_files = params.get("urls", [])
22
+ # api = params.get("api","")
23
+ # job_id = params.get("job_id","")
24
 
25
  solutions=[]
26
 
 
29
  text = result_large['text']
30
 
31
  answer_dict = {}
32
+ answer_dict.update({'url':audio, 'answer':text})
33
  solutions.append(answer_dict)
34
 
35
+ # result_url = f"{api}/{job_id}"
36
  # send_results_to_api(solutions, result_url)
37
 
38
+ return json.dumps({"solutions":solutions})
39
 
40
  import gradio as gr
41
  inputt = gr.Textbox(label = "Parameter in json format Eg. {'audio_files':['file1.mp3','file2.wav'], 'api':'https://api.example.com', 'job_id':'1001'}")
42
  outputt = gr.JSON()
43
 
44
  application = gr.Interface(fn=process_audio, inputs = inputt, outputs= outputt, title="Hindi 2 Hindi Audio transcription with API Intergration")
45
+ application.launch()