Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -43,7 +43,7 @@ class CNN(nn.Module):
|
|
| 43 |
|
| 44 |
# Load the trained model
|
| 45 |
model = CNN(num_classes=5)
|
| 46 |
-
model.load_state_dict(torch.load("
|
| 47 |
model.eval()
|
| 48 |
|
| 49 |
# Extract features from audio file
|
|
@@ -71,11 +71,11 @@ def predict_and_reply(audio_path):
|
|
| 71 |
prompt = f"The user sounds {emotion.lower()}. What would you like to say to them?"
|
| 72 |
|
| 73 |
try:
|
| 74 |
-
openai.api_key = os.getenv("OPENAI_API_KEY", "
|
| 75 |
response = openai.ChatCompletion.create(
|
| 76 |
model="gpt-3.5-turbo",
|
| 77 |
messages=[
|
| 78 |
-
{"role": "system", "content": "You are
|
| 79 |
{"role": "user", "content": prompt}
|
| 80 |
]
|
| 81 |
)
|
|
|
|
| 43 |
|
| 44 |
# Load the trained model
|
| 45 |
model = CNN(num_classes=5)
|
| 46 |
+
model.load_state_dict(torch.load("best_model_CNN_bs32_lr0.0005_epoch9_acc0.9238.pth", map_location="cpu"))
|
| 47 |
model.eval()
|
| 48 |
|
| 49 |
# Extract features from audio file
|
|
|
|
| 71 |
prompt = f"The user sounds {emotion.lower()}. What would you like to say to them?"
|
| 72 |
|
| 73 |
try:
|
| 74 |
+
openai.api_key = os.getenv("OPENAI_API_KEY", "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") # Replace with real key or env var
|
| 75 |
response = openai.ChatCompletion.create(
|
| 76 |
model="gpt-3.5-turbo",
|
| 77 |
messages=[
|
| 78 |
+
{"role": "system", "content": "You are a helpful assistant that provides entertainment recommendations."},
|
| 79 |
{"role": "user", "content": prompt}
|
| 80 |
]
|
| 81 |
)
|