stt-config.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { STTConfig, STTConfigValidator } from "../store";
  2. import Locale from "../locales";
  3. import { ListItem, Select } from "./ui-lib";
  4. import { DEFAULT_STT_ENGINES } from "../constant";
  5. import { isFirefox } from "../utils";
  6. export function STTConfigList(props: {
  7. sttConfig: STTConfig;
  8. updateConfig: (updater: (config: STTConfig) => void) => void;
  9. }) {
  10. return (
  11. <>
  12. <ListItem
  13. title={Locale.Settings.STT.Enable.Title}
  14. subTitle={Locale.Settings.STT.Enable.SubTitle}
  15. >
  16. <input
  17. type="checkbox"
  18. checked={props.sttConfig.enable}
  19. onChange={(e) =>
  20. props.updateConfig(
  21. (config) => (config.enable = e.currentTarget.checked),
  22. )
  23. }
  24. ></input>
  25. </ListItem>
  26. {!isFirefox() && (
  27. <ListItem title={Locale.Settings.STT.Engine.Title}>
  28. <Select
  29. value={props.sttConfig.engine}
  30. onChange={(e) => {
  31. props.updateConfig(
  32. (config) =>
  33. (config.engine = STTConfigValidator.engine(
  34. e.currentTarget.value,
  35. )),
  36. );
  37. }}
  38. >
  39. {DEFAULT_STT_ENGINES.map((v, i) => (
  40. <option value={v} key={i}>
  41. {v}
  42. </option>
  43. ))}
  44. </Select>
  45. </ListItem>
  46. )}
  47. </>
  48. );
  49. }