Text to Speech Speech to Text

123456789101112131415161718192021222324252627282930313233343536
  1. package api
  2. import (
  3. "fmt"
  4. )
  5. const (
  6. EnUS = 1
  7. ZhCN = 2
  8. )
  9. type CommonParams struct {
  10. TargetStr string `form:"lang"`
  11. Target int
  12. Page int `form:"page"`
  13. Limit int `form:"limit"`
  14. }
  15. func (cp *CommonParams) Check() error {
  16. switch cp.TargetStr {
  17. case "", "en-US":
  18. cp.Target = EnUS
  19. case "zh-CN":
  20. cp.Target = ZhCN
  21. default:
  22. return fmt.Errorf("Unexpected target param: %s", cp.TargetStr)
  23. }
  24. if cp.Limit == 0 {
  25. cp.Limit = 10
  26. }
  27. if cp.Page == 0 {
  28. cp.Page = 1
  29. }
  30. return nil
  31. }