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::AiSpeechRequest::text

The text to synthesize into speech.

QString ew::app::AiSpeechRequest::model

The speech model to request (e.g. "tts-1", "gpt-4o-mini-tts", a local model id).

QString ew::app::AiSpeechRequest::voice

The voice to use (e.g. "alloy", "verse"); empty leaves it to the provider's default.

QString ew::app::AiSpeechRequest::format

The audio format (e.g. "mp3", "wav", "opus"); empty defaults to "mp3".

Functions

QString ew::app::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::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.