AiSpeech.h header
#include <ew/app/AiSpeech.h>
Namespace ew::app
AiSpeechRequest struct
struct ew::app::AiSpeechRequest
A request to a text-to-speech model: the text to speak, the model, a voice name, and an audio format ("mp3", "wav", ...). Provider-agnostic – any endpoint speaking the OpenAI-compatible audio/speech shape consumes it. The model and voice come from settings, never hard-coded.
Members
QString ew::app::ai::AiSpeechRequest::text
The text to synthesize into speech.
QString ew::app::ai::AiSpeechRequest::model
The speech model to request (e.g. "tts-1", "gpt-4o-mini-tts", a local model id).
QString ew::app::ai::AiSpeechRequest::voice
The voice to use (e.g. "alloy", "verse"); empty leaves it to the provider's default.
QString ew::app::ai::AiSpeechRequest::format
The audio format (e.g. "mp3", "wav", "opus"); empty defaults to "mp3".
AiSpeechResult struct
struct ew::app::AiSpeechResult
The result of a text-to-speech request: the synthesized audio bytes (when ok) or an error.
Declared HERE rather than beside the HTTP client that produces it, because it is a plain result type with no networking in it and the transport-agnostic seam in AiProviders.h has to be able to name it. A result type living inside the networking module would have forced everything that merely reads a result to depend on the module that performs the request.
Members
bool ew::app::ai::AiSpeechResult::ok = false
True when the model returned audio; false when the request errored.
QByteArray ew::app::ai::AiSpeechResult::audioData
The synthesized audio bytes (in the requested format), when ok.
QString ew::app::ai::AiSpeechResult::error
A human-readable error message (when not ok).
Functions
QString ew::app::ai::buildSpeechRequestJson(const AiSpeechRequest &request)
Serializes request to an OpenAI-compatible audio/speech request body (JSON). Pure and unit-testable – no network or key.
QString ew::app::ai::parseSpeechErrorJson(const QString &json)
A successful text-to-speech response is raw audio bytes (no JSON to parse); only a failure is JSON. This extracts the error message from such a body ({"error":{"message":"..."}} or a bare string), returning an empty string when json is not a recognizable error. Pure and unit-testable.