文档

支持

Vivox Core SDK

Vivox Core SDK

Use text-to-speech for incoming messages

How to synthesize incoming text messages as speech.
阅读时间1 分钟最后更新于 12 天前

After you set up message polling for the Vivox SDK, you receive events whenever the Vivox SDK receives a message. If you want to use text-to-speech (TTS) to read incoming messages, use the
vx_tts_speak
function in the message event handler. The
tts_dest_queued_local_playback
destination is an ideal choice because it ensures that the messages are queued and that they are only played locally.
The following code displays an example of how to use TTS to read incoming messages:
case evt_message:{ vx_evt_message *evt_message = (vx_evt_message *)evt; string sessionHandle = string(evt_message->session_handle); string username; if (evt_message->participant_displayname != NULL) { username = string(evt_message->participant_displayname); } else { username = string("Anonymous"); } string text = username + " says " + string(evt_message->message_body); vx_tts_utterance_id utteranceID; vx_tts_status status = vx_tts_speak(*m_ttsManagerId, m_ttsVoiceID, text.c_str(), tts_dest_queued_local_playback, &utteranceID); break;}