Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Configures TTS.
- // 1. Create parameters. These parameters are optional. If you do not set them, default values are used.
- MLTtsConfig mlTtsConfig = new MLTtsConfig()
- .setVolume(1.5f)
- .setSpeed(1.5f)
- .setLanguage(MLTtsConstants.TTS_ZH_HANS)
- .setPerson(MLTtsConstants.TTS_SPEAKER_FEMALE_ZH);
- // 2. View custom parameter values.
- mlTtsConfig.getLanguage();// Obtain the language. If null is returned, the value is not customized.
- mlTtsConfig.getPerson();// Obtain the speaker name. If null is returned, the value is not customized.
- mlTtsConfig.getSpeed();// Obtain the speed. If 0 is returned, the value is not customized.
- mlTtsConfig.getVolume();// Obtain the volume. If 0 is returned, the value is not customized.
- // 3. Update configurations.
- // a. Use the previous configurations if there is no custom configuration. Use default configurations if no previous configuration exists.
- // b. Use current custom configurations if there are any.
- // 4. Update mode:
- // a. During initialization.
- MLTtsEngine mlTtsEngine = = new MLTtsEngine(mlTtsConfig);
- // b. During the process.
- mlTtsEngine.updateConfig(mlTtsConfig);
| Constructor name |
| MLTtsConfig() |
| Return type | Method name |
| String | getLanguage() |
| String | getPerson() |
| float | getSpeed() |
| float | getVolume() |
| MLTtsConfig | setLanguage(String language) |
| MLTtsConfig | setPerson(String person) |
| MLTtsConfig | setSpeed(float speed) |
| MLTtsConfig | setVolume(float volume) |
| Method |
| public MLTtsConfig() |
| Constructor. |
| Method |
| public String getLanguage() |
| Obtains the language in the current configuration instance. |
Return
| Type | desc |
| String | Returns the language. If null is returned, the value is not customized. |
| Method |
| public String getPerson() |
| Obtains the speaker in the current configuration instance. |
Return
| Type | desc |
| String | Returns the speaker name. If null is returned, the value is not customized. |
| Method |
| Obtains the speech speed in the current configuration instance. |
Return
| Type | desc |
| float | Returns the speech speed. If 0 is returned, the value is not customized. |
| Method |
| Obtains the volume in the current configuration instance. |
Return
| Type | desc |
| float | Returns the volume. If 0 is returned, the value is not customized. |
| Method |
Sets the language. |
Parameters
| Parameter name | Parameter desc |
| language | Language name. If this parameter is not set, the default value zh-Hans is used, indicating Simplified Chinese. TTS_EN_US: English (US) TTS_ZH_HANS: Simplified Chinese TTS_LAN_ES_ES: Spanish TTS_LAN_FR_FR: French |
Return
| Type | desc |
| MLTtsConfig | Configuration instance after the language is set. |
| Method |
| Sets the speaker. |
Parameters
| Parameter name | Parameter desc |
| person | Name of the speaker. If this parameter is not set, the default value Female-zh is used, indicating Chinese female voice. TTS_SPEAKER_FEMALE_EN: English female voice TTS_SPEAKER_FEMALE_ZH: Chinese female voice TTS_SPEAKER_MALE_EN: English male voice TTS_SPEAKER_MALE_ZH: Chinese male voice TTS_SPEAKER_FEMALE_ES: Spanish standard female voice TTS_SPEAKER_FEMALE_FR: French standard female voice |
Return
| Type | desc |
| MLTtsConfig | Configuration instance after the speaker is set. |
| Method |
| Sets the speech speed. |
Parameters
| Parameter name | Parameter desc |
| speed | Speech speed. The value range is (0, 2). Value 1.0 indicates the normal speed. A value less than 1.0 indicates a lower speed. Value 0.5 indicates half of the normal speed. If the value is greater than 1.0, the speed is accelerated. For example, 1.5 indicates that the speed is 1.5 times the normal speed. If this parameter is not set, the default value is 1.0 is used. |
Return
| Type | desc |
| MLTtsConfig | Configuration instance after the speech speed is set. |
| Method |
| Sets the volume. |
Parameters
| Parameter name | Parameter desc |
| volume | Speech volume. The value range is (0, 2). Value 1.0 indicates the normal volume. A value less than 1.0 indicates a lower volume. Value 0.5 indicates half of the normal volume. If the value is greater than 1.0, the volume increases. For example, 1.5 indicates that the volume is 1.5 times the normal volume. If this parameter is not set, the default value is 1.0 is used. |
Return
| Type | desc |
| MLTtsConfig | Configuration instance after the volume is set. |