Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions models/common/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

from daft import DataType

# One ASR word timestamp. `text` is the normalized word/token text emitted by
# the backend, with timestamps in the original source timeline.
WordStruct = DataType.struct(
{
"text": DataType.string(),
"start": DataType.float64(),
"end": DataType.float64(),
}
)

# One transcript line. `speaker` is filled in after diarization (empty until then).
SegmentStruct = DataType.struct(
{
Expand All @@ -19,6 +29,7 @@
"end": DataType.float64(),
"text": DataType.string(),
"speaker": DataType.string(),
"words": DataType.list(WordStruct),
}
)

Expand Down
20 changes: 19 additions & 1 deletion models/common/vad.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,25 @@ def __init__(

self.torch = torch
self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
self.model = nemo_asr.models.EncDecFrameClassificationModel.from_pretrained(model_id).eval().to(self.device)
self.model = (
nemo_asr.models.EncDecFrameClassificationModel.from_pretrained(model_id, strict=False).eval().to(self.device)
)
self.configure(
threshold=threshold,
min_speech_duration_ms=min_speech_duration_ms,
min_silence_duration_ms=min_silence_duration_ms,
speech_pad_ms=speech_pad_ms,
)

def configure(
self,
*,
threshold: float,
min_speech_duration_ms: int,
min_silence_duration_ms: int,
speech_pad_ms: int,
) -> None:
"""Retune threshold/windowing without reloading the NeMo weights."""
self.threshold = threshold
self.min_speech_frames = max(1, min_speech_duration_ms // self.FRAME_MS)
self.min_silence_frames = max(1, min_silence_duration_ms // self.FRAME_MS)
Expand Down
Loading
Loading