tencent cloud

Voice Interaction
Last updated: 2025-02-11 16:47:21
Voice Interaction
Last updated: 2025-02-11 16:47:21
Note:
Voice interaction, used for voice communication between remote and field devices. Audio link will be automatically connected when a control session is established. The SDK defaults to only enable the upstream audio (from field devices to remote devices). If you need to use bidirectional audio, please prepare the relevant audio hardware, add the necessary configuration, and restart the SDK.

Hardware Preparation

Device Side
Upstream audio: field device -> remote device
Downstream audio: remote device -> field device
Field Device
Microphone
Speaker
Remote Device
Speaker
Microphone

Modifying Software Configuration

Modify the configurations of field devices and remote devices, enable the audio switch, and set the audio device.

Enable Audio Switch

Enable Audio Reception by setting audio_receive to 1; Enable Audio Capture by setting audio_enable to 1.
Device Side
Upstream audio: field device -> remote device
Downstream audio: remote device -> field device
Field Device
"audio_enable":1
"audio_receive":1
Remote Device
"audio_receive":1
"audio_enable":1

Use Configurations to Set Audio Devices

The SDK uses the system default audio playback and capture devices by default. If the target audio device is not the system default device on Linux, the corresponding audio device can be specified through configuration. After modifying the configuration, you need to restart the SDK.
Item
Configuration Instructions
Configuration Example
Playback
"audio_play":"hw:#Card,#Device,#SubDevice"
Here, #Card, #Device, #SubDevice are the sound card device numbers. On Linux platforms, you can query the card, device, and subdevice numbers of the target device using aplay -l .
For example, the target device is Card 0, Device 0, SubDevice #0:
audio_play":"hw:0,0,0"
Capture
"audio_record":"hw:#Card,#Device,#SubDevice"
#Card, #Device, #SubDevice represent the sound card device numbers. On the Linux platform, you can use arecord -l to query the card, device, subdevice numbers of the target device.
For example, the target device is Card 0, Device 0, SubDevice #0:
audio_record":"hw:0,0,0"
Example: Execute the command "aplay -l" to view audio playback devices.



If the playback device used is "card 0, device 3, subdevice 0" as shown, add the configuration node "audio_play":"hw:0,3,0" to the config.json file.

Use API to Set Audio Devices

You can use the sdk API to set the current audio device.
1) TRRO_getDeviceCount retrieves the number of audio devices of target type.
2) TRRO_getDeviceName retrieves the device name, and filters by name to find the audio device number of the target name
3) TRRO_setCurrentDevice sets the audio device with the corresponding device number as the current audio device
Interfaces
Description
Retrieve the Number of Audio Capture/Playback Devices
Retrieve the Name of Audio Capture/Playback Devices
Change the Current Audio Capture/Playback Device



Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback