回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

行空板K10————语音识别古诗词 简单

头像 rzegkly 2024.08.27 90 0

一、测试升级

93b7e8b75a764c218d8a493b17e92679_2f343c7dfc766668ff3fab03845e188d.png

假期是一个学习充电的过程

与孩子一起读古诗,一起学习。

今天,对《古诗语音码书项目》升级,

通过行空板K10中语音识别麦克风识别古诗词,

利用TF卡中古诗音频文件,音频播放古诗项目。

本项目融合了传统与现代的优势,为孩子学习古诗词提供了更加便捷、高效的学习体验。

二、  行空板K10microSD卡接口

image.png

 1.K10microSD卡接口存储文件

      支持扩充存储空间,可存储照片(   .png和     .bmp)、音乐(.wav)、录音等数据。

image.png

 

2.K10microSD卡接口可以识别最大32g的SD卡

 

具体操作步骤:对SD卡进行格式化为FAT32。

 

3.WAV文件转换——格式工厂

image.png

三、程序展示

 

1.程序初始化

image.png

2.古诗词语音子程序

image.png
image.png
image.png
image.png

三、语音识别程序

image.png
image.png

四、测试视频

五、测试建议

 

1.行空板TF卡将来支持播放视频文件;

2.行空板k10显示字号可以调节大小;

3.行空板K10播放音频文件时,连续播放三遍。

代码
/*!
 * MindPlus
 * esp32s3bit
 *
 */
#include "asr.h"
#include "unihiker_k10.h"
#include "arduino_image_cache.h"
// 函数声明
void DF_TianJingShaQiuSi();
void DF_GuanCangHai();
void DF_JiangNanFengLiGuiNian();
void DF_CiBeiGuShanXia();
void DF_WenWangChangLingZuoQianLongBiaoYaoYouCiJi();
// 创建对象
UNIHIKER_K10 k10;
ASR          asr;
uint8_t      screen_dir=2;
Music        music;


// 主程序开始
void setup() {
	k10.begin();
	asr.asrInit(CONTINUOUS, CN_MODE, 6000);
	while(asr._asrState == 0){delay(100);}
	k10.initScreen(screen_dir);
	k10.creatCanvas();
	k10.initSDFile();
	asr.addASRCommand(0+1, "qiu si");
	asr.addASRCommand(1+1, "cang hai");
	asr.addASRCommand(2+1, "jiang nan");
	asr.addASRCommand(3+1, "shan xia");
	k10.setScreenBackground(0xFFFFFF);
	k10.canvas->canvasText("行空板", 1, 0x000000);
	k10.canvas->canvasText("——语音识别古诗词", 3, 0x000000);
	k10.canvas->canvasDrawBitmap(70,125,100,100,image_data1);
	k10.canvas->updateCanvas();
	delay(5000);
	k10.rgb->write(-1, 0x000000);
}
void loop() {
	if (asr.isWakeUp()) {
		if (asr.isDetectCmdID(0+1)) {
			k10.rgb->write(-1, 0x00FF00);
			music.playTFCardAudio("S:/tj.wav");
			DF_TianJingShaQiuSi();
		}
		if (asr.isDetectCmdID(1+1)) {
			k10.rgb->write(-1, 0xFF0000);
			music.playTFCardAudio("S:/gc.wav");
			DF_GuanCangHai();
		}
		if (asr.isDetectCmdID(2+1)) {
			k10.rgb->write(-1, 0xFFFF00);
			music.playTFCardAudio("S:/jn.wav");
			DF_JiangNanFengLiGuiNian();
		}
		if (asr.isDetectCmdID(3+1)) {
			k10.rgb->write(-1, 0xCC33CC);
			music.playTFCardAudio("S:/cb.wav");
			DF_CiBeiGuShanXia();
		}
	}
	else {
		k10.rgb->write(-1, 0x000000);
		k10.canvas->canvasText("等待语音指令输入", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
		k10.canvas->updateCanvas();
		delay(2000);
	}
}


// 自定义函数
void DF_TianJingShaQiuSi() {
	k10.canvas->canvasText("天净沙·秋思—马致远", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(4000);
	k10.canvas->canvasText("枯藤老树昏鸦,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(4000);
	k10.canvas->canvasText("小桥流水人家,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(4000);
	k10.canvas->canvasText("古道西风瘦马。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("夕阳西下,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(1000);
	k10.canvas->canvasText("断肠人在天涯。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(4000);
	k10.canvas->canvasText("天净沙·秋思—马致远", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
}
void DF_GuanCangHai() {
	k10.canvas->canvasText("观沧海——曹操", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("东临碣石,以观沧海。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("水何澹澹,山岛竦峙。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("树木丛生,百草丰茂。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("秋风萧瑟,洪波涌起。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("日月之行,若出其中。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3500);
	k10.canvas->canvasText("星汉灿烂,若出其里。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3500);
	k10.canvas->canvasText("幸甚至哉,歌以咏志。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3500);
	k10.canvas->canvasText("观沧海——曹操", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
}
void DF_JiangNanFengLiGuiNian() {
	k10.canvas->canvasText("江南逢李龟年—杜甫", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(4000);
	k10.canvas->canvasText("岐王宅里寻常见,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("崔九堂前几度闻。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("正是江南好风景,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("落花时节又逢君。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("江南逢李龟年—杜甫", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
}
void DF_CiBeiGuShanXia() {
	k10.canvas->canvasText("次北固山下——王湾", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("客路青山外,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(2000);
	k10.canvas->canvasText("行舟绿水前。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(2000);
	k10.canvas->canvasText("潮平两岸阔,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("风正一帆悬。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(2000);
	k10.canvas->canvasText("海日生残夜,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(2000);
	k10.canvas->canvasText("江春入旧年。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("乡书何处达,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("归雁洛阳边。", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(2000);
	k10.canvas->canvasText("次北固山下——王湾", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
}
void DF_WenWangChangLingZuoQianLongBiaoYaoYouCiJi() {
	k10.canvas->canvasText("闻王昌龄左迁龙标遥有此寄——李白", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("杨花落尽子规啼,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("闻道龙标过五溪,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("我寄愁心与明月,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("随君直到夜郎西,", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
	k10.canvas->canvasText("闻王昌龄左迁龙标遥有此寄——李白", 0, 280, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
	k10.canvas->updateCanvas();
	delay(3000);
}

评论

user-avatar