raphaelbiojout
commited on
Commit
·
d9a0ef6
1
Parent(s):
a7da197
update
Browse files- handler.py +3 -2
handler.py
CHANGED
@@ -23,7 +23,7 @@ SAMPLE_RATE = 16000
|
|
23 |
def whisper_config():
|
24 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
25 |
whisper_model = "large-v2"
|
26 |
-
batch_size =
|
27 |
# change to "int8" if low on GPU mem (may reduce accuracy)
|
28 |
compute_type = "float16" if device == "cuda" else "int8"
|
29 |
return device, batch_size, compute_type, whisper_model
|
@@ -172,7 +172,7 @@ class EndpointHandler():
|
|
172 |
def __init__(self, path=""):
|
173 |
# load the model
|
174 |
device, batch_size, compute_type, whisper_model = whisper_config()
|
175 |
-
self.model = whisperx.load_model(whisper_model, device=device, compute_type=compute_type
|
176 |
# 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 ERIC
|
177 |
# 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 OLD
|
178 |
logger.info(f"Model {whisper_model} initialized")
|
@@ -230,6 +230,7 @@ class EndpointHandler():
|
|
230 |
# 2. transcribe
|
231 |
device, batch_size, compute_type, whisper_model = whisper_config()
|
232 |
logger.info("--------------- STARTING TRANSCRIPTION ------------------------")
|
|
|
233 |
transcription = self.model.transcribe(audio_nparray, batch_size=batch_size,language=language)
|
234 |
if info:
|
235 |
print(transcription["segments"]) # before alignment
|
|
|
23 |
def whisper_config():
|
24 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
25 |
whisper_model = "large-v2"
|
26 |
+
batch_size = 16 # reduce if low on GPU mem, 16 initailly
|
27 |
# change to "int8" if low on GPU mem (may reduce accuracy)
|
28 |
compute_type = "float16" if device == "cuda" else "int8"
|
29 |
return device, batch_size, compute_type, whisper_model
|
|
|
172 |
def __init__(self, path=""):
|
173 |
# load the model
|
174 |
device, batch_size, compute_type, whisper_model = whisper_config()
|
175 |
+
self.model = whisperx.load_model(whisper_model, device=device, compute_type=compute_type)
|
176 |
# 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 ERIC
|
177 |
# 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 OLD
|
178 |
logger.info(f"Model {whisper_model} initialized")
|
|
|
230 |
# 2. transcribe
|
231 |
device, batch_size, compute_type, whisper_model = whisper_config()
|
232 |
logger.info("--------------- STARTING TRANSCRIPTION ------------------------")
|
233 |
+
logger.info(f"device: {device}, batch_size: {batch_size}, compute_type:{compute_type}, whisper_model: {whisper_model}")
|
234 |
transcription = self.model.transcribe(audio_nparray, batch_size=batch_size,language=language)
|
235 |
if info:
|
236 |
print(transcription["segments"]) # before alignment
|