mirror of
https://github.com/chliny/hass-tencentcloud-asr.git
synced 2026-07-21 22:53:58 +08:00
fix: update model translation
This commit is contained in:
@@ -3,8 +3,9 @@ import voluptuous as vol
|
||||
from typing import Any, Dict
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow, ConfigEntry
|
||||
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig, SelectOptionDict
|
||||
|
||||
from .tencentcloud_api import Modules, DefaultModel
|
||||
from .tencentcloud_api import ModuleSupportLanguage, DefaultModel
|
||||
from .tencentcloud_api import TencentCloudAsrAPi
|
||||
from . import SecretIdKey, SecretKeyKey, ModelKey
|
||||
from . import DOMAIN
|
||||
@@ -12,6 +13,16 @@ from . import DOMAIN
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
modelSelector = SelectSelector(
|
||||
SelectSelectorConfig(
|
||||
options=[
|
||||
SelectOptionDict(value=model_id, label=model_id) for model_id in ModuleSupportLanguage
|
||||
],
|
||||
translation_key="model_descriptions",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_user(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
|
||||
errors: Dict[str, str] = {}
|
||||
@@ -27,17 +38,14 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
if not errors:
|
||||
return self.async_create_entry(title=DOMAIN, data=user_input)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
config_schema = vol.Schema(
|
||||
{
|
||||
vol.Required(SecretIdKey): str,
|
||||
vol.Required(SecretKeyKey): str,
|
||||
vol.Required(ModelKey, default=DefaultModel): vol.In(Modules.keys()),
|
||||
},
|
||||
),
|
||||
errors=errors
|
||||
)
|
||||
vol.Required(ModelKey, default=DefaultModel): modelSelector,
|
||||
})
|
||||
|
||||
return self.async_show_form(step_id="user", data_schema=config_schema, errors=errors)
|
||||
|
||||
@staticmethod
|
||||
@callback
|
||||
@@ -59,6 +67,6 @@ class TencentCloudAsrOptionFlow(OptionsFlow):
|
||||
return self.async_create_entry(title=DOMAIN, data=user_input)
|
||||
model = user_input.get(ModelKey, DefaultModel)
|
||||
config_schema = vol.Schema({
|
||||
vol.Optional(ModelKey, default=model): vol.In(Modules.keys()),
|
||||
vol.Optional(ModelKey, default=model): modelSelector,
|
||||
})
|
||||
return self.async_show_form(step_id="user", data_schema=config_schema, errors={})
|
||||
|
||||
@@ -10,13 +10,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SentenceRecognitionSourceTypePost = 1
|
||||
SentenceRecognitionSourceTypeURL = 0
|
||||
Modules = {
|
||||
"16k_zh": "中文",
|
||||
"16k_zh-PY": "中英粤",
|
||||
"16k_en": "英语",
|
||||
"16k_yue": "粤语",
|
||||
"16k_zh_dialect": "多方言",
|
||||
}
|
||||
ModuleSupportLanguage = {
|
||||
"16k_zh": ["zh"],
|
||||
"16k_zh-PY": ["zh", "en", "yue"],
|
||||
|
||||
@@ -8,8 +8,29 @@
|
||||
"secretid": "tencentcloud asr secretid",
|
||||
"secretkey": "tencnetcloud asr secretkey",
|
||||
"model": "model"
|
||||
},
|
||||
"description": "The integration is based on [Tencent Cloud API](https://cloud.tencent.com/document/product/1093/35646)."
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"model": "model"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"selector": {
|
||||
"model_descriptions": {
|
||||
"options": {
|
||||
"16k_zh": "16k_zh Chinese",
|
||||
"16k_zh-PY": "16k_zh-PY - Chinese, English, and Cantonese",
|
||||
"16k_en": "16k_en - English",
|
||||
"16k_yue": "16k_yue - Cantonese",
|
||||
"16k_zh_dialect": "16k_zh_dialect - Chinese dialects"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,29 @@
|
||||
"secretid": "请输入腾讯云ASR服务secretid",
|
||||
"secretkey": "请输入腾讯云ASR服务secretkey",
|
||||
"model": "模型"
|
||||
},
|
||||
"description": "此集成基于腾讯云API, 具体见[腾讯云文档](https://cloud.tencent.com/document/product/1093/35646)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"model": "模型"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"selector": {
|
||||
"model_descriptions": {
|
||||
"options": {
|
||||
"16k_zh": "16k_zh - 中文通用",
|
||||
"16k_zh-PY": "16k_zh-PY - 中英粤",
|
||||
"16k_en": "16k_en - 英语",
|
||||
"16k_yue": "16k_yue - 粤语",
|
||||
"16k_zh_dialect": "16k_zh_dialect - 中文多方言"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user