本帖最后由 驴友花雕 于 2023-10-25 13:50 编辑
ASRPRO-Plus开发板
板子基本介绍
本例实验的LED模块:
1个电源LED,一个可控制LED(与KEY3共用引脚PA4)。
电原理图(红点处D5为可控制LED)
实验之一:通过语音控制,点亮板载LED灯
- #include "asr.h"
- extern "C"{ void * __dso_handle = 0 ;}
- #include "setup.h"
- #include "myLib/asr_event.h"
-
- uint32_t snid;
-
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- //{speak:阿栋-浑厚男声,vol:20,speed:12,platform:haohaodada}
- //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我。}
- //{playid:10002,voice:我退下了,用智能管家唤醒我}
- void sys_power_on_hook(void){
- vol_set(7);
- }
-
- void ASR_CODE()
- {
- //{ID:500,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在呢,请指示"}
- if(snid == 500){
-
- }
- //{ID:501,keyword:"命令词",ASR:"打开灯光",ASRTO:"好的,灯已打开"}
- if(snid == 501){
- digital_write(4,0);
- }
- //{ID:502,keyword:"命令词",ASR:"关闭灯光",ASRTO:"好的,灯已关闭"}
- if(snid == 502){
- digital_write(4,1);
- }
- //{ID:503,keyword:"命令词",ASR:"还行谢谢",ASRTO:"不客气,欢迎使用AI语音助手"}
- if(snid == 503){
- digital_write(4,1);
- }
- set_state_enter_wakeup(6000);
- }
-
- void setup()
- {
- set_gpio_input(0);
- set_gpio_input(1);
- set_gpio_input(2);
- set_gpio_input(3);
- digital_write(4, 1);
- set_gpio_input(5);
- set_gpio_input(6);
- set_gpio_input(13);
- set_gpio_input(14);
- set_gpio_input(20);
- }
复制代码
天问Block 编程(入门模式)
生成模型
语音模型生成成功
编译下载(烧录程序)
实验场景图
实验记录视频
【实验之一:通过语音控制,点亮板载LED灯】
https://www.bilibili.com/video/BV1fN4y1C7NF/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
实验之二:通过语音识别控制,快闪与慢闪板载LED灯
实验开源代码
- #include "asr.h"
- extern "C"{ void * __dso_handle = 0 ;}
- #include "setup.h"
- #include "myLib/asr_event.h"
-
- uint32_t snid;
- void hardware_init();
-
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- void ASR_CODE()
- {
- //{ID:500,keyword:"命令词",ASR:"灯光快闪五次",ASRTO:"好的,飞快闪五次"}
- if(snid == 500){
- digital_write((4),0);
- delay(500);
- digital_write((4),1);
- delay(500);
- digital_write((4),0);
- delay(500);
- digital_write((4),1);
- delay(500);
- digital_write((4),0);
- delay(500);
- digital_write((4),1);
- delay(500);
- digital_write((4),0);
- delay(500);
- digital_write((4),1);
- delay(500);
- digital_write((4),0);
- delay(500);
- digital_write((4),1);
- }
- //{ID:501,keyword:"命令词",ASR:"灯光慢闪三次",ASRTO:"好的,慢慢闪3次"}
- if(snid == 501){
- digital_write((4),0);
- delay(1000);
- digital_write((4),1);
- delay(1000);
- digital_write((4),0);
- delay(1000);
- digital_write((4),1);
- delay(1000);
- digital_write((4),0);
- delay(1000);
- digital_write((4),1);
- }
- //{ID:502,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在呢,请吩咐"}
- if(snid == 502){
-
- }
- //{ID:503,keyword:"命令词",ASR:"打开灯光",ASRTO:"好的,灯已打开"}
- if(snid == 503){
- digital_write((4),0);
- }
- //{ID:504,keyword:"命令词",ASR:"关闭灯光",ASRTO:"好的,灯已关闭"}
- if(snid == 504){
- digital_write((4),1);
- }
- }
-
- void hardware_init(){
-
- 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 编程(标准模式)
实验视频(56秒)
https://www.bilibili.com/video/BV1L84y1R7wN/?vd_source=98c6b1fc23b2787403d97f8d3cc0b7e5
|