refactor: 重构项目架构,拆分代码到模块化目录
将单文件tts_server.go重构为模块化项目结构,拆分出common、dto、middleware、router、controller、service、adapter、setting等目录,优化代码组织提升可维护性
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package dto
|
||||
|
||||
type HealthResponse struct {
|
||||
Status string `json:"status"`
|
||||
Service string `json:"service"`
|
||||
Version string `json:"version"`
|
||||
Uptime string `json:"uptime"`
|
||||
StartTime string `json:"start_time"`
|
||||
Memory map[string]interface{} `json:"memory"`
|
||||
APIStats APIStatsResponse `json:"api_stats"`
|
||||
Errors ErrorResponse `json:"errors"`
|
||||
ConfigStatus ConfigStatusResponse `json:"config_status"`
|
||||
}
|
||||
|
||||
type APIStatsResponse struct {
|
||||
TotalRequests int `json:"total_requests"`
|
||||
SuccessfulRequests int64 `json:"successful_requests"`
|
||||
FailedRequests int64 `json:"failed_requests"`
|
||||
ErrorRatePercent string `json:"error_rate_percent"`
|
||||
AvgResponseTimeMs string `json:"avg_response_time_ms"`
|
||||
RecentResponseTimesMs []float64 `json:"recent_response_times_ms"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
RecentErrorsCount int `json:"recent_errors_count"`
|
||||
}
|
||||
|
||||
type ConfigStatusResponse struct {
|
||||
AllRequiredVarsSet bool `json:"all_required_vars_set"`
|
||||
ConfigError bool `json:"config_error"`
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type OpenAITTSRequest struct {
|
||||
Model string `json:"model"`
|
||||
Input string `json:"input"`
|
||||
Voice string `json:"voice"`
|
||||
ResponseFormat string `json:"response_format,omitempty"`
|
||||
Speed float64 `json:"speed,omitempty"`
|
||||
}
|
||||
|
||||
type V3TTSResponse struct {
|
||||
ReqID string `json:"reqid"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Event string `json:"event"`
|
||||
Sequence int `json:"sequence"`
|
||||
Data string `json:"data"`
|
||||
Sentence string `json:"sentence,omitempty"`
|
||||
IsFinal bool `json:"is_final"`
|
||||
Usage *V3Usage `json:"usage,omitempty"`
|
||||
}
|
||||
|
||||
type V3Usage struct {
|
||||
TextWords int `json:"text_words"`
|
||||
}
|
||||
|
||||
type ByteDanceTTSConfig struct {
|
||||
ApiKey string
|
||||
ResourceId string
|
||||
Speaker string
|
||||
URL string
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
type SynthesisResult struct {
|
||||
AudioData []byte
|
||||
ReqID string
|
||||
}
|
||||
Reference in New Issue
Block a user