示例#1
0
static void tts_request_cb(GDBusConnection *c, const gchar *sender,
                           const gchar *path, const gchar *interface,
                           const gchar *method, GVariant *args,
                           GDBusMethodInvocation *inv, gpointer user_data)
{
    wrtc_t     *wrtc    = (wrtc_t *)user_data;
    int         timeout = SRS_VOICE_QUEUE;
    int         events  = SRS_VOICE_MASK_NONE;
    char       *voice, *msg;
    uint32_t    id;

    if (strcmp(method, "synthesize"))
        return;

    g_variant_get(args, "(&s&s)", &msg, &voice);

    if (voice == NULL || !*voice)
        voice = "english";

    mrp_log_info("WRT media client: relaying TTS request '%s' in '%s' from %s.",
                 msg, voice, sender);

    id = client_render_voice(wrtc->c, msg, voice, 0, 0, timeout, events);

    g_dbus_method_invocation_return_value(inv, g_variant_new("(u)", id));
}
示例#2
0
static void request_voice(client_t *c, srs_req_voice_t *req)
{
    const char *msg     = req->msg;
    const char *voice   = req->voice;
    double      rate    = req->rate;
    double      pitch   = req->pitch;
    int         timeout = req->timeout;
    int         events  = req->events;
    uint32_t    reqid;

    mrp_debug("received voice render request from native client #%d", c->id);

    reqid = client_render_voice(c->c, msg, voice, rate, pitch, timeout, events);

    if (reqid != SRS_VOICE_INVALID)
        reply_render(c, req->reqno, reqid);
    else
        reply_status(c, req->reqno, SRS_STATUS_FAILED, "failed");
}
示例#3
0
static int render_voice_req(mrp_dbus_t *dbus, mrp_dbus_msg_t *req,
                            void *user_data)
{
    dbusif_t      *bus = (dbusif_t *)user_data;
    srs_context_t *srs = bus->self->srs;
    const char    *id, *msg, *voice, *errmsg = NULL;
    double         rate, pitch;
    int            timeout, events, err;
    uint32_t       reqid;
    srs_client_t  *c;

    err = parse_render_voice(req, &id, &msg, &voice, &rate, &pitch, &timeout,
                             &events, &errmsg);

    if (err != 0) {
        reply_error(dbus, req, err, errmsg);

        return TRUE;
    }

    c = client_lookup_by_id(srs, id);

    if (c == NULL) {
        reply_error(dbus, req, 1, "you don't exists, go away");

        return TRUE;
    }

    reqid = client_render_voice(c, msg, voice, rate, pitch, timeout, events);

    if (reqid != SRS_VOICE_INVALID)
        reply_render(dbus, req, reqid);
    else
        reply_error(dbus, req, 1, "voice render request failed");

    return TRUE;
}