Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import openai
|
|
3 |
from decouple import config
|
4 |
from gtts import gTTS
|
5 |
import os
|
|
|
|
|
6 |
import config
|
7 |
|
8 |
openai.api_key = config.API_KEYS['openai']
|
@@ -23,16 +25,14 @@ def decipher(audio):
|
|
23 |
messages.append({"role": "user", "content": transcript["text"]})
|
24 |
|
25 |
response = openai.ChatCompletion.create(
|
26 |
-
model="
|
27 |
messages=messages
|
28 |
)
|
29 |
|
30 |
-
system_message = response["choices"][0]["
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
os.system("xdg-open welcome.mp3")
|
35 |
-
|
36 |
messages.append({"role": "assistant", "content": system_message})
|
37 |
|
38 |
chat_transcript = ""
|
@@ -45,4 +45,4 @@ def decipher(audio):
|
|
45 |
# Using Gradio's audio Interface
|
46 |
interface = gr.Interface(fn=decipher, inputs=gr.Audio(
|
47 |
source="microphone", type="filepath"), outputs="text")
|
48 |
-
interface.launch()
|
|
|
3 |
from decouple import config
|
4 |
from gtts import gTTS
|
5 |
import os
|
6 |
+
import pyttsx3
|
7 |
+
import io
|
8 |
import config
|
9 |
|
10 |
openai.api_key = config.API_KEYS['openai']
|
|
|
25 |
messages.append({"role": "user", "content": transcript["text"]})
|
26 |
|
27 |
response = openai.ChatCompletion.create(
|
28 |
+
model="text-davinci-002",
|
29 |
messages=messages
|
30 |
)
|
31 |
|
32 |
+
system_message = response["choices"][0]["text"]
|
33 |
+
engine = pyttsx3.init()
|
34 |
+
engine.say(system_message)
|
35 |
+
engine.runAndWait()
|
|
|
|
|
36 |
messages.append({"role": "assistant", "content": system_message})
|
37 |
|
38 |
chat_transcript = ""
|
|
|
45 |
# Using Gradio's audio Interface
|
46 |
interface = gr.Interface(fn=decipher, inputs=gr.Audio(
|
47 |
source="microphone", type="filepath"), outputs="text")
|
48 |
+
interface.launch(share=True)
|