mirror of
https://github.com/chliny/hass-tencentcloud-asr.git
synced 2026-07-31 00:13:55 +08:00
feat: add ASR filtering options
This commit is contained in:
@@ -3,11 +3,24 @@ 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 homeassistant.helpers.selector import (
|
||||
BooleanSelector,
|
||||
SelectOptionDict,
|
||||
SelectSelector,
|
||||
SelectSelectorConfig,
|
||||
)
|
||||
|
||||
from .tencentcloud_api import ModuleSupportLanguage, DefaultModel
|
||||
from .tencentcloud_api import TencentCloudAsrAPi
|
||||
from . import SecretIdKey, SecretKeyKey, ModelKey
|
||||
from . import (
|
||||
ConvertNumModeKey,
|
||||
FilterDirtyKey,
|
||||
FilterModalKey,
|
||||
FilterPuncKey,
|
||||
ModelKey,
|
||||
SecretIdKey,
|
||||
SecretKeyKey,
|
||||
)
|
||||
from . import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -22,6 +35,17 @@ modelSelector = SelectSelector(
|
||||
)
|
||||
)
|
||||
|
||||
filterDirtySelector = SelectSelector(
|
||||
SelectSelectorConfig(
|
||||
options=[
|
||||
SelectOptionDict(value="0", label="0"),
|
||||
SelectOptionDict(value="1", label="1"),
|
||||
SelectOptionDict(value="2", label="2"),
|
||||
],
|
||||
translation_key="filter_dirty_descriptions",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_user(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
|
||||
@@ -43,6 +67,10 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
vol.Required(SecretIdKey): str,
|
||||
vol.Required(SecretKeyKey): str,
|
||||
vol.Required(ModelKey, default=DefaultModel): modelSelector,
|
||||
vol.Required(FilterDirtyKey, default="0"): filterDirtySelector,
|
||||
vol.Required(FilterModalKey, default=False): BooleanSelector(),
|
||||
vol.Required(FilterPuncKey, default=False): BooleanSelector(),
|
||||
vol.Required(ConvertNumModeKey, default=True): BooleanSelector(),
|
||||
})
|
||||
|
||||
return self.async_show_form(step_id="user", data_schema=config_schema, errors=errors)
|
||||
@@ -68,5 +96,21 @@ class TencentCloudAsrOptionFlow(OptionsFlow):
|
||||
model = user_input.get(ModelKey, DefaultModel)
|
||||
config_schema = vol.Schema({
|
||||
vol.Optional(ModelKey, default=model): modelSelector,
|
||||
vol.Required(
|
||||
FilterDirtyKey,
|
||||
default=user_input.get(FilterDirtyKey, "0"),
|
||||
): filterDirtySelector,
|
||||
vol.Required(
|
||||
FilterModalKey,
|
||||
default=user_input.get(FilterModalKey, False),
|
||||
): BooleanSelector(),
|
||||
vol.Required(
|
||||
FilterPuncKey,
|
||||
default=user_input.get(FilterPuncKey, False),
|
||||
): BooleanSelector(),
|
||||
vol.Required(
|
||||
ConvertNumModeKey,
|
||||
default=user_input.get(ConvertNumModeKey, True),
|
||||
): BooleanSelector(),
|
||||
})
|
||||
return self.async_show_form(step_id="user", data_schema=config_schema, errors={})
|
||||
|
||||
Reference in New Issue
Block a user