Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
import os
|
2 |
import openai
|
3 |
import gradio as gr
|
|
|
4 |
from transformers import pipeline
|
5 |
-
import tempfile
|
6 |
-
import requests
|
7 |
from openai import OpenAI
|
8 |
client = OpenAI()
|
9 |
|
10 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
11 |
pipe = pipeline(model="Ussen/whisper-medium-swc-drc-kat-1")
|
12 |
|
13 |
def transcribe(audio):
|
@@ -15,9 +15,8 @@ def transcribe(audio):
|
|
15 |
return text
|
16 |
|
17 |
def generate_response(transcribed_text):
|
18 |
-
|
19 |
response = client.chat.completions.create(
|
20 |
-
|
21 |
messages=[
|
22 |
{
|
23 |
"role": "system",
|
@@ -114,10 +113,11 @@ def generate_response(transcribed_text):
|
|
114 |
"role": "user",
|
115 |
"content": transcribed_text
|
116 |
},
|
117 |
-
]
|
|
|
118 |
)
|
119 |
return response.choices[0].message.content
|
120 |
-
|
121 |
def inference(text):
|
122 |
#client = openai.OpenAI(api_key='your_api_key')
|
123 |
response = client.audio.speech.create(
|
|
|
1 |
import os
|
2 |
import openai
|
3 |
import gradio as gr
|
4 |
+
from gtts import gTTS
|
5 |
from transformers import pipeline
|
|
|
|
|
6 |
from openai import OpenAI
|
7 |
client = OpenAI()
|
8 |
|
9 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
10 |
+
|
11 |
pipe = pipeline(model="Ussen/whisper-medium-swc-drc-kat-1")
|
12 |
|
13 |
def transcribe(audio):
|
|
|
15 |
return text
|
16 |
|
17 |
def generate_response(transcribed_text):
|
|
|
18 |
response = client.chat.completions.create(
|
19 |
+
|
20 |
messages=[
|
21 |
{
|
22 |
"role": "system",
|
|
|
113 |
"role": "user",
|
114 |
"content": transcribed_text
|
115 |
},
|
116 |
+
],
|
117 |
+
model="gpt-4"
|
118 |
)
|
119 |
return response.choices[0].message.content
|
120 |
+
|
121 |
def inference(text):
|
122 |
#client = openai.OpenAI(api_key='your_api_key')
|
123 |
response = client.audio.speech.create(
|