Use text-to-speech for incoming messages
How to synthesize incoming text messages as speech.
Read time 1 minuteLast updated 7 months ago
After you set up message polling for the Vivox SDK, you receive events whenever the Vivox SDK receives a message.
- When a text channel message is received, the event is raised.
vx_evt_message - When a direct message is received, the event is raised.
vx_evt_user_to_user_message
If you want to use text-to-speech (TTS) to read incoming messages, use the function in the message event handler. The destination is an ideal choice because it ensures that the messages are queued and that they are only played locally.
vx_tts_speaktts_dest_queued_local_playbackThe 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;}