TransTCNet: Transformer-Based Temporal-Contextual Network for Low-Latency Typing Interfaces on Edge Devices
Abstract
1. Introduction
2. Materials and Methods
2.1. Dataset Description
2.1.1. Keyboard Typing sEMG Dataset
2.1.2. Participants
2.1.3. Data Structure
2.2. Data Preprocessing
2.2.1. Valid Session and Window Selection
2.2.2. Data Augmentation
2.2.3. Normalization and Tensor Formation
2.3. Neural Network Architecture
2.3.1. TransTCNet Pipeline
Local Temporal Feature Encoding
Global Contextual Sequence Modeling
| Algorithm 1: TransTCNet Training and Inference |
| Input: Preprocessed sEMG windows X, class labels y, learning rate η, number of epochs N, batch size B Output: Trained model parameters θ*, evaluation metrics 1. Initialize TransTCNet parameters θ 2. Initialize optimizer (Adam) and loss function (Cross-Entropy) 3. for epoch ← 1 to N, do 4. for each minibatch (Xb, yb) ∈ Dtrain, do 5. Zt ← DilatedCausalConv1D (Xb) 6. Zc ← Self Attention (Zt) 7. ← Softmax (Classifier (Zc)) 8. ← Cross Entropy (, yb) 9. θ ← θ − η ∇ θ end 10. Model Evaluation (accuracy, F1-score, etc.) end Return: Final trained model θ*, performance metrics |
3. Experimental Setup
3.1. Training and Validation Split
3.2. Hyperparameters and Evaluation Metrics
3.3. Hardware/Software
4. Results
4.1. Accuracy and Loss Curves
4.2. Confusion Matrix Analysis
4.3. Participant-Wise Performance Analysis
4.4. Class Level Performance
4.5. Feature Space Visualization
4.6. ROC Curve Analysis
4.7. Prediction Confidence and Calibration Analysis
4.7.1. Confidence Distribution Analysis
4.7.2. Model Calibration Assessment
4.8. Error Pattern Analysis
4.9. Ablation Study
4.9.1. Baseline: 1D-CNN
4.9.2. + Temporal Module (Dilated Causal Convolutions)
4.9.3. + Global Context (Transformer Encoder)
4.9.4. TransTCNet: Full Architecture
4.9.5. Architectural Justification for Fine-Grained Discrimination
4.10. Comparison Models
4.11. Statistical Analysis
5. Limitations and Future Work
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Yeo, A.; Kwok, B.W.; Joshna, A.; Chen, K.; Lee, J.S. Entering the next dimension: A review of 3d user interfaces for virtual reality. Electronics 2024, 13, 600. [Google Scholar] [CrossRef] [Scilit]
- Hu, J.; Jiang, H.; Xiao, Z.; Chen, S.; Dustdar, S.; Liu, J. HeadTrack: Real-Time Human–Computer Interaction via Wireless Earphones. IEEE J. Sel. Areas Commun. 2024, 42, 990–1002. [Google Scholar] [CrossRef] [Scilit]
- Zheng, M.; Crouch, M.S.; Eggleston, M.S. Surface electromyography as a natural human–machine interface: A review. IEEE Sens. J. 2022, 22, 9198–9214. [Google Scholar] [CrossRef] [Scilit]
- Zaim, T.; Abdel-Hadi, S.; Mahmoud, R.; Khandakar, A.; Rakhtala, S.M.; Chowdhury, M.E. Machine Learning-and Deep Learning-Based Myoelectric Control System for Upper Limb Rehabilitation Utilizing EEG and EMG Signals: A Systematic Review. Bioengineering 2025, 12, 144. [Google Scholar] [CrossRef] [Scilit]
- Eddy, E.; Campbell, E.; Bateman, S.; Scheme, E. Big data in myoelectric control: Large multi-user models enable robust zero-shot EMG-based discrete gesture recognition. Front. Bioeng. Biotechnol. 2024, 12, 1463377. [Google Scholar] [CrossRef] [Scilit]
- Kyranou, I.; Szymaniak, K.; Nazarpour, K. EMG dataset for gesture recognition with arm translation. Sci. Data 2025, 12, 100. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Zhang, S.; Zhou, H.; Tchantchane, R.; Alici, G. A wearable human–machine-interface (HMI) system based on colocated EMG-pFMG sensing for hand gesture recognition. IEEE/ASME Trans. Mechatron. 2024, 30, 369–380. [Google Scholar] [CrossRef] [Scilit]
- Ma, C.; Wang, C.; Zhu, D.; Chen, M.; Zhang, M.; He, J. The Investigation of the Relationship Between Individual Pain Perception, Brain Electrical Activity, and Facial Expression Based on Combined EEG and Facial EMG Analysis. J. Pain Res. 2025, 21–32. [Google Scholar] [CrossRef] [Scilit]
- Adamov, L.; Petrović, B.; Milić, L.; Štrbac, V.; Kojić, S.; Joseph, K.; Stojanović, G. Comparative analysis of electrical signals in facial expression muscles. Biomed. Eng. 2025, 24, 17. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ullah, A.; Zhang, F.; Song, Z.; Wang, Y.; Zhao, S.; Riaz, W.; Li, G. Surface Electromyography-Based Recognition of Electronic Taste Sensations. Biosensors 2024, 14, 396. [Google Scholar] [CrossRef] [Scilit]
- Ullah, A.; Liu, Y.; Wang, Y.; Gao, H.; Luo, Z.; Li, G. Gender Differences in Taste Sensations Based on Frequency Analysis of Surface Electromyography. Percept. Mot. Ski. 2023, 130, 938–957. [Google Scholar] [CrossRef] [Scilit]
- Salkanovic, A.; Sušanj, D.; Batistić, L.; Ljubic, S. Beyond Signatures: Leveraging Sensor Fusion for Contextual Handwriting Recognition. Sensors 2025, 25, 2290. [Google Scholar] [CrossRef] [Scilit]
- Tigrini, A.; Ranaldi, S.; Verdini, F.; Mobarak, R.; Scattolini, M.; Conforto, S.; Schmid, M.; Burattini, L.; Gambi, E.; Fioretti, S. Intelligent human–computer interaction: Combined wrist and forearm myoelectric signals for handwriting recognition. Bioengineering 2024, 11, 458. [Google Scholar] [CrossRef] [Scilit]
- Eby, J.; Beutel, M.; Koivisto, D.; Achituve, I.; Fetaya, E.; Zariffa, J. Electromyographic typing gesture classification dataset for neurotechnological human-machine interfaces. Sci. Data 2025, 12, 440. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Choudhury, N.A.; Soni, B. Enhanced complex human activity recognition system: A proficient deep learning framework exploiting physiological sensors and feature learning. IEEE Sens. Lett. 2023, 7, 1–4. [Google Scholar] [CrossRef] [Scilit]
- Essa, E.; Abdelmaksoud, I.R. Temporal-channel convolution with self-attention network for human activity recognition using wearable sensors. Knowl.-Based Syst. 2023, 278, 110867. [Google Scholar] [CrossRef] [Scilit]
- Singh, S.; Choudhury, N.A.; Soni, B. Gait recognition using activities of daily livings and ensemble learning models. In Proceedings of the International Conference on Advances in IoT and Security with AI, New Delhi, India, 24–25 March 2023; pp. 195–206. [Google Scholar]
- Zhang, S.; Li, Y.; Zhang, S.; Shahabi, F.; Xia, S.; Deng, Y.; Alshurafa, N. Deep learning in human activity recognition with wearable sensors: A review on advances. Sensors 2022, 22, 1476. [Google Scholar] [CrossRef] [Scilit]
- Demrozi, F.; Pravadelli, G.; Bihorac, A.; Rashidi, P. Human activity recognition using inertial, physiological and environmental sensors: A comprehensive survey. IEEE Access 2020, 8, 210816–210836. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Choudhury, N.A.; Soni, B. An efficient CNN-LSTM approach for smartphone sensor-based human activity recognition system. In Proceedings of the 2022 5th International Conference on Computational Intelligence and Networks (CINE), Odisha, India, 1–3 December 2022; pp. 1–6. [Google Scholar]
- Putro, N.A.S.; Avian, C.; Prakosa, S.W.; Mahali, M.I.; Leu, J.-S. Estimating finger joint angles by surface EMG signal using feature extraction and transformer-based deep learning model. Biomed. Signal Process. Control 2024, 87, 105447. [Google Scholar] [CrossRef] [Scilit]
- Riaz, W.; Ullah, A.; Ji, J. Multi-Scale Attention Networks with Feature Refinement for Medical Item Classification in Intelligent Healthcare Systems. Sensors 2025, 25, 5305. [Google Scholar] [CrossRef] [Scilit]
- Zhang, X.; Cheng, X.; Liu, H. TPRO-NET: An EEG-based emotion recognition method reflecting subtle changes in emotion. Sci. Rep. 2024, 14, 13491. [Google Scholar] [CrossRef] [Scilit]
- Riaz, W.; Ji, J.; Ullah, A. TriViT-Lite: A Compact Vision Transformer–MobileNet Model with Texture-Aware Attention for Real-Time Facial Emotion Recognition in Healthcare. Electronics 2025, 14, 3256. [Google Scholar] [CrossRef] [Scilit]
- Ullah, A.; Song, Z.; Riaz, W.; Qi, X.; Hossain, M.M. Hand Gesture-Based Biometric Verification and Identification Using Embedded-STQNet Deep Neural Architecture in Security-Oriented Systems. IEEE Internet Things J. 2026. [Google Scholar] [CrossRef] [Scilit]
- Al-Qaness, M.A.A.; Dahou, A.; Abd Elaziz, M.; Helmi, A.M. Multi-ResAtt: Multilevel residual network with attention for human activity recognition using wearable sensors. IEEE Trans. Ind. Inform. 2022, 19, 144–152. [Google Scholar] [CrossRef] [Scilit]
- Hnoohom, N.; Jitpattanakul, A.; You, I.; Mekruksavanich, S. Deep learning approach for complex activity recognition using heterogeneous sensors from wearable device. In Proceedings of the 2021 Research, Invention, and Innovation Congress: Innovation Electricals and Electronics (RI2C), Bangkok, Thailand, 1–3 September 2021; pp. 60–65. [Google Scholar]
- Choudhury, N.A.; Moulik, S.; Roy, D. Physique-based human activity recognition using ensemble learning and smartphone sensors. IEEE Sens. J. 2021, 21, 16852–16860. [Google Scholar] [CrossRef] [Scilit]
- Choudhury, N.A.; Soni, B.J.I.S.J. An efficient and lightweight deep learning model for human activity recognition on raw sensor data in uncontrolled environment. IEEE Sens. J. 2023, 23, 25579–25586. [Google Scholar] [CrossRef] [Scilit]
- Wang, T.; Hou, B.; Li, J.; Shi, P.; Zhang, B.; Snoussi, H. TASTA: Text-Assisted Spatial and Temporal Attention Network for Video Question Answering. Adv. Intell. Syst. 2023, 5, 2200131. [Google Scholar] [CrossRef] [Scilit]
- Pradhan, A. Electromyography-Based Biometrics for Secure and Robust Personal Identification and Authentication. Ph.D. Thesis, University of Waterloo, Waterloo, ON, Canada, 2024. [Google Scholar]
- Ullah, A.; Song, Z.; Riaz, W.; Wang, Y. GTMH-TasteNet: Advanced Deep Learning for sEMG-Based Taste Sensation Recognition. Tsinghua Sci. Technol. 2025. [Google Scholar] [CrossRef] [Scilit]
- Pourmokhtari, M.; Beigzadeh, B. Simple recognition of hand gestures using single-channel EMG signals. Proc. Inst. Mech. Eng. Part H J. Eng. Med. 2024, 238, 372–380. [Google Scholar] [CrossRef] [Scilit]
- Liu, G.; Wang, Z.; Xi, C.; He, Z.; Guo, S.; Zhang, R.; Yao, D. Kinetic and Kinematic Sensors-free Approach for Estimation of Continuous Force and Gesture in sEMG Prosthetic Hands. arXiv 2024, arXiv:2407.00014. [Google Scholar]
- Taheri, M.; Omranpour, H. Breast cancer prediction by ensemble meta-feature space generator based on deep neural network. Biomed. Signal Process. Control 2024, 87, 105382. [Google Scholar] [CrossRef] [Scilit]
- Wetzel, S.J.; Ha, S.; Iten, R.; Klopotek, M.; Liu, Z. Interpretable machine learning in physics: A review. arXiv 2025, arXiv:2503.23616. [Google Scholar] [CrossRef] [Scilit]
- Li, Z.; Cai, J.; Chen, Q.; Chen, L.; Qing, M.; Yang, S.X. An LSTM Network With Neural Plasticity for Driver Fatigue Recognition on Real Roads. IEEE Trans. Ind. Electron. 2025, 72, 14668–14676. [Google Scholar] [CrossRef] [Scilit]












