-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathopenmoss_server.h
More file actions
68 lines (55 loc) · 2.2 KB
/
Copy pathopenmoss_server.h
File metadata and controls
68 lines (55 loc) · 2.2 KB
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
#pragma once
#include "lemon/backends/backend_registry.h"
#include "lemon/wrapped_server.h"
#include "lemon/server_capabilities.h"
#include "lemon/backends/backend_utils.h"
#include <map>
#include <mutex>
#include <string>
#include <utility>
#include <vector>
namespace lemon {
namespace backends {
class OpenMossServer : public WrappedServer,
public ITextToSpeechServer,
public IAudioGenerationServer {
public:
static InstallParams get_install_params(const std::string& backend, const std::string& version);
OpenMossServer(const std::string& log_level,
ModelManager* model_manager,
BackendManager* backend_manager);
~OpenMossServer() override;
void load(const std::string& model_name,
const ModelInfo& model_info,
const RecipeOptions& options,
bool do_not_upgrade) override;
void unload() override;
void audio_speech(const json& request, httplib::DataSink& sink) override;
void audio_generations(const json& request, httplib::DataSink& sink) override;
std::vector<std::string> supported_audio_formats() const override { return {"wav"}; }
private:
struct Subprocess {
ProcessHandle handle;
int port = 0;
};
std::string resolve_binary_path(const std::string& backend);
Subprocess spawn(const std::string& model_path);
// The voice-design model is a component of the speech model, but
// moss-tts-server hosts exactly one --model per process. It is spawned only
// to render a reference sample and torn down immediately, so steady-state
// residency stays at the speech model alone.
std::string design_reference_sample(const std::string& voice_description);
json apply_voice_design(const json& request);
std::string exe_path_;
std::string voicegen_path_;
std::map<std::string, std::string> reference_cache_;
std::vector<std::pair<std::string, std::string>> env_vars_;
std::mutex design_mutex_;
};
namespace openmoss {
std::unique_ptr<WrappedServer> create(const BackendContext& ctx);
const BackendSpec* spec();
const BackendOps* ops();
} // namespace openmoss
} // namespace backends
} // namespace lemon