《【开发教程12】AI语音人脸识别(会议记录仪/人脸打卡机)-语音传输与解析显示.docx》由会员分享,可在线阅读,更多相关《【开发教程12】AI语音人脸识别(会议记录仪/人脸打卡机)-语音传输与解析显示.docx(15页珍藏版)》请在第一文库网上搜索。
1、CC3200AI实验教程疯壳开发板系列W olverine-Team2018/07/1:目录官网地址:http:www.fenHke.club淘宝店: 官方 QQ 群:193836402官网地址:http:/www.fengke.club购买链接:http:官方 QQ 群:193836402语音传输与解析显示TLV320Ale3254支持12c和SPI接口,这里用到12c对TLV320Ale3254的寄存器进行配置,用IAR打开AI_ASR里面的工程,如图1.0.1所示为CC3200初始化l2C部分代码。intI2C_IF_0pen (unsigned long ulMede)( 一 一/ E
2、nable I2C Peripheral/MAP_HvSemaphoreLock (HWSEM_I2Cr HWSEM_WAIT_FOR_EVER);MAP_PRCMPeripher a 1C1 kEnable7PRCM_12CA07 Pr61_RUN_M0DE_CLK);MAP_PRCMPeripheralReset (PRCM_I2CA0);/ Configure I2C module in the specified mode/switch (ulMode)(case I2C_MASTER_MODE_STD:/* 100000 */MAP_I2CMasterInitExpClk (I2C_
3、BASE, SYS_CLK, false);break;case I2C_MASTER_MODE_FST:/* 400000 */MAP_I2CMasterInitExpClk (I2C_BASEr SYS_CLKr true);break;default:MAP_I2CMasterInitExpClk(I2C_BASEf SYS_CLKr true);break;/ Disables the multi-master mode/MAP_I2CMasterDisable (I2C_BASE);return SUCCESS;图1.0.1初始化PC部分代码对TLV320AIC3254的初始化函数,
4、如图102所示。/ Configure Andjo Codec/AudioCodecReset (AUDI0_C0DEC_TI_3254, NULL);#if defined (USE_ONBOARD_MIC)/AudioCodecConfig (AUDI0_C0DEC_TI_3254, AUDIO_CODEC_16_BIT, 16000,AUDIO_CODEC_STEREO, AUDIO_CODEC_SPEAKER_ALL,AUDIO_CODEC_MIC_ALL);音量调整0100 一 一 一AudioCodecSpeakerVolCtri (AUDI0_C0DEC_TI_3254, AUD
5、IO_CODEC_SPEAKER_ALL, 95);AudioCodecMicVolCtri (AUDI0_C0DEC_TI_3254, AUDIO_CODEC_MIC_ALL, 95);图 1.0.2 TLV320AIC3254 初始化官网地址:http:www.fengke.dub淘宝店: 官方 QQ 群:193836402通过该函数可以设置设备的ID、采样位数、采样速率、音频通道、音频输出以及音频输入的增益。本次实验使用UDP连接的方式进行通信。使用CC3200配置为UDP模式的代码如图1.0.3所示。long CreateUdpServer (tUDPSocket *pSock)(in
6、t uiPort = AUDIO_PORT;long IRetVal = -1;pSock-iSockDesc = socket (AF.INET, SOCK_DGRAM, 0);pSock-Server. sin_amily = AF_INET;pSockServer. sin_addr. s_addr = htonl (INADDR_AKY);pSock-Server. sin_port = htons (uiPort);pS o ck- i S er ver Length = si zeof (pSock-Server);pSock-Client. sin_family = AFJNET
7、;pSock-Xli ent. sin_addr. s_addr - htonl (INVALID_CLIENT_ADDRESS);pSock-Xli ent. sin_port = htons (uiPort);pSockiCli entLength = si zeof (pSockXli ent);IRetVal = bind (pSockiSockDesc (struct s o ckaddr ) & IjiS o ck S er ver ),pS o ck* i S erverLength);ASSERT_ON_ERROR QRetVal);return SUCCESS;图1.0.3
8、CC3200U配置UDP模式WEP 或者 WPAotdefine SSIDJIAME#define SECURITY_TYPEdefine SECURITY-KEYtdefine SSID_LEN_MAXidefine BSSID_LEN_MAX打开common.h,连接的路由器名称及密码如图104所示,特别注意的是要修改加密方式OPEN、nfengke2.4Gn /* AP SSID /SL_SEC_TYPE_WPA/* Security type (OPEN or WEP or iPA*/nfengke305ft/* Passvord of the secured AP */326图1.0
9、.4路由器相关信息连接服务器的IP地址及端口如图1.0,5所示。在network.c找至IHOST_IP_ADDR可在宏定义中修改IP地址,修改usPort的值可以修改端口。官网地址:http:/www.fengke.dub 淘宝店: 官方 QQ 群:1938364022audioCodec.h | audiocodec.c | pinmux.c | control.c neb/vorKc speaker.c | network.h | user.h | osi./Speaker De tec ted - Add Clsen tg_UdpSock. Client, sin-family = A
10、F_INE1j|,g_UdpSock. Client. sin_addr. s_addr = htom (pAddr);g_UdpSock. Client. sin_port = htons (usPort);g_UdpSock. iClientLength = sizeo(g_UdpSock. Client);g_loopback = 0;MAF_UtilsDelay (80*1000*100);#elseunsigned int pAddr=HOST_IP_ADDR;unsigned long usPort=8082;char cCmdBuff20 = 0:,图1.0.5服务器的IP地址及
11、端口IP地址用16进制来表示,例如:“192”对应16进制的“0xc0”、“168”对应16进制的“0xa8”、“05” 对应 16 进制的 “0x05”、“05” 对应 16 进制的 “0x05”,合起来就是 0xc0a80505 (192.168.5.5)0Network任务主要是实现网络连接,所以该任务主要实现CC3200连接上路由器,建立UDP。任务如图1.0.6所示。官网地址:http:/www.fengke.club 淘宝店: 官方 QQ 群:1938364025void Network ( void *pvParamet ers )a long IRetVal = -1 ;UAR
12、T_PRINT (Network 1 rn);/Initialize G1obal Vari ableInit ializeAppVariables():UART_PRINT(Network 2 rrT):/Connect to NetworkIRetVal = ConnectToNetwork();if (IRetVal 0)3UART_PR工NT(Failed to establish connection w/ an AP rn):LOOP.FOREVERO ;- _elsea(UART_PRINT(Establish connection w/ an AP rn);- UART_PRI
13、NT(*Network 3 rn);/Cread UDP Socket and Bind to Local IP AddressIRetVal = CreateUdpServer(&g_UdpSock);if (IRetVal 0)3UART_PR工NT(Failed to Create UDP Server rn);LOOP.FOREVERO :UART.PRINT (Network 4 rn):3 #ifdef MULTICAST/Add to Multicast GroupIRetVal = Re ceiveMulti cast Packet ():if (IRetVal 0)3UART
14、.PRINT(Failed to Create UDP Server rn);LOOP.FOREVERO ;- /Delete the Networking Task as Service Discovery is not neededo s T askD e1et e(& g_Net wo rk T ask);#else/Discover CC3200 Audio DevicesmDNS.TaskO :-#endif图 1.0.6 Network 任务在ConnectToNetwork。函数内有一个函数WlanConnect()通过该函数可以连接上Common.h的宏定义中的路由器,WlanConnect。函数如图1.0.7所示。static long JVlanConnect ()SlSecParams_t secParams = 0;long IRetVal = 0;secParams. Key - (si gned char*)SECURITY_KEY;secParams. KeyLen = strien (SECURITY_KEY);secPar