| Hyperparameter | Value |
|---|---|
| Batch Size | 32 |
| Learning Rate | 1 × 10−4 |
| Optimizer | Adam (β1 = 0.9, β2 = 0.999, ε = 10−8) |
| Epochs | 100 |
| Augmentation Factor | 3 |
| Train/Validation Split | 80:20 |
| Model Architecture | Transformer Encoder |
| Input Channels | 16 |
| Embedding Dimension (d_model) | 128 |
| Attention Heads | 8 |
| Transformer Layers | 4 |
| Dropout Rate | 0.1 |
| Positional Encoding | Learned |
| Feedforward Dimension | 512 |
| Loss Function | Cross-Entropy |
| Gradient Clipping | 1.0 |
| Weight Initialization | Xavier Uniform |
| Model Parameters | 849,818 |
| Training Time | 1.51 h |
| Model Variant | Architectural Components | Validation Accuracy (%) |
|---|---|---|
| Baseline | Standard 1D convolutional layers | 48.66 |
| + Temporal Module | Dilated causal convolutions (dilation = 2, 4) | 72.67 |
| + Global Context | Multi-head self-attention encoder | 88.39 |
| TransTCNet (Full) | Both temporal + global components integrated | 96.53 |
| Model | Accuracy (%) | Comments |
|---|---|---|
| SVM + Handcrafted Features | 87.4 ± 2.5 | Baseline model using RMS, LOGVAR, WL, WAMP, ZC, AR1, AR2 |
| SVM (Excl. spacebar class) | 90.2 ± 2.1 | 26-class classification (A–Z only) |
| MLP (FedAvg) | 53.3 ± 0.92 | Shared model, no personalization |
| MLP (FedPer) | 66.58 ± 1.01 | Personalized classifier layers |
| MLP (pFedGP) | 74.49 ± 0.72 | Gaussian process with personalized heads |
| TransTCNet (Current model) | 96.53% | Short-range temporal dependencies and long-range contextual patterns |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Ullah, A.; Song, Z.; Riaz, W.; Shao, Y.; Qi, X. TransTCNet: Transformer-Based Temporal-Contextual Network for Low-Latency Typing Interfaces on Edge Devices. Biomimetics 2026, 11, 337. https://doi.org/10.3390/biomimetics11050337
Ullah A, Song Z, Riaz W, Shao Y, Qi X. TransTCNet: Transformer-Based Temporal-Contextual Network for Low-Latency Typing Interfaces on Edge Devices. Biomimetics. 2026; 11(5):337. https://doi.org/10.3390/biomimetics11050337
Chicago/Turabian StyleUllah, Asif, Zhendong Song, Waqar Riaz, Yizhi Shao, and Xiaozhi Qi. 2026. "TransTCNet: Transformer-Based Temporal-Contextual Network for Low-Latency Typing Interfaces on Edge Devices" Biomimetics 11, no. 5: 337. https://doi.org/10.3390/biomimetics11050337
APA StyleUllah, A., Song, Z., Riaz, W., Shao, Y., & Qi, X. (2026). TransTCNet: Transformer-Based Temporal-Contextual Network for Low-Latency Typing Interfaces on Edge Devices. Biomimetics, 11(5), 337. https://doi.org/10.3390/biomimetics11050337

