Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

feat: STT model params

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Sep 16, 2025

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.

Details

Instructions 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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Sep 16, 2025

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment


def get_model_params_setting_form(self, model_name):
pass
return TencentSSTModelParams()
Copy link
Contributor Author

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:

  1. Import Statements: Ensure there are no unnecessary imports at the top of the file.

  2. Docstring Consistency: Check if all functions and classes have consistent docstrings, which could improve readability.

  3. Unused Function get_model_params_setting_form: The function get_model_params_setting_form is 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.

Copy link
Contributor Author

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')},
],
},
],
Copy link
Contributor Author

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:

  1. Indentation: Ensured all lines within the return dictionary are properly indented to match the previous block.
  2. 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.

@zhanweizhang7 zhanweizhang7 merged commit 6c2b2f6 into v2 Sep 16, 2025
5 of 8 checks passed
@maninhill maninhill deleted the pr@v2@feat_STT_model_params branch September 23, 2025 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants