80 lines
1.9 KiB
C
80 lines
1.9 KiB
C
#include "server/audio_server.h"
|
|
#include "server/server_core.h"
|
|
#include "system/app_core.h"
|
|
#include "generic/circular_buf.h"
|
|
#include "os/os_api.h"
|
|
#include "app_config.h"
|
|
#include "system/includes.h"
|
|
#include "wifi/wifi_connect.h"
|
|
#include "syscfg/syscfg_id.h"
|
|
#include "storage_device.h"
|
|
#include "fs/fs.h"
|
|
#include <time.h>
|
|
#include "device/device.h"
|
|
#include "asm/clock.h"
|
|
#include "spiflash.h"
|
|
#include "asm/sfc_norflash_api.h"
|
|
#include "event/device_event.h"
|
|
|
|
#define DOUBAO
|
|
#ifdef DOUBAO
|
|
|
|
extern void asr_websocket_client_thread_create(void);
|
|
extern void websockets_asr_client_request_handle_create(void);
|
|
extern void http_chat_task_create(void);
|
|
extern void tts_websocket_client_thread_create(void);
|
|
|
|
|
|
static void doubao_start(void *priv)
|
|
{
|
|
enum wifi_sta_connect_state state;
|
|
FILE *f;
|
|
while (1) {
|
|
os_time_dly(500);
|
|
printf("Connecting to the network...\n");
|
|
state = wifi_get_sta_connect_state();
|
|
if (WIFI_STA_NETWORK_STACK_DHCP_SUCC == state) {
|
|
printf("Network connection is successful!\n");
|
|
break;
|
|
}else{
|
|
f = fopen("mnt/sdfile/res/ai_res/con_net.mp3", "r");
|
|
if (!f) {
|
|
printf("fopen err!\n");
|
|
}else{
|
|
extern int playback_file(FILE *res);
|
|
|
|
playback_file(f);
|
|
}
|
|
}
|
|
}
|
|
asr_websocket_client_thread_create();
|
|
websockets_asr_client_request_handle_create();
|
|
http_chat_task_create();
|
|
tts_websocket_client_thread_create();
|
|
|
|
msleep(3000);
|
|
|
|
f = fopen("mnt/sdfile/res/ai_res/bootsound.amr", "r");
|
|
if (!f) {
|
|
printf("fopen err!\n");
|
|
}else{
|
|
extern int playback_file(FILE *res);
|
|
|
|
playback_file(f);
|
|
}
|
|
}
|
|
//程序入口
|
|
static int doubao_init_task(void)
|
|
{
|
|
|
|
if (thread_fork("doubao_start", 10, 512, 0, NULL, doubao_start, NULL) != OS_NO_ERR) {
|
|
printf("thread fork fail\n");
|
|
}
|
|
}
|
|
late_initcall(doubao_init_task);
|
|
|
|
#endif //PLAYBACK
|
|
|
|
|
|
|