Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -71,7 +71,7 @@ wav2vec2_model.eval()
|
|
| 71 |
label_map = {0: "Neutral", 1: "Happy", 2: "Angry", 3: "Sad", 4: "Surprise"}
|
| 72 |
|
| 73 |
# ------------------ ChatGPT API Setup ---------------------
|
| 74 |
-
openai.api_key = "" #
|
| 75 |
|
| 76 |
def create_prompt_from_label(label):
|
| 77 |
return f"""
|
|
@@ -98,7 +98,7 @@ def get_recommendations(label):
|
|
| 98 |
)
|
| 99 |
return response['choices'][0]['message']['content'].strip()
|
| 100 |
except Exception as e:
|
| 101 |
-
return f"
|
| 102 |
|
| 103 |
# ----------------- Inference Pipeline ---------------------
|
| 104 |
def process_audio_and_recommend(file_path):
|
|
|
|
| 71 |
label_map = {0: "Neutral", 1: "Happy", 2: "Angry", 3: "Sad", 4: "Surprise"}
|
| 72 |
|
| 73 |
# ------------------ ChatGPT API Setup ---------------------
|
| 74 |
+
openai.api_key = os.getenv("OPENAI_API_KEY", "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") # Replace or set env var
|
| 75 |
|
| 76 |
def create_prompt_from_label(label):
|
| 77 |
return f"""
|
|
|
|
| 98 |
)
|
| 99 |
return response['choices'][0]['message']['content'].strip()
|
| 100 |
except Exception as e:
|
| 101 |
+
return f"❌ GPT Error: {str(e)}"
|
| 102 |
|
| 103 |
# ----------------- Inference Pipeline ---------------------
|
| 104 |
def process_audio_and_recommend(file_path):
|