stash commit - wip
This commit is contained in:
@@ -7,6 +7,9 @@ class AudioPreprocessor:
|
||||
# for different models in future
|
||||
# def __init__(self, model):
|
||||
# pass
|
||||
|
||||
def __init__(self, target_sr: int) -> None:
|
||||
self.TARGET_SAMPLING_RATE = target_sr
|
||||
|
||||
def _resample(
|
||||
self,
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import torch
|
||||
from typing import List
|
||||
from logging import Logger
|
||||
|
||||
# TODO: add logging here
|
||||
class Splitter:
|
||||
def __init__(
|
||||
self,
|
||||
chunkSize: int,
|
||||
batchSize: int,
|
||||
# logger: Logger
|
||||
) -> None:
|
||||
self.chunkSize = chunkSize * 16000 # 16 kHz after resampling
|
||||
self.batchSize = batchSize
|
||||
@@ -19,7 +22,7 @@ class Splitter:
|
||||
chunksCount = (totalSamples + self.chunkSize - 1) // self.chunkSize
|
||||
|
||||
chunks: List = []
|
||||
# tqdm or something here?
|
||||
# tqdm for logger or something here?
|
||||
for chunkNum in range(chunksCount):
|
||||
start = chunkNum * self.chunkSize
|
||||
end = min((chunkNum + 1) * self.chunkSize, totalSamples)
|
||||
@@ -34,11 +37,9 @@ class Splitter:
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user