audio.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package dto
  2. import (
  3. "one-api/types"
  4. "github.com/gin-gonic/gin"
  5. )
  6. type AudioRequest struct {
  7. Model string `json:"model"`
  8. Input string `json:"input"`
  9. Voice string `json:"voice"`
  10. Speed float64 `json:"speed,omitempty"`
  11. ResponseFormat string `json:"response_format,omitempty"`
  12. }
  13. func (r *AudioRequest) GetTokenCountMeta() *types.TokenCountMeta {
  14. meta := &types.TokenCountMeta{
  15. CombineText: r.Input,
  16. TokenType: types.TokenTypeTextNumber,
  17. }
  18. return meta
  19. }
  20. func (r *AudioRequest) IsStream(c *gin.Context) bool {
  21. return false
  22. }
  23. type AudioResponse struct {
  24. Text string `json:"text"`
  25. }
  26. type WhisperVerboseJSONResponse struct {
  27. Task string `json:"task,omitempty"`
  28. Language string `json:"language,omitempty"`
  29. Duration float64 `json:"duration,omitempty"`
  30. Text string `json:"text,omitempty"`
  31. Segments []Segment `json:"segments,omitempty"`
  32. }
  33. type Segment struct {
  34. Id int `json:"id"`
  35. Seek int `json:"seek"`
  36. Start float64 `json:"start"`
  37. End float64 `json:"end"`
  38. Text string `json:"text"`
  39. Tokens []int `json:"tokens"`
  40. Temperature float64 `json:"temperature"`
  41. AvgLogprob float64 `json:"avg_logprob"`
  42. CompressionRatio float64 `json:"compression_ratio"`
  43. NoSpeechProb float64 `json:"no_speech_prob"`
  44. }