实验之六:语音控制WS2812B,实现单个灯珠的颜色变化
实验开源代码
- #include "asr.h"
- extern "C"{ void * __dso_handle = 0 ;}
- #include "setup.h"
- #include "myLib/asr_event.h"
- #include "myLib/asr_ws2812.h"
-
- uint32_t snid;
- void hardware_init();
-
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- WS2812 ASR_WS2812_27(27);
- void ASR_CODE()
- {
- //{ID:500,keyword:"命令词",ASR:"打开灯光",ASRTO:"灯光已打开"}
- if(snid == 500){
- ASR_WS2812_27.pixel_set_all_color(200,200,200);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:501,keyword:"命令词",ASR:"关闭灯光",ASRTO:"灯光已关闭"}
- if(snid == 501){
- ASR_WS2812_27.pixel_set_all_color(0,0,0);
- ASR_WS2812_27.pixel_show();
- digital_write(4,1);
- }
- //{ID:502,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在呢"}
- if(snid == 502){
- digital_write(4,0);
- }
- //{ID:503,keyword:"命令词",ASR:"不错呀",ASRTO:"谢谢夸奖"}
- if(snid == 503){
-
- }
- //{ID:504,keyword:"命令词",ASR:"彩虹呼吸",ASRTO:"已执行"}
- if(snid == 504){
- ASR_WS2812_27.rainbowCycle(5);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:505,keyword:"命令词",ASR:"还有什么变化",ASRTO:"三个灯不同颜色"}
- if(snid == 505){
-
- }
- //{ID:506,keyword:"命令词",ASR:"那我试试",ASRTO:"请开始你的表演"}
- if(snid == 506){
-
- }
- //{ID:507,keyword:"命令词",ASR:"红蓝绿",ASRTO:"红蓝绿灯已打开"}
- if(snid == 507){
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(0,255,0,0);
- ASR_WS2812_27.setBrightness(250);
- ASR_WS2812_27.pixel_set_color(1,0,0,255);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(2,0,255,0);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:508,keyword:"命令词",ASR:"红灯",ASRTO:"一个灯"}
- if(snid == 508){
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(0,255,0,0);
- ASR_WS2812_27.setBrightness(0);
- ASR_WS2812_27.pixel_set_color(1,0,136,255);
- ASR_WS2812_27.setBrightness(0);
- ASR_WS2812_27.pixel_set_color(2,136,0,255);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:509,keyword:"命令词",ASR:"蓝红绿",ASRTO:"蓝红绿灯已打开"}
- if(snid == 509){
- ASR_WS2812_27.setBrightness(250);
- ASR_WS2812_27.pixel_set_color(0,0,0,255);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(1,255,0,0);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(2,0,255,0);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:510,keyword:"命令词",ASR:"蓝灯",ASRTO:"二个灯"}
- if(snid == 510){
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(0,0,0,255);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(1,0,0,255);
- ASR_WS2812_27.setBrightness(0);
- ASR_WS2812_27.pixel_set_color(2,255,255,0);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:511,keyword:"命令词",ASR:"绿蓝红",ASRTO:"绿蓝红灯已打开"}
- if(snid == 511){
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(0,0,255,0);
- ASR_WS2812_27.setBrightness(250);
- ASR_WS2812_27.pixel_set_color(1,0,0,255);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(2,255,0,0);
- ASR_WS2812_27.pixel_show();
- }
- //{ID:512,keyword:"命令词",ASR:"绿灯",ASRTO:"三个灯"}
- if(snid == 512){
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(0,0,255,0);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(1,0,255,0);
- ASR_WS2812_27.setBrightness(200);
- ASR_WS2812_27.pixel_set_color(2,0,255,0);
- ASR_WS2812_27.pixel_show();
- }
- }
-
- void hardware_init(){
- ASR_WS2812_27.pixel_init(3);
- vTaskDelete(NULL);
- }
-
- void setup()
- {
- //{speak:橙子-甜美客服,vol:20,speed:10,platform:haohaodada}
- //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
- //{playid:10002,voice:我要退下了,用智能管家唤醒我}
- digital_write((4),1);
- xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
- }
复制代码
天问Block(标准模式)训练模型与编译烧录
实验记录视频
https://www.bilibili.com/video/BV1Dj411a74d/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
|