代码拉取完成,页面将自动刷新
#ifndef WHISPER_STREAM_COMPONENTS_OUTPUT_H
#define WHISPER_STREAM_COMPONENTS_OUTPUT_H
#include <memory>
#include <iostream>
#include "whisper.h"
#include "stream_components_params.h"
/**
* Classes that support componentization of the service.
* These classes support encoding the service state and the transcription
* into JSON (and in the future, into other formats such as msgpack,
* flexbuffers, etc.)
*/
namespace stream_components {
class WhisperEncoder {
public:
virtual void reset() = 0;
virtual void start_arr(const char *name) = 0;
virtual void end_arr(bool end) = 0;
virtual void start_obj(const char *name) = 0;
virtual void end_obj(bool end) = 0;
virtual void start_value(const char *name) = 0;
virtual void value_s(const char *name, const char *val, bool end) = 0;
virtual void end_value(bool end) = 0;
virtual void value_i(const char *name, const int64_t val, bool end) = 0;
virtual void value_b(const char *name, const bool val, bool end) = 0;
virtual void value_f(const char *name, const float val, bool end) = 0;
};
class WhisperEncoderJSON : public WhisperEncoder {
public:
WhisperEncoderJSON(std::ostream &os) : fout(os) {}
void reset() override { indent = 0; }
void start_arr(const char *name) override;
void end_arr(bool end) override;
void start_obj(const char *name) override;
void end_obj(bool end) override;
void start_value(const char *name) override;
void value_s(const char *name, const char *val, bool end) override;
void end_value(bool end) override;
void value_i(const char *name, const int64_t val, bool end) override;
void value_b(const char *name, const bool val, bool end) override;
void value_f(const char *name, const float val, bool end) override;
protected:
std::ostream &fout;
int indent = 0;
void doindent();
};
class WhisperStreamOutput {
public:
WhisperStreamOutput(
struct whisper_context *ctx,
const service_params ¶ms);
static void encode_server(WhisperEncoder &encoder, const service_params ¶ms, struct whisper_context *ctx);
void encode_transcription(WhisperEncoder &encoder) const;
static void to_json(std::ostream &os, const service_params ¶ms, struct whisper_context *ctx);
void transcription_to_json(std::ostream &os) const;
protected:
struct whisper_context *ctx;
const service_params params;
};
using WhisperOutputPtr = std::shared_ptr<WhisperStreamOutput>;
} // namespace stream_components
#endif // WHISPER_STREAM_COMPONENTS_OUTPUT_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。