Views
No views yet
| Metric | Score |
|---|---|
| 🎯 Accuracy | 93.12% |
| 📈 F1-Score | 93.55% |
| 🎪 Precision | 92.15% |
| 🎭 Recall | 95.00% |
| ⚡ Latency | <15ms |
| 💾 Model Size | ~135MB |

📊 Evaluated on 10,000+ Hindi 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-Hindi"):
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 "ऐसा देखा गया है कि भूकंप के कारण पृत्वी में अनेक तोड मोड उत्पन हो जाते हैं", # Expected: End of Turn
67 "छोटे पठार जंगल वजल के प्राकृतिक स्रोत मिल जाते हैं और", # Expected: Not End of Turn
68 "उस काल में पर्शिया का सामराज्य अचार खंडों में विभक्त था", # Expected: End of Turn
69 "कोईंबुतूर एक महत्वपून अध्योगिक शहर है, लेकिन", # Expected: Not End of Turn
70 ]
71
72 for sentence in sentences:
73 predicted_label, confidence = detector.predict(sentence)
74 result = "End of Turn" if predicted_label == 1 else "Not End of Turn"
75 print(f"'{sentence}' -> {result} (confidence: {confidence:.3f})")
76 print("-" * 50)
771from videosdk_agents import NamoTurnDetectorV1, pre_download_namo_turn_v1_model
2
3#download model
4pre_download_namo_turn_v1_model(language="hi")
5
6# Initialize Hindi turn detector for VideoSDK Agents
7turn_detector = NamoTurnDetectorV1(language="hi")📚 Complete Integration Guide - Learn how to useNamoTurnDetectorV1with VideoSDK Agents
1@model{namo_turn_detector_en_2025,
2 title={Namo Turn Detector v1: Hindi},
3 author={VideoSDK Team},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/videosdk-live/Namo-Turn-Detector-v1-Hindi},
7 note={ONNX-optimized DistilBERT for turn detection in Hindi}
8}