hc
2023-11-20 2e7bd41e4e8ab3d1efdabd9e263a2f7fe79bff8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef DUI_MSG_H
#define DUI_MSG_H
#ifdef __cplusplus
extern "C" {
#endif
 
#include <stdbool.h>
#include <sys/time.h>
 
typedef enum {
    //recorder
    RECORDER_CMD_START = 0,
    RECORDER_CMD_STOP,
 
    //以下消息内部使用
 
    //player
    PLAYER_CMD_PLAY,
    //播放结束消息
    PLAYER_INFO_PLAY_END,
    //播放开始
    PLAYER_INFO_PLAY,
    //vad
    VAD_CMD_START,
    VAD_CMD_STOP,
    VAD_CMD_ABORT,
    //检测语音起点超时
    VAD_INFO_TIMEOUT,
    //检测语音起点多次超时
    VAD_INFO_TIMEOUT_REPEAT,
    //检测到语音起点
    VAD_INFO_START,
    //检测到语音结束
    VAD_INFO_END,
    //wakeup
    WAKEUP_CMD_START,
    WAKEUP_CMD_STOP,
    //唤醒角度
    WAKEUP_INFO_DOA,
    //主唤醒词唤醒
    WAKEUP_INFO_WAKEUP,
    //快捷唤醒词唤醒
    WAKEUP_INFO_WAKEUP_MINOR,
    //dds
    //收到云端识别结果
    DDS_INFO_RESULT,
    //多轮对话
    DDS_INFO_SPEECH_CONTINUE,
    //错误
    DDS_INFO_ERROR,
} dui_msg_type_t;
 
typedef enum {
    //提示音
    PLAYER_MODE_PROMPT = 0,
    //合成音
    PLAYER_MODE_TTS,
    //音频
    PLAYER_MODE_AUDIO,
} player_mode_t;
 
typedef struct {
    dui_msg_type_t type;
    union {
        struct {
            int dummy;
        } recorder;
        struct {
            player_mode_t mode;
            char *target;
            bool need_free;
            bool native;
            bool end_session;
        } player;
        struct {
            int doa;
            bool major;
            int index; 
 
            //记录上一次唤醒时间
            struct timeval last_major_time;
            struct timeval last_minor_time;
 
            //记录每次唤醒的时间
            struct timeval cur_major_time;
            struct timeval cur_minor_time;
        } wakeup;
        struct {
            //判断如果VAD检测起点超时情况发生时,是否需要重复播放提示音
            bool timeout_need_prompt;
            //允许循环检测超时的次数
            int timeout_prompt_count;
        } vad;
    };
} dui_msg_t;
 
#ifdef __cplusplus
}
#endif
#endif