Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions docs/openrpc/openrpc/text_to_speech.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@
"type": "string"
},
"required": true
},
{
"name": "callSign",
"summary": "Optional call sign for the app making the request",
"schema": {
"type": "string"
}
},
{
"name": "language",
"summary": "Optional language override as a BCP 47 locale tag",
"schema": {
"type": "string"
}
},
{
"name": "voice",
"summary": "Optional voice identifier",
"schema": {
"type": "string"
}
},
{
"name": "volume",
"summary": "Optional volume override",
"schema": {
"type": "string"
}
},
{
"name": "rate",
"summary": "Optional speech rate override",
"schema": {
"type": "string"
}
},
{
"name": "pitch",
"summary": "Optional pitch override",
"schema": {
"type": "string"
}
}
],
"tags": [
Expand Down Expand Up @@ -45,6 +87,30 @@
{
"name": "text",
"value": "I am a text waiting for speech."
},
{
"name": "callSign",
"value": "AppA"
},
{
"name": "language",
"value": "en-US"
},
{
"name": "voice",
"value": "female-1"
},
{
"name": "volume",
"value": "80"
},
{
"name": "rate",
"value": "normal"
},
{
"name": "pitch",
"value": "medium"
}
],
"result": {
Expand Down
66 changes: 66 additions & 0 deletions docs/openrpc/the-spec/firebolt-open-rpc--legacy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,48 @@
"type": "string"
},
"required": true
},
{
"name": "callSign",
"summary": "Optional call sign for the app making the request",
"schema": {
"type": "string"
}
},
{
"name": "language",
"summary": "Optional language override as a BCP 47 locale tag",
"schema": {
"type": "string"
}
},
{
"name": "voice",
"summary": "Optional voice identifier",
"schema": {
"type": "string"
}
},
{
"name": "volume",
"summary": "Optional volume override",
"schema": {
"type": "string"
}
},
{
"name": "rate",
"summary": "Optional speech rate override",
"schema": {
"type": "string"
}
},
{
"name": "pitch",
"summary": "Optional pitch override",
"schema": {
"type": "string"
}
}
],
"tags": [
Expand Down Expand Up @@ -2870,6 +2912,30 @@
{
"name": "text",
"value": "I am a text waiting for speech."
},
{
"name": "callSign",
"value": "AppA"
},
{
"name": "language",
"value": "en-US"
},
{
"name": "voice",
"value": "female-1"
},
{
"name": "volume",
"value": "80"
},
{
"name": "rate",
"value": "normal"
},
{
"name": "pitch",
"value": "medium"
}
],
"result": {
Expand Down
66 changes: 66 additions & 0 deletions docs/openrpc/the-spec/firebolt-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,48 @@
"type": "string"
},
"required": true
},
{
"name": "callSign",
"summary": "Optional call sign for the app making the request",
"schema": {
"type": "string"
}
},
Comment thread
brendanobra marked this conversation as resolved.
{
"name": "language",
"summary": "Optional language override as a BCP 47 locale tag",
"schema": {
"type": "string"
}
},
{
"name": "voice",
"summary": "Optional voice identifier",
"schema": {
"type": "string"
}
},
{
"name": "volume",
"summary": "Optional volume override",
"schema": {
"type": "string"
}
},
{
"name": "rate",
"summary": "Optional speech rate override",
"schema": {
"type": "string"
}
},
{
"name": "pitch",
"summary": "Optional pitch override",
"schema": {
"type": "string"
}
}
],
"tags": [
Expand Down Expand Up @@ -2511,6 +2553,30 @@
{
"name": "text",
"value": "I am a text waiting for speech."
},
{
"name": "callSign",
"value": "AppA"
},
{
"name": "language",
"value": "en-US"
},
{
"name": "voice",
"value": "female-1"
},
{
"name": "volume",
"value": "80"
},
{
"name": "rate",
"value": "normal"
},
{
"name": "pitch",
"value": "medium"
}
],
"result": {
Expand Down
13 changes: 11 additions & 2 deletions include/firebolt/texttospeech.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,20 @@ class ITextToSpeech
* @brief Speak the uttered text using the TTS engine
*
* @param[in] text : String to be converted to Audio for speech
* @param[in] callSign : Optional call sign for the app making the request
* @param[in] language : Optional language for the speech request
* @param[in] voice : Optional voice for the speech request
* @param[in] volume : Optional volume for the speech request
* @param[in] rate : Optional rate for the speech request
* @param[in] pitch : Optional pitch for the speech request
*
* @retval Result for Speak
*/
[[nodiscard]] virtual Result<SpeechResponse> speak(const std::string& text) const = 0;

[[nodiscard]] virtual Result<SpeechResponse>
speak(const std::string& text, std::optional<std::string> callSign = std::nullopt,
std::optional<std::string> language = std::nullopt, std::optional<std::string> voice = std::nullopt,
std::optional<std::string> volume = std::nullopt, std::optional<std::string> rate = std::nullopt,
std::optional<std::string> pitch = std::nullopt) const = 0;
/**
* @brief Pauses the speech for given speech id
*
Expand Down
30 changes: 29 additions & 1 deletion src/texttospeech_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,38 @@ Result<ListVoicesResponse> TextToSpeechImpl::listVoices(const std::string& langu
return helper_.get<JsonData::ListVoicesResponse, ListVoicesResponse>("TextToSpeech.listvoices", params);
}

Result<SpeechResponse> TextToSpeechImpl::speak(const std::string& text) const
Result<SpeechResponse> TextToSpeechImpl::speak(const std::string& text, std::optional<std::string> callSign,
std::optional<std::string> language, std::optional<std::string> voice,
std::optional<std::string> volume, std::optional<std::string> rate,
std::optional<std::string> pitch) const
{
nlohmann::json params;
params["text"] = text;
if (callSign)
{
params["callSign"] = *callSign;
}
if (language)
{
params["language"] = *language;
}
if (voice)
{
params["voice"] = *voice;
}
if (volume)
{
params["volume"] = *volume;
}
if (rate)
{
params["rate"] = *rate;
}
if (pitch)
{
params["pitch"] = *pitch;
}

return helper_.get<JsonData::SpeechResponse, SpeechResponse>("TextToSpeech.speak", params);
}

Expand Down
6 changes: 5 additions & 1 deletion src/texttospeech_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class TextToSpeechImpl : public ITextToSpeech
~TextToSpeechImpl() override = default;

[[nodiscard]] Result<ListVoicesResponse> listVoices(const std::string& language) const override;
[[nodiscard]] Result<SpeechResponse> speak(const std::string& text) const override;
[[nodiscard]] Result<SpeechResponse>
speak(const std::string& text, std::optional<std::string> callSign = std::nullopt,
std::optional<std::string> language = std::nullopt, std::optional<std::string> voice = std::nullopt,
std::optional<std::string> volume = std::nullopt, std::optional<std::string> rate = std::nullopt,
std::optional<std::string> pitch = std::nullopt) const override;
[[nodiscard]] Result<TTSStatusResponse> pause(SpeechId speechId) const override;
[[nodiscard]] Result<TTSStatusResponse> resume(SpeechId speechId) const override;
[[nodiscard]] Result<TTSStatusResponse> cancel(SpeechId speechId) const override;
Expand Down
Loading
Loading