1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import time
from faster_whisper import WhisperModel
model_path = "models/whisper-tiny-en-ct2/"
audio_files = [
"1670546132-2421.m4a",
"1670362801-1654.m4a",
"1675533069-1077.m4a",
"1675540057-3070.m4a",
"1677179024-2421.m4a",
"1677179036-2421.m4a",
"1677289865-3070.m4a",
"1677289881-3070.m4a",
"us.ny.monroe-1654-1678728684.m4a",
"us.ny.monroe-1704-1677730882.m4a",
]
t0 = time.perf_counter()
model = WhisperModel(model_path, device="cpu", compute_type="default", num_workers=4)
t1 = time.perf_counter()
print(f"loaded model in {t1 - t0:0.2f} seconds")
for file in audio_files:
t1 = time.perf_counter()
segments, info = model.transcribe(f"audio/{file}", language="en")
for segment in segments:
print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
pass
t2 = time.perf_counter()
print(f"transcription finished in {t2 - t1:0.2f} seconds")
|