Cheeky Sparrow commited on
Commit ·
b8f460c
1
Parent(s): e3ad53e
try secrets
Browse files- handler.py +3 -2
handler.py
CHANGED
|
@@ -6,8 +6,9 @@ import torch
|
|
| 6 |
|
| 7 |
class EndpointHandler():
|
| 8 |
def __init__(self, path=""):
|
|
|
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
-
model = NatureLM.from_pretrained("EarthSpeciesProject/NatureLM-audio", device=device)
|
| 11 |
self.model = model.eval().to(device)
|
| 12 |
self.pipeline = Pipeline(model=self.model, cfg_path="inference.yml")
|
| 13 |
|
|
@@ -51,7 +52,7 @@ class EndpointHandler():
|
|
| 51 |
input_sample_rate=sample_rate
|
| 52 |
)
|
| 53 |
|
| 54 |
-
return [{"result": results[0], "query": query}]
|
| 55 |
|
| 56 |
except Exception as e:
|
| 57 |
return [{"error": f"Error processing audio: {str(e)}"}]
|
|
|
|
| 6 |
|
| 7 |
class EndpointHandler():
|
| 8 |
def __init__(self, path=""):
|
| 9 |
+
auth_token = os.environ.get("LLAMA_TOK")
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
+
model = NatureLM.from_pretrained("EarthSpeciesProject/NatureLM-audio", device=device, hf_auth_token=auth_token)
|
| 12 |
self.model = model.eval().to(device)
|
| 13 |
self.pipeline = Pipeline(model=self.model, cfg_path="inference.yml")
|
| 14 |
|
|
|
|
| 52 |
input_sample_rate=sample_rate
|
| 53 |
)
|
| 54 |
|
| 55 |
+
return [{"result": results[0], "query": query, "token": os.environ.get("LLAMA_TOK")}]
|
| 56 |
|
| 57 |
except Exception as e:
|
| 58 |
return [{"error": f"Error processing audio: {str(e)}"}]
|