-
Notifications
You must be signed in to change notification settings - Fork 22
feat(model/cosyvoice): support hot_fix params and max_prompt_audio_length #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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.
| if (parameters != null && !parameters.isEmpty() && parameters.containsKey(ApiKeywords.VOICE)) { | ||
| jsonObject.addProperty(ApiKeywords.VOICE, (String) parameters.get(ApiKeywords.VOICE)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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)); | |
| } |
| 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); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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); | |
| } | |
| } |
No description provided.