Views
No views yet
| Metric | Score |
|---|---|
| 🎯 Accuracy | 86.52% |
| 📈 F1-Score | 86.89% |
| 🎪 Precision | 85.29% |
| 🎭 Recall | 88.54% |
| ⚡ Latency | <12ms |
| 💾 Model Size | ~135MB |

📊 Evaluated on 700+ Danish utterances from diverse conversational contexts

pip install onnxruntime transformers huggingface_hub1import numpy as np
2import onnxruntime as ort
3from transformers import AutoTokenizer
4from huggingface_hub import hf_hub_download
5
6class TurnDetector:
7 def __init__(self, repo_id="videosdk-live/Namo-Turn-Detector-v1-Danish"):
8 """
9 Initializes the detector by downloading the model and tokenizer
10 from the Hugging Face Hub.
11 """
12 print(f"Loading model from repo: {repo_id}")
13
14 # Download the model and tokenizer from the Hub
15 # Authentication is handled automatically if you are logged in
16 model_path = hf_hub_download(repo_id=repo_id, filename="model_quant.onnx")
17 self.tokenizer = AutoTokenizer.from_pretrained(repo_id)
18
19 # Set up the ONNX Runtime inference session
20 self.session = ort.InferenceSession(model_path)
21 self.max_length = 512
22 print("✅ Model and tokenizer loaded successfully.")
23
24 def predict(self, text: str) -> tuple:
25 """
26 Predicts if a given text utterance is the end of a turn.
27 Returns (predicted_label, confidence) where:
28 - predicted_label: 0 for "Not End of Turn", 1 for "End of Turn"
29 - confidence: confidence score between 0 and 1
30 """
31 # Tokenize the input text
32 inputs = self.tokenizer(
33 text,
34 truncation=True,
35 max_length=self.max_length,
36 return_tensors="np"
37 )
38
39 # Prepare the feed dictionary for the ONNX model
40 feed_dict = {
41 "input_ids": inputs["input_ids"],
42 "attention_mask": inputs["attention_mask"]
43 }
44
45 # Run inference
46 outputs = self.session.run(None, feed_dict)
47 logits = outputs[0]
48
49 probabilities = self._softmax(logits[0])
50 predicted_label = np.argmax(probabilities)
51 confidence = float(np.max(probabilities))
52
53 return predicted_label, confidence
54
55 def _softmax(self, x, axis=None):
56 if axis is None:
57 axis = -1
58 exp_x = np.exp(x - np.max(x, axis=axis, keepdims=True))
59 return exp_x / np.sum(exp_x, axis=axis, keepdims=True)
60
61# --- Example Usage ---
62if __name__ == "__main__":
63 detector = TurnDetector()
64
65 sentences = [
66 "Kan du tilgive dig selv, når du har begået en fejl?", # Expected: Not End of Turn
67 "Store temperaturintervaller er." # Expected: End of Turn
68 ]
69
70 for sentence in sentences:
71 predicted_label, confidence = detector.predict(sentence)
72 result = "End of Turn" if predicted_label == 1 else "Not End of Turn"
73 print(f"'{sentence}' -> {result} (confidence: {confidence:.3f})")
74 print("-" * 50)
751from videosdk_agents import NamoTurnDetectorV1, pre_download_namo_turn_v1_model
2
3#download model
4pre_download_namo_turn_v1_model(language="da")
5
6# Initialize Danish turn detector for VideoSDK Agents
7turn_detector = NamoTurnDetectorV1(language="da")📚 Complete Integration Guide - Learn how to useNamoTurnDetectorV1with VideoSDK Agents
1@model{namo_turn_detector_da_2025,
2 title={Namo Turn Detector v1: Danish},
3 author={VideoSDK Team},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/videosdk-live/Namo-Turn-Detector-v1-Danish},
7 note={ONNX-optimized DistilBERT for turn detection in Danish}
8}