robertselvam commited on
Commit
1cda033
·
verified ·
1 Parent(s): 7e3c3cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -6,7 +6,7 @@ from langchain_openai import AzureChatOpenAI
6
  from pypdf import PdfReader
7
  import os
8
  import gradio as gr
9
- from openai import OpenAI
10
  from gtts import gTTS
11
  import requests
12
 
@@ -17,7 +17,7 @@ headers = {"Authorization": f"Bearer {hf_token}"}
17
 
18
  class ScreeningAssistant:
19
  def __init__(self):
20
- self.chat = AzureChatOpenAI(azure_deployment = "GPT4")
21
  # self.client = OpenAI()
22
 
23
  def extract_text(self, pdf_path):
@@ -29,12 +29,15 @@ class ScreeningAssistant:
29
  all_text += page.extract_text()
30
  return all_text
31
 
32
- def audio_to_text(self, audio_path):
33
- with open(audio_path, "rb") as f:
34
- data = f.read()
35
- response = requests.post(API_URL, headers=headers, data=data)
36
- print(response.json()['text'])
37
- return response.json()['text']
 
 
 
38
 
39
 
40
  def text_to_audio(self, mytext):
 
6
  from pypdf import PdfReader
7
  import os
8
  import gradio as gr
9
+ from openai import AzureOpenAI
10
  from gtts import gTTS
11
  import requests
12
 
 
17
 
18
  class ScreeningAssistant:
19
  def __init__(self):
20
+ self.client = AzureOpenAI(api_version="2024-02-01",azure_endpoint = os.getenv('URL'))
21
  # self.client = OpenAI()
22
 
23
  def extract_text(self, pdf_path):
 
29
  all_text += page.extract_text()
30
  return all_text
31
 
32
+ def audio_to_text(self,audio_file):
33
+ deployment_id = "whisper07" #This will correspond to the custom name you chose for your deployment when you deployed a model."
34
+ audio_test_file = audio_file
35
+ print("audio_test_file",audio_test_file)
36
+ result = self.client.audio.transcriptions.create(
37
+ file=open(audio_test_file, "rb"),
38
+ model=deployment_id
39
+ )
40
+ return result.text
41
 
42
 
43
  def text_to_audio(self, mytext):