voicevox_client_cpp  0.0.0
A client library for VOICEVOX implemented in C++.
post.hpp
Go to the documentation of this file.
1 #ifndef VOICEVOX_CLIENT_CPP_POST_HPP_
2 #define VOICEVOX_CLIENT_CPP_POST_HPP_
3 #include <optional>
4 
6 
11 
13 {
14 
15 namespace audio_query
16 {
17 
21 class Builder final : public BaseBuilder
22 {
23 public:
27  Builder() : BaseBuilder("/audio_query")
28  {
29  this->method(web::http::methods::POST);
30  }
31 
39  Builder& text(const utility::string_t& text)
40  {
41  this->uri_builder_.append_query("text", text);
42  return *this;
43  }
44 
52  Builder& speaker(const int speaker)
53  {
54  this->uri_builder_.append_query("speaker", speaker);
55  return *this;
56  }
57 
65  Builder& core_version(const std::optional<int>& core_version)
66  {
67  if (core_version != std::nullopt)
68  {
69  this->uri_builder_.append_query("core_version", core_version.value());
70  }
71  return *this;
72  }
73 };
74 
75 extern "C"
76 {
83 
91 
100  const char* text);
101 
110  const int speaker);
111 
120  const int core_version);
121 }
122 
123 } // namespace audio_query
124 
125 namespace synthesis
126 {
127 
131 class Builder final : public BaseBuilder
132 {
133 public:
137  Builder() : BaseBuilder("/synthesis")
138  {
139  this
140  ->method(web::http::methods::POST)
141  .header("accept", "audio/wav")
142  .header("Content-Type", "application/json");
143  }
144 
152  Builder& speaker(const int speaker)
153  {
154  this->uri_builder_.append_query("speaker", speaker);
155  return *this;
156  }
157 
166  {
168  {
169  this->uri_builder_.append_query("enable_interrogative_upspeak", "true");
170  }
171  else
172  {
173  this->uri_builder_.append_query("enable_interrogative_upspeak", "false");
174  }
175  return *this;
176  }
177 
185  Builder& accent_phrases(const web::json::value& accent_phrases)
186  {
187  this->body(accent_phrases);
188  return *this;
189  }
190 
199  {
200  this->body(accent_phrases);
201  return *this;
202  }
203 
211  Builder& core_version(const std::optional<int>& core_version)
212  {
213  if (core_version != std::nullopt)
214  {
215  this->uri_builder_.append_query("core_version", core_version.value());
216  }
217  return *this;
218  }
219 };
220 
221 extern "C"
222 {
229 
237 
246  const int speaker);
247 
256  const bool enable_interrogative_upspeak);
257 
266  const char* accent_phrases);
267 
276  const int core_version);
277 } // extern "C"
278 
279 } // namespace synthesis
280 } // namespace voicevox_client_cpp::request::post
281 #endif // VOICEVOX_CLIENT_CPP_POST_HPP_
Builder & body(const utility::string_t &body)
Set the body of the request. (String type)
Definition: request.hpp:84
Builder & method(const web::http::method &method)
Set HTTP method to request.
Definition: request.hpp:57
Builder & header(const utility::string_t &key, const utility::string_t &value)
Set a header consists of a key and a value.
Definition: request.hpp:71
web::http::uri_builder uri_builder_
URI builder.
Definition: request.hpp:107
A base class for a group of builder classes.
Definition: request.hpp:16
Builder & speaker(const int speaker)
Set the speaker ID to be used for the query to synthesize Japanese speech.
Definition: post.hpp:52
Builder & core_version(const std::optional< int > &core_version)
Set core_version to the request.
Definition: post.hpp:65
Builder & text(const utility::string_t &text)
Set the text to be used for the query to synthesize Japanese speech.
Definition: post.hpp:39
Builder()
Initialize base URI.
Definition: post.hpp:27
A builder for creating requests to obtain audio_query.
Definition: post.hpp:22
Builder & accent_phrases(const char *accent_phrases)
Set the query for speech synthesis included in the response body of the audio_query request.
Definition: post.hpp:198
Builder & speaker(const int speaker)
Set the speaker ID to be used for the query to synthesize Japanese speech.
Definition: post.hpp:152
Builder & accent_phrases(const web::json::value &accent_phrases)
Set the query for speech synthesis included in the response body of the audio_query request.
Definition: post.hpp:185
Builder()
Initialize base URI and headers.
Definition: post.hpp:137
Builder & enable_interrogative_upspeak(const bool enable_interrogative_upspeak)
Set a flag to control whether to raise the intonation at the end when it's a question.
Definition: post.hpp:165
Builder & core_version(const std::optional< int > &core_version)
Set core_version to the request.
Definition: post.hpp:211
A builder for creating requests to obtain audio_query.
Definition: post.hpp:132
void SetPostAudioQueryRequestSpeaker(voicevox_client_cpp::request::post::audio_query::Builder *builder, const int speaker)
Set the speaker ID to be used for the query to synthesize Japanese speech.
void SetPostAudioQueryRequestText(voicevox_client_cpp::request::post::audio_query::Builder *builder, const char *text)
Set the text to be used for the query to synthesize Japanese speech.
voicevox_client_cpp::request::post::audio_query::Builder * CreatePostAudioQueryRequestBuilder()
Get a pointer to the builder for creating a request to obtain audio query.
void DestroyPostAudioQueryRequestBuilder(voicevox_client_cpp::request::post::audio_query::Builder *builder)
Delete the builder for getting audio auery.
void SetPostAudioQueryRequestCoreVersion(voicevox_client_cpp::request::post::audio_query::Builder *builder, const int core_version)
Set cove_version value to request.
void SetPostSynthesisRequestAccentPhrases(voicevox_client_cpp::request::post::synthesis::Builder *builder, const char *accent_phrases)
Set the query for speech synthesis included in the response body of the audio_query request.
void SetPostSynthesisRequestCoreVersion(voicevox_client_cpp::request::post::synthesis::Builder *builder, const int core_version)
Set cove_version value to request.
void SetPostSynthesisRequestEnableInterrogativeUpspeak(voicevox_client_cpp::request::post::synthesis::Builder *builder, const bool enable_interrogative_upspeak)
Set a flag to control whether to raise the intonation at the end when it's a question.
void DestroyPostSynthesisRequestBuilder(voicevox_client_cpp::request::post::synthesis::Builder *builder)
Delete the builder for getting synthesized data.
void SetPostSynthesisRequestSpeaker(voicevox_client_cpp::request::post::synthesis::Builder *builder, const int speaker)
Set the speaker ID to be used for the query to synthesize Japanese speech.
voicevox_client_cpp::request::post::synthesis::Builder * CreatePostSynthesisRequestBuilder()
Get a pointer to the builder for creating a request to obtain synthesized data.
Definition: post.hpp:13