new structure for transcription engine

- found problems with mps
- integrated jinja2 templates for rendering (.tex?)
- raw ui & bad structure
This commit is contained in:
2026-02-24 02:58:28 +03:00
parent 9e67b36842
commit 3d48f473b0
24 changed files with 584 additions and 403 deletions
+50
View File
@@ -0,0 +1,50 @@
import torch
from typing import List
class Splitter:
def __init__(
self,
chunkSize: int,
batchSize: int,
) -> None:
self.chunkSize = chunkSize * 16000 # 16 kHz after resampling
self.batchSize = batchSize
# maybe raise some exceptions here?
def _split_to_chunks(
self,
waveform: torch.Tensor,
) -> List:
totalSamples = waveform.shape[0]
chunksCount = (totalSamples + self.chunkSize - 1) // self.chunkSize
chunks: List = []
# tqdm or something here?
for chunkNum in range(chunksCount):
start = chunkNum * self.chunkSize
end = min((chunkNum + 1) * self.chunkSize, totalSamples)
chunk = waveform[start : end].cpu().numpy().astype("float32")
chunks.append(chunk)
return chunks
def _split_to_batches(
self,
chunks: List,
) -> List:
batches: List = []
for i in range(0, len(chunks), self.batchSize):
batch = chunks[i : i + self.batchSize]
batches.append(batch)
return batches
def split(
self,
waveform: torch.Tensor
) -> List:
chunks = self._split_to_chunks(waveform)
batches = self._split_to_batches(chunks)
return batches