Spaces:
Build error
Build error
Marco Acierno
commited on
Commit
·
03ccab8
1
Parent(s):
c9f35a7
changes
Browse files- server/src/main.py +5 -4
server/src/main.py
CHANGED
@@ -8,6 +8,8 @@ from fastapi import FastAPI
|
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
|
|
|
|
11 |
|
12 |
@app.get("/")
|
13 |
def read_root():
|
@@ -18,8 +20,8 @@ TRANSCRIBE_PIPELINE = pipeline(
|
|
18 |
"automatic-speech-recognition",
|
19 |
model="openai/whisper-large-v3",
|
20 |
torch_dtype=torch.float16,
|
21 |
-
device=
|
22 |
-
model_kwargs={"attn_implementation":
|
23 |
)
|
24 |
|
25 |
|
@@ -35,8 +37,7 @@ async def transcribe(request: Request):
|
|
35 |
'task': 'transcribe',
|
36 |
'language': 'english'
|
37 |
},
|
38 |
-
|
39 |
-
return_timestamps=False
|
40 |
)
|
41 |
text = outputs["text"].strip()
|
42 |
return {"transcribe": text}
|
|
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
11 |
+
DEVICE = "mps"
|
12 |
+
ATTN_IMPLEMENTATION = "sdpa"
|
13 |
|
14 |
@app.get("/")
|
15 |
def read_root():
|
|
|
20 |
"automatic-speech-recognition",
|
21 |
model="openai/whisper-large-v3",
|
22 |
torch_dtype=torch.float16,
|
23 |
+
device=DEVICE,
|
24 |
+
model_kwargs={"attn_implementation": ATTN_IMPLEMENTATION},
|
25 |
)
|
26 |
|
27 |
|
|
|
37 |
'task': 'transcribe',
|
38 |
'language': 'english'
|
39 |
},
|
40 |
+
return_timestamps='word'
|
|
|
41 |
)
|
42 |
text = outputs["text"].strip()
|
43 |
return {"transcribe": text}
|