/*
 * Copyright 2024 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef __KYLIN_AI_SPEECH_RESULT_H__
#define __KYLIN_AI_SPEECH_RESULT_H__

#include <common/macros.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    // 出错
    SPEECH_ERROR_OCCURRED = 1,
    // 已启动语音识别
    SPEECH_RECOGNITION_STARTED = 2,
    // 正在进行语音识别，中间结果
    SPEECH_RECOGNIZING = 3,
    // 语音识别的最终结果，经过修正
    SPEECH_RECOGNIZED = 4,
    // 语音识别完成
    SPEECH_RECOGNITION_COMPLETED = 5,
    // 已启动语音合成
    SPEECH_SYNTHESIS_STARTED = 6,
    // 正在进行语音合成，语音合成的结果输出
    SPEECH_SYNTHESIZING = 7,
    // 语音合成已经完成
    SPEECH_SYNTHESIS_COMPLETED = 8,
} SpeechResultReason;

typedef struct _SpeechRecognitionResult SpeechRecognitionResult;

AISDK_EXTERN
SpeechResultReason speech_recognition_result_get_reason(
    SpeechRecognitionResult *result);

AISDK_EXTERN
const char *speech_recognition_result_get_text(SpeechRecognitionResult *result);

AISDK_EXTERN
int speech_recognition_result_get_speaker_id(SpeechRecognitionResult *result);

AISDK_EXTERN
int speech_recognition_result_get_error_code(SpeechRecognitionResult *result);

AISDK_EXTERN
const char *speech_recognition_result_get_error_message(
    SpeechRecognitionResult *result);

typedef struct _SpeechSynthesisResult SpeechSynthesisResult;

AISDK_EXTERN
SpeechResultReason speech_synthesis_result_get_reason(
    SpeechSynthesisResult *result);

AISDK_EXTERN
const char *speech_synthesis_result_get_audio_format(
    SpeechSynthesisResult *result);

AISDK_EXTERN
int speech_synthesis_result_get_audio_rate(SpeechSynthesisResult *result);

AISDK_EXTERN
int speech_synthesis_result_get_audio_channel(SpeechSynthesisResult *result);

AISDK_EXTERN
const uint8_t *speech_synthesis_result_get_data(SpeechSynthesisResult *result,
                                                uint32_t *data_length);

AISDK_EXTERN
int speech_synthesis_result_get_error_code(SpeechSynthesisResult *result);

AISDK_EXTERN
const char *speech_synthesis_result_get_error_message(
    SpeechSynthesisResult *result);

typedef void (*SpeechRecognitionResultCallback)(SpeechRecognitionResult *result,
                                                void *user_data);
typedef void (*SpeechSynthesisResultCallback)(SpeechSynthesisResult *result,
                                              void *user_data);

#ifdef __cplusplus
}
#endif

#endif
