Skip to content

Conversation

@songguocola
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @songguocola, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request expands the capabilities of the speech synthesis and voice enrollment services. It provides a mechanism for fine-tuning speech output through custom pronunciation and replacement rules, and offers greater control over input audio length for voice enrollment. These changes aim to improve the adaptability and precision of the audio processing features.

Highlights

  • Speech Synthesis Hot Fix Parameters: Introduced new functionality to allow users to define custom pronunciation and text replacement rules (hot fixes) for speech synthesis. This includes a new ParamHotFix class and its integration into SpeechSynthesisParam.
  • Max Prompt Audio Length for Voice Enrollment: Added a maxPromptAudioLength parameter to VoiceEnrollmentParam, enabling control over the maximum length of prompt audio used in voice enrollment processes.
  • Dynamic Voice Parameter Handling: Enhanced MultiModalConversationParam to support setting the VOICE parameter dynamically from a general parameters map, providing more flexibility in multimodal conversation configurations.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/main/java/com/alibaba/dashscope/aigc/multimodalconversation/MultiModalConversationParam.java
    • Added logic to allow the 'VOICE' parameter to be set from a generic 'parameters' map, if available.
  • src/main/java/com/alibaba/dashscope/audio/tts/SpeechSynthesisApiKeywords.java
    • Introduced new API keywords: HOT_FIX, PRONUNCIATION, and REPLACE to support the new hot fix feature.
    • Added extra newlines for improved code formatting around existing keywords.
  • src/main/java/com/alibaba/dashscope/audio/ttsv2/ParamHotFix.java
    • Added a new class ParamHotFix to encapsulate pronunciation and replacement rules for speech synthesis.
    • Includes nested static classes PronunciationItem and ReplaceItem to define individual rules.
    • Provides methods to convert these rule lists into a format suitable for API requests.
  • src/main/java/com/alibaba/dashscope/audio/ttsv2/SpeechSynthesisParam.java
    • Added a hotFix field of type ParamHotFix to SpeechSynthesisParam.
    • Modified the getParameters() method to include the hotFix configurations (pronunciation and replace rules) in the generated request payload.
  • src/main/java/com/alibaba/dashscope/audio/ttsv2/enrollment/VoiceEnrollmentParam.java
    • Added a maxPromptAudioLength field with a default value of 10.0f.
    • Updated the getInput() method to include max_prompt_audio_length in the JSON payload when its value is greater than 0.
    • Added an extra newline in the import section for formatting.
  • src/main/java/com/alibaba/dashscope/audio/ttsv2/enrollment/VoiceEnrollmentService.java
    • Updated the createVoice method to pass the new maxPromptAudioLength from customParam to the VoiceEnrollmentParam builder.
  • src/test/java/com/alibaba/dashscope/TestTtsV2SpeechSynthesizer.java
    • Imported the new ParamHotFix class.
    • Added test code to construct ParamHotFix objects with sample pronunciation and replacement rules.
    • Integrated the created hotFix object into the SpeechSynthesisParam builder for testing purposes.
Activity
  • The pull request was opened by songguocola, introducing new features and enhancements to the speech synthesis and voice enrollment modules.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@songguocola songguocola closed this Feb 9, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for hot_fix parameters for the cosyvoice model and a max_prompt_audio_length parameter for voice enrollment. The implementation is generally good, but I have identified a couple of high-severity issues. One is a potential logic bug in MultiModalConversationParam where a generic parameter could unintentionally override a specific one. The other is a performance issue in SpeechSynthesisParam caused by redundant method calls inside a conditional block. I've provided suggestions to address these points to improve the code's correctness and efficiency.

Comment on lines +185 to +187
if (parameters != null && !parameters.isEmpty() && parameters.containsKey(ApiKeywords.VOICE)) {
jsonObject.addProperty(ApiKeywords.VOICE, (String) parameters.get(ApiKeywords.VOICE));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current logic allows the voice parameter from the generic parameters map to overwrite the value from the dedicated voice field if both are present. This can lead to unexpected behavior. The dedicated voice field should have precedence. To fix this, you can check if the voice property has already been set on the jsonObject before adding it from the parameters map.

Suggested change
if (parameters != null && !parameters.isEmpty() && parameters.containsKey(ApiKeywords.VOICE)) {
jsonObject.addProperty(ApiKeywords.VOICE, (String) parameters.get(ApiKeywords.VOICE));
}
if (parameters != null && !parameters.isEmpty() && parameters.containsKey(ApiKeywords.VOICE) && !jsonObject.has(ApiKeywords.VOICE)) {
jsonObject.addProperty(ApiKeywords.VOICE, (String) parameters.get(ApiKeywords.VOICE));
}

Comment on lines +90 to +101
if (getHotFix() != null) {
Map<String, Object> hotFixParams = new HashMap<>();
if (getHotFix().getPronunciation() != null && !getHotFix().getPronunciation().isEmpty()) {
hotFixParams.put(SpeechSynthesisApiKeywords.PRONUNCIATION, getHotFix().getPronunciation());
}
if (getHotFix().getReplace() != null && !getHotFix().getReplace().isEmpty()) {
hotFixParams.put(SpeechSynthesisApiKeywords.REPLACE, getHotFix().getReplace());
}
if (!hotFixParams.isEmpty()) {
params.put(SpeechSynthesisApiKeywords.HOT_FIX, hotFixParams);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This block has a performance issue: getHotFix().getPronunciation() and getHotFix().getReplace() are called multiple times. Since these methods create new collections on each invocation, this is inefficient. You should call them once and store the results in local variables.

Additionally, the method names getPronunciation and getReplace in ParamHotFix are confusing as they override Lombok's getters but perform data transformation. It would be clearer to rename them to something like buildPronunciationPayload() and buildReplacePayload() to improve code clarity.

Suggested change
if (getHotFix() != null) {
Map<String, Object> hotFixParams = new HashMap<>();
if (getHotFix().getPronunciation() != null && !getHotFix().getPronunciation().isEmpty()) {
hotFixParams.put(SpeechSynthesisApiKeywords.PRONUNCIATION, getHotFix().getPronunciation());
}
if (getHotFix().getReplace() != null && !getHotFix().getReplace().isEmpty()) {
hotFixParams.put(SpeechSynthesisApiKeywords.REPLACE, getHotFix().getReplace());
}
if (!hotFixParams.isEmpty()) {
params.put(SpeechSynthesisApiKeywords.HOT_FIX, hotFixParams);
}
}
if (getHotFix() != null) {
Map<String, Object> hotFixParams = new HashMap<>();
List<Object> pronunciations = getHotFix().getPronunciation();
if (pronunciations != null && !pronunciations.isEmpty()) {
hotFixParams.put(SpeechSynthesisApiKeywords.PRONUNCIATION, pronunciations);
}
List<Object> replaces = getHotFix().getReplace();
if (replaces != null && !replaces.isEmpty()) {
hotFixParams.put(SpeechSynthesisApiKeywords.REPLACE, replaces);
}
if (!hotFixParams.isEmpty()) {
params.put(SpeechSynthesisApiKeywords.HOT_FIX, hotFixParams);
}
}

@songguocola songguocola deleted the dev/0208_cosyvoice branch February 9, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant