轻量级高斯注意力在嵌入式语音唤醒中的应用与性能优化Lightweight Gaussian Attention: Application and Performance Optimization in Embedded Keyword Spotting
李志为,麦启聪,钟清华,王德明,张洋祥
摘要(Abstract):
关键词唤醒(Keyword Spotting,KWS)是实现自然人机语音交互的基础技术,但在计算和存储资源有限的嵌入式设备上,现有深度KWS模型在识别准确率与运行开销之间仍存在难以兼顾的矛盾,尤其是标准自注意力机制计算复杂度高、难以直接部署。为解决上述问题,文章提出一种基于通道-时间高斯加权池化(Channel-Temporal Gaussian Weighted Pooling,CTGWP)机制的轻量级关键词唤醒模型(GWP):首先,提出CTGWP机制,并在基线轻量卷积神经网络(Baseline Convolutional Neural Network,Baseline CNN)中,以CTGWP机制替代全局平均池化,在参数规模基本不变的前提下引入一维高斯时间注意力,以聚焦有效语音片段;接着,引入SpecAugment数据增强方法、AdamW优化器及带预热的余弦退火学习率策略,以提升模型训练的稳定性和泛化能力。为验证GWP模型的识别性能,在Google Speech Commands v2数据集上,将GWP模型与Baseline CNN、轻量级时序卷积残差网络(TC-ResNet8)进行对比实验;并采用TensorFlow Lite将GWP模型量化为INT8格式,在Raspberry Pi 5平台上完成部署测试。实验结果表明:与Baseline CNN和TC-ResNet8相比,GWP模型的整体准确率分别提高了0.88、0.21个百分点,错误接受率(False Acceptance Rate,FAR)分别降低了0.26、0.09个百分点,错误拒绝率(False Rejection Rate,FRR)分别降低了0.84、0.28个百分点;在Raspberry Pi 5平台上,与TensorFlow Lite 32位浮点版本(TFLite FP32)相比,GWP模型的INT8版本的平均推理时延降低了1.83 ms,CPU利用率降低了4.6个百分点,模型大小减少了0.29 MB,运行内存增加了1.0 MB。结果表明,在BaselineCNN中引入CTGWP机制,能够在识别可靠性与部署成本之间取得了较好的平衡,体现了其在资源受限端侧设备上的部署可行性和应用价值。
关键词(KeyWords): 语音唤醒;嵌入式系统;轻量级模型;注意力机制;高斯注意力;性能优化;模型量化
基金项目(Foundation): 国家重点研发计划项目(2021ZD0114600);; 广东省基础与应用基础研究基金项目(2023A1515140187)
作者(Author): 李志为,麦启聪,钟清华,王德明,张洋祥
参考文献(References):
- [1] Warden P.Speech commands:a dataset for limited-vocabulary speech recognition[J/OL].arXiv,(2018-04-09)[2025-07-16].https://arxiv.org/abs/1804.03209.
- [2] Zhang Y D,Suda N,Lai L,et al.Hello edge:keyword spotting on microcontrollers[J/OL].arXiv,(2017-11-20)[2025-07-15].https://arxiv.org/abs/1711.07128.
- [3] Paszke A,Gross S,Massa F,et al.PyTorch:an imperative style,high-performance deep learning library[C]//Advances in Neural Information Processing Systems 32.Red Hook,NY:Curran Associates,Inc,2019:8024-8035.
- [4] 赵泽宇,张卫强,刘加.采用注意力机制和多任务训练的端到端无语音识别关键词检索系统[J].信号处理,2020,36(6):839-851.Zhao Z Y,Zhang W Q,Liu J.End-to-end keyword search system based on attention mechanism and multitask learning[J].Journal of Signal Processing,2020,36(6):839-851.
- [5] 李双峰.TensorFlow Lite:端侧机器学习框架[J].计算机研究与发展,2020,57(9):1839-1853.Li S F.TensorFlow Lite:on-device machine learning framework[J].Journal of Computer Research and Deve-lopment,2020,57(9):1839-1853.
- [6] Choi S,Seo S,Shin B,et al.Temporal convolution for real-time keyword spotting on mobile devices[C]//Procee-dings of Interspeech 2019.Graz:ISCA,2019:3372-3376.
- [7] Svirsky J,Shaham U,Lindenbaum O.Sparse binarization for fast keyword spotting[C]//Proceedings of Interspeech 2024.Kos:ISCA,2024:3010-3014.
- [8] Shen Y,Wu B,Straeussnigg D,et al.A KWS system for edge-computing applications with analog-based feature extraction and learned step size quantized classifier[J].Sensors,2025,25(8):2550.
- [9] Rahothvarmam P,Mamidi R.Towards efficient audio-text keyword spotting:quantization and multi-scale linear attention with foundation models[C]//Proceedings of the 21st International Conference on Natural Language Processing.Chennai:NLP Association of India,2024:264-268.
- [10] Kim B,Chang S,Lee J,et al.Broadcasted residual lear-ning for efficient keyword spotting[C]//Proceedings of Interspeech 2021.Brno:ISCA,2021:4538-4542.
- [11] Li X M,Wei X D,Qin X W.Small-footprint keyword spotting with multi-scale temporal convolution[C]//Proceedings of Interspeech 2020.Shanghai:ISCA,2020:1987-1991.
- [12] Majumdar S,Ginsburg B.MatchboxNet:1D time-channel separable convolutional neural network architecture for speech commands recognition[C]//Proceedings of Interspeech 2020.Shanghai:ISCA,2020:3356-3360.
- [13] Xu M L,Zhang X L.Depthwise separable convolutional ResNet with squeeze-and-excitation blocks for small-footprint keyword spotting[C]//Proceedings of Interspeech 2020.Shanghai:ISCA,2020:2547-2551.
- [14] Hu J,Shen L,Sun G.Squeeze-and-excitation networks[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition.Salt Lake City:IEEE,2018:7132-7141.
- [15] Wang Z Y,Kong S Y,Wan L,et al.Query-by-example keyword spotting using spectral-temporal graph attentive pooling and multi-task learning[C]//Proceedings of Interspeech 2024.Kos:ISCA,2024:322-326.
- [16] Pham H V,Vu T P,Nguyen H T,et al.Lightweight keyword spotting with inter-domain interaction and attention for real-time voice-controlled robotics[J].EAI Endorsed Transactions on AI and Robotics,2025,4:7877.
- [17] Vaswani A,Shazeer N,Parmar N,et al.Attention is all you need[C]//Advances in Neural Information Proces-sing Systems 30.Red Hook,NY:Curran Associates,Inc,2017:5998-6008.
- [18] Peng J Y,Gu R Z,Zhang H R,et al.Context-adaptive Gaussian attention for text-independent speaker verification[C]//Proceedings of the 12th Asia-Pacific Signal and Information Processing Association Annual Summit and Conference.Auckland:IEEE,2020:595-599.
- [19] Sainath T N,Parada C.Convolutional neural networks for small-footprint keyword spotting[C]//Proceedings of Interspeech 2015.Dresden:ISCA,2015:1478-1482.
- [20] 杨润延,程高峰,刘建.基于端到端语音识别的关键词检索技术研究[J].计算机科学,2022,49(1):53-58.Yang R Y,Cheng G F,Liu J.Study on keyword search framework based on end-to-end automatic speech recognition[J].Computer Science,2022,49(1):53-58.
- [21] Simonyan K,Zisserman A.Very deep convolutional networks for large-scale image recognition[J/OL].arXiv,(2015-04-10)[2025-07-16].https://arxiv.org/abs/1409.1556
- [22] Ioffe S,Szegedy C.Batch normalization:accelerating deep network training by reducing internal covariate shift[C]//Proceedings of the 32nd International Conference on Machine Learning.Lille:PMLR,2015:448-456.
- [23] Nair V,Hinton G E.Rectified linear units improve restricted Boltzmann machines[C]//Proceedings of the 27th International Conference on Machine Learning.Haifa:Omnipress,2010:807-814.
- [24] Lin M,Chen Q,Yan S C.Network in network[J/OL].ar-Xiv,(2014-05-04)[2025-07-16].https://arxiv.org/abs/1312.4400.
- [25] Saeed A.Binary early-exit network for adaptive inference on low-resource devices[C]//Proceedings of Interspeech 2022.Incheon:ISCA,2022:516-520.
- [26] Sainath T N,Mohamed A R,Kingsbury B,et al.Deep convolutional neural networks for LVCSR[C]//Procee-dings of the 2013 IEEE International Conference on Acoustics,Speech and Signal Processing.Vancouver:IEEE,2013:8614-8618.
- [27] Loshchilov I,Hutter F.Decoupled weight decay regularization[J/OL].arXiv,(2017-11-14)[2025-07-16].https://arxiv.org/abs/1711.05101.
- [28] Loshchilov I,Hutter F.SGDR:stochastic gradient descent with warm restarts[J/OL].arXiv,(2016-08-13)[2025-07-16].https://arxiv.org/abs/1608.03983.
- [29] Park D S,Chan W,Zhang Y,et al.SpecAugment:a simple data augmentation method for automatic speech recognition[C]//Proceedings of Interspeech 2019.Graz:ISCA,2019:2613-2617.
- [30] David R,Duke J,Jain A,et al.TensorFlow Lite Micro:embedded machine learning for TinyML systems[C]//Proceedings of Machine Learning and Systems.San Jose:Systems and Machine Learning Foundation,2021:800-811.