-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: STT model params #4046
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
feat: STT model params #4046
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
||
| def get_model_params_setting_form(self, model_name): | ||
| pass | ||
| return TencentSSTModelParams() |
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 provided code does not contain any immediate issues that would prevent it from running correctly. However, I can suggest a few optimizations:
-
Import Statements: Ensure there are no unnecessary imports at the top of the file.
-
Docstring Consistency: Check if all functions and classes have consistent docstrings, which could improve readability.
-
Unused Function
get_model_params_setting_form: The functionget_model_params_setting_formis currently empty and might be redundant if its purpose has already been served elsewhere in the codebase.
Here's an optimized version of the code with some minor adjustments:
from models_provider.base_model_provider import BaseModelCredential, ValidCode
class TencentSSTModelParams(BaseForm):
"""Class for configuring engine model type."""
EngSerViceType = forms.SingleSelect(
TooltipLabel(_('Engine model type'), _('If not passed, the default value is 16k_zh (Chinese universal)')),
required=True,
default_value='16k_zh',
option_list=[
{"value": "8k_zh", "label": _("Chinese telephone universal")},
{"value": "8k_en", "label": _("English telephone universal")},
{"value": "16k_zh", "label": _("Commonly used in Chinese")},
{"value": "16k_zh-PY", "label": _("Chinese, English, and Guangdong")},
{"value": "16k_zh_medical", "label": _("Chinese medical")},
{"value": "16k_en", "label": _("English")},
{"value": "16k_yue", "label": _("Cantonese")},
{"value": "16k_ja", "label": _("Japanese")},
{"value": "16k_ko", "label": _("Korean")},
{"value": "16k_vi", "label": _("Vietnamese")},
{"value": "16k_ms", "label": _("Malay language")},
{"value": "16k_id", "label": _("Indonesian language")},
{"value": "16k_fil", "label": _("Filipino language")},
{"value": "16k_th", "label": _("Thai")},
{"value": "16k_pt", "label": _("Portuguese")},
{"value": "16k_tr", "label": _("Turkish")},
{"value": "16k_ar", "label": _("Arabic")},
{"value": "16k_es", "label": _("Spanish")},
{"value": "16k_hi", "label": _("Hindi")},
{"value": "16k_fr", "label": _("French")},
{"value": "16k_de", "label": _("German")},
{"value": "16k_zh_dialect", "label": _("Multiple dialects, supporting 23 dialects")}
],
value_field='value',
text_field='label'
)
class TencentSTTModelCredential(BaseForm, BaseModelCredential):
"""
Class for storing credentials for speech-to-text services.
Attributes:
REQUIRED_FIELDS: Required fields for authentication.
"""
REQUIRE_FIELDS = ["SecretId", "SecretKey"]
def encryption_dict(self, model):
return {}
SecretKey = forms.PasswordInputField('secretkey', required=True)
def get_model_params_setting_form(self):
# Return instance of TencentSSTModelParams class
return TencentSSTModelParams()By applying these changes, you should make the code more readable and maintainable without adding significant overhead.
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 provided code appears to be valid Python and doesn't contain any significant irregularities, issues, or optimizations. The AliyunBaiLianOmiSTTModelParams class and its methods seem to be correctly defined according to Django Form API. The changes made in the last three lines should also work without issue.
However, there is a minor inconsistency in the line endings. It seems like you want to replace \No newline at end of file, which isn't used properly for multiline comments starting with @@. Instead, you might have intended to remove that comment entirely if it was no longer needed.
Here's a slightly more formatted version of the cleaned-up code:
# from models_provider.base_model_provider import BaseModelCredential, ValidCode
from django.utils.translation import gettext_lazy as _
class AliyunBaiLianOmiSTTModelParams(forms.Form):
CueWord = forms.CharField(
label=_('CueWord'),
help_text=_('If not passed, the default value is "What is this audio saying? Only answer the audio content".'),
required=True,
initial='这段音频在说什么,只回答音频的内容',
)
class AliyunBaiLianOmiSTTModelCredential(BaseForm, BaseModelCredential):
# Method implementation here
def encryption_dict(self, model: dict) -> dict:
# Encryption logic here
def get_model_params_setting_form(self, model_name):
return AliyunBaiLianOmiSTTModelParams()Note that I replaced forms.TextInputField with forms.CharField, which is generally recommended for text fields due to better handling and compatibility across different browsers and platforms. This change aligns with modern best practices in form field definitions.
| {"type": "text", "text": self.params.get('CueWord')}, | ||
| ], | ||
| }, | ||
| ], |
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.
It looks like there is an indentation issue at the beginning of one line. Here’s the corrected version:
@@ -68,7 +68,7 @@
return {
"request": [
{
"audio_data": {
"uri": f"s3://{bucket_name}/{key}",
"format": "mp3"
},
- {"type": "text", "text": '这段音频在说什么,只回答音频的内容'}
+ {"type": "text", "text": self.params.get('CueWord')}
}
]
}Improvements/Notes:
- Indentation: Ensured all lines within the
returndictionary are properly indented to match the previous block. - Consistency: Kept the parameter extraction using
self.params.get('CueWord')consistent with other uses in the function.
This correction ensures that the JSON structure remains valid and adheres to Python syntax conventions.
feat: STT model params