Vihang28 commited on
Commit
590d051
1 Parent(s): b873d24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -27
app.py CHANGED
@@ -50,33 +50,34 @@ def api_calling(audio_file, prompt, api_key):
50
  audio_text = record_text(audio_file,api_key)
51
  if len(prompt) == 0:
52
  prompt = "Apply proper punctuations, upper case and lower case to the provided text."
53
-
54
- headers = {
55
- "Content-Type": "application/json",
56
- "Authorization": f"Bearer {api_key}"
57
- }
58
- payload = {
59
- "model": "gpt-3.5-turbo",
60
- "messages": [
61
- {
62
- "role": "user",
63
- "content": [
64
- {
65
- "type": "text",
66
- "text": prompt
67
- },
68
- {
69
- "type": "text",
70
- "text": audio_text
71
- }
72
- ]
73
- }
74
- ],
75
- # "max_tokens": 1500
76
- }
77
- response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
78
- audio_text_res = response.json()
79
- return audio_text_res["choices"][0]["message"]["content"]
 
80
 
81
 
82
 
 
50
  audio_text = record_text(audio_file,api_key)
51
  if len(prompt) == 0:
52
  prompt = "Apply proper punctuations, upper case and lower case to the provided text."
53
+ return audio_text
54
+ else:
55
+ headers = {
56
+ "Content-Type": "application/json",
57
+ "Authorization": f"Bearer {api_key}"
58
+ }
59
+ payload = {
60
+ "model": "gpt-3.5-turbo",
61
+ "messages": [
62
+ {
63
+ "role": "user",
64
+ "content": [
65
+ {
66
+ "type": "text",
67
+ "text": prompt
68
+ },
69
+ {
70
+ "type": "text",
71
+ "text": audio_text
72
+ }
73
+ ]
74
+ }
75
+ ],
76
+ "max_tokens": 1000
77
+ }
78
+ response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
79
+ audio_text_res = response.json()
80
+ return audio_text_res["choices"][0]["message"]["content"]
81
 
82
 
83