Voice Service Interface
| Function | C++ | Python | C# | Java |
|---|---|---|---|---|
| Voice Service Switch | - | - | ✔ | - |
| ASR Switch | ✔ | ✔ | ✔ | ✔ |
| TTS Switch | ✔ | ✔ | ✔ | ✔ |
| TTS Playback | - | ✔ | ✔ | ✔ |
| Stop TTS Playback | ✔ | ✔ | ✔ | ✔ |
| Switch Audio Source | - | - | ✔ | - |
| Switch Dialogue Mode | - | - | ✔ | - |
| Switch Recognition Mode | - | - | ✔ | - |
| Register ASR Callback | ✔ | ✔ | ✔ | ✔ |
EnableVoiceService
Function Prototypes
- C#:
(bool success, string message) EnableVoiceService(bool enable, int id = 301, int timeoutMs = 5000)
Function Description
Enables or disables the voice service.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
enable | bool | Required | true: Enable, false: Disable |
id | int | Optional (C#) | Request ID |
timeoutMs | int | Optional (C#) | Timeout (ms) |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | Contains success(bool) and message(string) |
Code Example
// C#
var result = robot.EnableVoiceService(true);EnableAsr
Function Prototypes
- C#:
(bool success, string message) SpeechStartASR(bool enable) - C++:
CommReply enableAsr(bool enable) - Python:
async def enable_asr_engine(enable: bool, timeout: float = 30.0) -> Optional[Dict] - Java:
ServiceOperationResponse SpeechEnableAsr(boolean enable)
Function Description
Enables or disables the Automatic Speech Recognition (ASR) engine.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
enable | bool | Required | true: Enable, false: Disable |
timeout | float | Optional (Py) | Timeout (seconds) |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | Contains success(bool) and message(string) |
| C++ | CommReply | Contains success(bool) and message(string) |
| Python | Dict | Contains success(bool) and message(string) |
| Java | ServiceOperationResponse | Contains status and message |
Code Example
// C#
robot.SpeechStartASR(true);# Python
await client.enable_asr_engine(True)// Java
robot.SpeechEnableAsr(true);// C++
robot.enableAsr(true);EnableTts
Function Prototypes
- C#:
(bool success, string message) SpeechInitTTS(bool enable) - C++:
CommReply enableTts(bool enable) - Python:
async def enable_tts_engine(enable: bool, timeout: float = 30.0) -> Optional[Dict] - Java:
ServiceOperationResponse SpeechEnableTts(boolean enable)
Function Description
Enables or disables the Text-To-Speech (TTS) engine.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
enable | bool | Required | true: Enable, false: Disable |
timeout | float | Optional (Py) | Timeout (seconds) |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | Contains success(bool) and message(string) |
| C++ | CommReply | Contains success(bool) and message(string) |
| Python | Dict | Contains success(bool) and message(string) |
| Java | ServiceOperationResponse | Contains status and message |
Code Example
// C#
robot.SpeechInitTTS(true);# Python
await client.enable_tts_engine(True)// Java
robot.SpeechEnableTts(true);// C++
robot.enableTts(true);GenerateAudio
Function Prototypes
- C#:
(bool success, string message) SpeechPlayTTS(string text, int sid = 0, float speed = 1.0f) - Python:
async def generate_audio(text: str, sid: int = 0, speed: float = 1.0, timeout: float = 30.0) -> Optional[Dict] - Java:
ServiceOperationResponse SpeechGenerateAudio(String text, int sid, float speed, int timeout)
Function Description
Converts text to speech and plays it.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
text | string | Required | Text content to convert |
sid | int | 0 | Speaker ID |
speed | float | 1.0 | Speech speed (0.7 ~ 1.3) |
timeout | int/float | 30 | Timeout |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | Contains success(bool) and message(string) |
| Python | Dict | Contains success(bool) and message(string) |
| Java | ServiceOperationResponse | Contains status and message |
Code Example
// C#
robot.SpeechPlayTTS("Hello, I am Daystar Robot");# Python
await client.generate_audio("Hello, I am Daystar Robot")// Java
robot.SpeechGenerateAudio("Hello, I am Daystar Robot", 0, 1.0f, 30);StopPlayingTts
Function Prototypes
- C#:
(bool success, string message) SpeechStopTTS() - C++:
CommReply stopPlayingTts(bool enable) - Python:
async def stop_playing_tts(timeout: float = 30.0) -> Optional[Dict] - Java:
ServiceOperationResponse SpeechStopPlayingTts()
Function Description
Stops the currently playing TTS audio.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
enable | bool | Required (C++) | Flag (usually true) |
timeout | float | Optional (Py) | Timeout |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | Contains success(bool) and message(string) |
| C++ | CommReply | Contains success(bool) and message(string) |
| Python | Dict | Contains success(bool) and message(string) |
| Java | ServiceOperationResponse | Contains status and message |
Code Example
// C#
robot.SpeechStopTTS();# Python
await client.stop_playing_tts()// Java
robot.SpeechStopPlayingTts();// C++
robot.stopPlayingTts(true);SwitchAudioSource
Function Prototypes
- C#:
(bool success, string message) SwitchAudioSource(int source, int id = 302, int timeoutMs = 5000)
Function Description
Switches the audio input source.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
source | int | Required | 0: Default (Robot), 1: External |
timeoutMs | int | Optional | Timeout (ms) |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | success, message |
Code Example
// C#
robot.SwitchAudioSource(0);SetDialogMode
Function Prototypes
- C#:
(bool success, string message) SetDialogMode(int mode, int id = 303, int timeoutMs = 5000)
Function Description
Sets the dialogue mode (Single-turn or Multi-turn).
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
mode | int | Required | 0: Single-turn, 1: Multi-turn |
timeoutMs | int | Optional | Timeout (ms) |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | success, message |
Code Example
// C#
robot.SetDialogMode(0);SetVoiceRecognitionMode
Function Prototypes
- C#:
(bool success, string message) SetVoiceRecognitionMode(int mode, int id = 304, int timeoutMs = 5000)
Function Description
Switches the voice recognition mode (Online or Offline).
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
mode | int | Required | 0: Online Mode, 1: Offline Mode |
timeoutMs | int | Optional | Timeout (ms) |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | (bool, string) | success, message |
Code Example
// C#
robot.SetVoiceRecognitionMode(0);RegisterASRCallback
Function Prototypes
- C#:
bool SpeechRegisterASRResult(Action<object> callback) - C++:
bool subscribeSpeechAsrResult() - Python:
async def subscribe_asr_result(callback: Callable[[Dict], None]) -> bool - Java:
void RegisterSpeechAsrResult(Consumer<SpeechAsrResult> callback)
Function Description
Registers a callback for ASR recognition results.
Parameters
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
callback | function | Required | ASR result callback function |
Return Value
| Language | Return Type | Description |
|---|---|---|
| C# | bool | Whether subscription was successful |
| C++ | bool | True if subscribed successfully |
| Python | bool | True if subscribed successfully |
| Java | void | No return value |
Code Example
// C#
robot.SpeechRegisterASRResult(data => {
// data is the ASR result object
});# Python
# See Python example// Java
robot.RegisterSpeechAsrResult(result -> {
System.out.println("ASR Text: " + result.text);
});// C++
robot.subscribeSpeechAsrResult();