#ifndef RECORDER_H
#define RECORDER_H

#include <QtMultimedia/QAudioFormat>
#include <QtMultimedia/QAudioInput>

#include <QObject>
#include <QAudioRecorder>//录音
#include <QAudioEncoderSettings>//音频编码器
#include <QAudioBuffer>//音频缓存
#include <QAudioProbe> //音频探针
#include <QUdpSocket> //UDP套接字
#include <QHostAddress> //主机地址
#include <QUrl> //文件地址
#include <QAudioEncoderSettings>
#include <QFile>
#include <QBuffer>

#include <kylin-ai/coreai/speech/recognizer.h>
#include <kylin-ai/coreai/speech/audioconfig.h>
#include <kylin-ai/coreai/speech/error.h>
#include <kylin-ai/coreai/speech/result.h>
#include "msgpane.h"


#define TEST 1

class Recorder : public QObject
{
    Q_OBJECT
public:
    explicit Recorder(QObject *parent = nullptr);
    ~Recorder();
    void startRecord();
    void stopRecord();
    void closeSession();

signals:
    void sigSendTmpMsg(const QString str);  //语音识别中的结果
    void sigSendMsg(const QString str);     //语音识别修正后的结果
    void reply(const QString &message, bool is_end, int index, int errorCode, QString model = "");
    void sigCancelSendVoice();  //取消语音输入
    void sigIsStartTimer();     //向前端发送信号，启动30s计时器

private:
    bool initSession();

private:
    SpeechRecognitionSession *session = nullptr;
    AudioConfig *config = nullptr;
    QAudioDeviceInfo devInfo;

};

#endif // RECORDER_H
