Update app.py
Browse files
app.py
CHANGED
@@ -10,16 +10,14 @@ import os
|
|
10 |
access_token=os.getenv("access_token")
|
11 |
|
12 |
MODEL_NAME = "openai/whisper-large-v3"
|
13 |
-
BATCH_SIZE =
|
14 |
-
FILE_LIMIT_MB = 1000
|
15 |
-
YT_LENGTH_LIMIT_S = 3600 # limit to 1 hour YouTube files
|
16 |
|
17 |
device = 0 if torch.cuda.is_available() else "cpu"
|
18 |
|
19 |
pipe = pipeline(
|
20 |
task="automatic-speech-recognition",
|
21 |
model=MODEL_NAME,
|
22 |
-
chunk_length_s=30,
|
23 |
device=device,
|
24 |
token=access_token
|
25 |
)
|
@@ -28,7 +26,7 @@ pipe = pipeline(
|
|
28 |
def transcribe(inputs, task):
|
29 |
if inputs is None:
|
30 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
31 |
-
text = pipe(inputs[1], batch_size=BATCH_SIZE, generate_kwargs={"task": task}
|
32 |
return text
|
33 |
|
34 |
|
|
|
10 |
access_token=os.getenv("access_token")
|
11 |
|
12 |
MODEL_NAME = "openai/whisper-large-v3"
|
13 |
+
BATCH_SIZE = 3
|
|
|
|
|
14 |
|
15 |
device = 0 if torch.cuda.is_available() else "cpu"
|
16 |
|
17 |
pipe = pipeline(
|
18 |
task="automatic-speech-recognition",
|
19 |
model=MODEL_NAME,
|
20 |
+
#chunk_length_s=30,
|
21 |
device=device,
|
22 |
token=access_token
|
23 |
)
|
|
|
26 |
def transcribe(inputs, task):
|
27 |
if inputs is None:
|
28 |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
|
29 |
+
text = pipe(inputs[1], batch_size=BATCH_SIZE, generate_kwargs={"task": task})["text"]
|
30 |
return text
|
31 |
|
32 |
|