Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
|
|
|
| 3 |
import os
|
| 4 |
import uuid
|
| 5 |
from gtts import gTTS
|
|
@@ -44,6 +45,7 @@ LANG_CODES = {
|
|
| 44 |
|
| 45 |
# === Load Whisper Model ===
|
| 46 |
model = WhisperModel("base", compute_type="int8")
|
|
|
|
| 47 |
|
| 48 |
# === Audio Processing ===
|
| 49 |
def convert_to_wav(input_file):
|
|
@@ -79,7 +81,7 @@ End with:
|
|
| 79 |
Transcript:
|
| 80 |
{transcript}
|
| 81 |
"""
|
| 82 |
-
response =
|
| 83 |
model="gpt-4",
|
| 84 |
messages=[
|
| 85 |
{"role": "system", "content": f"You are a supportive communication coach responding in {language}."},
|
|
@@ -97,7 +99,7 @@ You are a communication tutor. Rewrite this speech transcript to be a more polis
|
|
| 97 |
Transcript:
|
| 98 |
{transcript}
|
| 99 |
"""
|
| 100 |
-
response =
|
| 101 |
model="gpt-4",
|
| 102 |
messages=[
|
| 103 |
{"role": "system", "content": "You are a helpful speaking coach."},
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
+
from openai import OpenAI
|
| 4 |
import os
|
| 5 |
import uuid
|
| 6 |
from gtts import gTTS
|
|
|
|
| 45 |
|
| 46 |
# === Load Whisper Model ===
|
| 47 |
model = WhisperModel("base", compute_type="int8")
|
| 48 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 49 |
|
| 50 |
# === Audio Processing ===
|
| 51 |
def convert_to_wav(input_file):
|
|
|
|
| 81 |
Transcript:
|
| 82 |
{transcript}
|
| 83 |
"""
|
| 84 |
+
response = client.chat.completions.create(
|
| 85 |
model="gpt-4",
|
| 86 |
messages=[
|
| 87 |
{"role": "system", "content": f"You are a supportive communication coach responding in {language}."},
|
|
|
|
| 99 |
Transcript:
|
| 100 |
{transcript}
|
| 101 |
"""
|
| 102 |
+
response = client.chat.completions.create(
|
| 103 |
model="gpt-4",
|
| 104 |
messages=[
|
| 105 |
{"role": "system", "content": "You are a helpful speaking coach."},
|