Files
EchoChat/backend/go-service/app/dto/transcribe_dto.go
2026-05-18 21:23:00 +08:00

54 lines
2.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package dto 包含 transcribe 模块的请求/响应数据结构
package dto
import "time"
// AdminTranscribeRequest POST /admin/recordings/:id/transcribe 请求体
type AdminTranscribeRequest struct {
Force bool `json:"force"` // true=已 ready 时强制重新转写
Language string `json:"language"` // 可选 ISO-639 语言提示,"" 表示自动检测
}
// AdminTranscriptDTO 转写结果出参(去掉/格式化数据库字段,便于前端消费)
type AdminTranscriptDTO struct {
ID int64 `json:"id"`
RecordingID int64 `json:"recording_id"`
RoomID int64 `json:"room_id"`
Status string `json:"status"` // pending/running/ready/failed
StatusLabel string `json:"status_label"` // 中文标签
Text string `json:"text"`
Segments []AdminTranscriptSeg `json:"segments"` // 解析后的时间轴
Language string `json:"language"`
DurationSec int `json:"duration_sec"`
ProviderCode string `json:"provider_code"`
ModelCode string `json:"model_code"`
ErrorMsg string `json:"error_msg"`
StartedAt string `json:"started_at"` // YYYY-MM-DD HH:MM:SS空则 ""
FinishedAt string `json:"finished_at"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// AdminTranscriptSeg 转写的单段时间轴
type AdminTranscriptSeg struct {
Start float64 `json:"start"`
End float64 `json:"end"`
Text string `json:"text"`
}
// FormatTime 工具time.Time 安全格式化(零值返回 ""
func FormatTranscriptTime(t time.Time) string {
if t.IsZero() {
return ""
}
return t.Format("2006-01-02 15:04:05")
}
// FormatTranscriptTimePtr 工具:*time.Time 安全格式化
func FormatTranscriptTimePtr(t *time.Time) string {
if t == nil || t.IsZero() {
return ""
}
return t.Format("2006-01-02 15:04:05")
}