61 lines
1.3 KiB
C
Raw Normal View History

2024-01-08 23:37:00 +08:00
#ifndef EBYROID_H
#define EBYROID_H
2024-04-02 15:36:52 +08:00
namespace ebyroid
{
// forward-declaration to avoid including api_adapter.h
class ApiAdapter;
struct ConvertParams
{
bool needs_reload;
char *base_dir;
char *voice;
float volume;
};
class Ebyroid
{
public:
Ebyroid(const Ebyroid &) = delete;
Ebyroid(Ebyroid &&) = delete;
~Ebyroid();
2025-01-07 22:03:39 +08:00
static Ebyroid *Create(const std::string &base_dir, const std::string &dllpath, const std::string &voice);
2025-01-02 22:56:39 +08:00
int Hiragana(const char *inbytes, std::vector<char> &);
int Speech(const char *inbytes, std::vector<int16_t> &, uint32_t mode = 0u);
2024-04-02 15:36:52 +08:00
private:
Ebyroid(ApiAdapter *api_adapter) : api_adapter_(api_adapter) {}
ApiAdapter *api_adapter_;
2025-01-07 22:03:39 +08:00
public:
void Setparam(float volume, float speed, float pitch);
2024-04-02 15:36:52 +08:00
};
2025-01-02 22:56:39 +08:00
template <typename T>
2024-04-02 15:36:52 +08:00
class Response
{
public:
2025-01-02 22:56:39 +08:00
Response(ApiAdapter *adapter) : api_adapter_(adapter)
{
event.Create(NULL, FALSE, FALSE, NULL);
}
void Write(T *bytes, size_t size)
{
buffer_.insert(std::end(buffer_), bytes, bytes + size);
}
std::vector<T> End()
{
return std::move(buffer_);
}
2024-04-02 15:36:52 +08:00
ApiAdapter *api_adapter() { return api_adapter_; };
2025-01-02 22:56:39 +08:00
CEvent event;
2024-04-02 15:36:52 +08:00
private:
ApiAdapter *api_adapter_;
2025-01-02 22:56:39 +08:00
std::vector<T> buffer_;
2024-04-02 15:36:52 +08:00
};
} // namespace ebyroid
#endif // EBYROID_H