Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
from gtts import gTTS
|
4 |
-
import
|
|
|
5 |
|
6 |
# Load the Whisper model for speech-to-text
|
7 |
pipe = pipeline(model="openai/whisper-small")
|
@@ -10,12 +11,12 @@ pipe = pipeline(model="openai/whisper-small")
|
|
10 |
# text_pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
11 |
|
12 |
def generate_gpt_response(text):
|
13 |
-
response =
|
14 |
-
|
15 |
-
|
16 |
-
max_tokens=150
|
17 |
)
|
18 |
-
|
|
|
19 |
|
20 |
def transcribe(audio):
|
21 |
# Transcribe the audio to text
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
from gtts import gTTS
|
4 |
+
from openai import OpenAI
|
5 |
+
client = OpenAI()
|
6 |
|
7 |
# Load the Whisper model for speech-to-text
|
8 |
pipe = pipeline(model="openai/whisper-small")
|
|
|
11 |
# text_pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
12 |
|
13 |
def generate_gpt_response(text):
|
14 |
+
response = client.chat.completions.create(
|
15 |
+
model='gpt-3.5-turbo-0125',
|
16 |
+
messages=[{"role": "user", "content": text}]
|
|
|
17 |
)
|
18 |
+
|
19 |
+
return response.choices[0].message.content
|
20 |
|
21 |
def transcribe(audio):
|
22 |
# Transcribe the audio to text
|