Documentation
¶
Index ¶
- Variables
- func CalculateAudioHash(data []byte) string
- func ConvertToMono(data []byte) ([]byte, error)
- func ErrAPIRequest(details string) error
- func ErrDeletionFailed(speakerID, details string) error
- func ErrIdentificationFailed(details string) error
- func ErrInvalidConfig(details string) error
- func ErrRegistrationFailed(speakerID, details string) error
- func FormatDuration(d time.Duration) string
- func FormatFileSize(size int64) string
- func GenerateSpeakerID(prefix string) string
- func GetErrorCode(err error) string
- func IsValidSpeakerID(speakerID string) bool
- func IsVoiceprintError(err error) bool
- func LoadAudioFile(filePath string) ([]byte, error)
- func SanitizeSpeakerID(speakerID string) string
- func ValidateAudioDuration(data []byte, minDuration, maxDuration time.Duration) error
- func ValidateAudioQuality(data []byte) error
- func ValidateWAVFormat(data []byte) error
- type AudioInfo
- type AudioResource
- type BatchIdentifyRequest
- type BatchIdentifyResponse
- type BatchRegisterRequest
- type BatchRegisterResponse
- type Cache
- type Client
- func (c *Client) Close() error
- func (c *Client) DeleteVoiceprint(ctx context.Context, speakerID string, assistantID ...string) (*DeleteResponse, error)
- func (c *Client) HealthCheck(ctx context.Context) (*HealthResponse, error)
- func (c *Client) IdentifyVoiceprint(ctx context.Context, req *IdentifyRequest) (*IdentifyResponse, error)
- func (c *Client) IsEnabled() bool
- func (c *Client) RegisterVoiceprint(ctx context.Context, req *RegisterRequest) (*RegisterResponse, error)
- type Config
- type CreateFeatureResult
- type CreateGroupResult
- type DeleteFeatureResult
- type DeleteGroupResult
- type DeleteRequest
- type DeleteResponse
- type Factory
- type FeatureItem
- type HTTPProviderAdapter
- func (a *HTTPProviderAdapter) Close() error
- func (a *HTTPProviderAdapter) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
- func (a *HTTPProviderAdapter) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
- func (a *HTTPProviderAdapter) DeleteFeature(ctx context.Context, groupID, featureID string) error
- func (a *HTTPProviderAdapter) DeleteGroup(ctx context.Context, groupID string) error
- func (a *HTTPProviderAdapter) HealthCheck(ctx context.Context) error
- func (a *HTTPProviderAdapter) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
- func (a *HTTPProviderAdapter) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
- func (a *HTTPProviderAdapter) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
- func (a *HTTPProviderAdapter) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, ...) (*UpdateFeatureResult, error)
- type HealthResponse
- type IdentifyRequest
- type IdentifyResponse
- type IdentifyResult
- type Provider
- type ProviderConfig
- type QueryFeatureListResult
- type RegisterRequest
- type RegisterResponse
- type ResponseFormat
- type SearchFeaResult
- type SearchScoreFeaResult
- type Service
- func (s *Service) BatchRegister(ctx context.Context, requests []RegisterRequest) (*BatchRegisterResponse, error)
- func (s *Service) Close() error
- func (s *Service) DeleteVoiceprint(ctx context.Context, speakerID string) (*DeleteResponse, error)
- func (s *Service) GetStatistics() *Statistics
- func (s *Service) HealthCheck(ctx context.Context) (*HealthResponse, error)
- func (s *Service) IdentifyVoiceprint(ctx context.Context, req *IdentifyRequest) (*IdentifyResult, error)
- func (s *Service) IdentifyWithConfidence(ctx context.Context, req *IdentifyRequest, minConfidence string) (*IdentifyResult, error)
- func (s *Service) IsEnabled() bool
- func (s *Service) RegisterVoiceprint(ctx context.Context, req *RegisterRequest) (*RegisterResponse, error)
- type SpeakerInfo
- type Statistics
- type TextResponse
- type UpdateFeatureResult
- type VoiceprintError
- type VoiceprintProvider
- type VolcengineClient
- func (c *VolcengineClient) Close() error
- func (c *VolcengineClient) Delete(ctx context.Context, uuid string) error
- func (c *VolcengineClient) HealthCheck(ctx context.Context) error
- func (c *VolcengineClient) Query(ctx context.Context, uuids []string, limit int, iterator string) (*VolcengineQueryResult, error)
- func (c *VolcengineClient) Register(ctx context.Context, audio, audioName, metaInfo string) (*VolcengineRegisterResult, error)
- func (c *VolcengineClient) Update(ctx context.Context, uuid, audio, audioName, metaInfo string) error
- type VolcengineConfig
- type VolcengineDeleteRequest
- type VolcengineDeleteResponse
- type VolcengineError
- type VolcengineErrorDetail
- type VolcengineProviderAdapter
- func (a *VolcengineProviderAdapter) Close() error
- func (a *VolcengineProviderAdapter) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
- func (a *VolcengineProviderAdapter) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
- func (a *VolcengineProviderAdapter) DeleteFeature(ctx context.Context, groupID, featureID string) error
- func (a *VolcengineProviderAdapter) DeleteGroup(ctx context.Context, groupID string) error
- func (a *VolcengineProviderAdapter) HealthCheck(ctx context.Context) error
- func (a *VolcengineProviderAdapter) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
- func (a *VolcengineProviderAdapter) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
- func (a *VolcengineProviderAdapter) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
- func (a *VolcengineProviderAdapter) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, ...) (*UpdateFeatureResult, error)
- type VolcengineQueryRequest
- type VolcengineQueryResponse
- type VolcengineQueryResult
- type VolcengineRegisterRequest
- type VolcengineRegisterResponse
- type VolcengineRegisterResult
- type VolcengineResponseMetadata
- type VolcengineUpdateRequest
- type VolcengineUpdateResponse
- type VolcengineVoicePrint
- type VolcengineVoicePrintInfo
- type XunfeiAuth
- type XunfeiClient
- func (c *XunfeiClient) Close() error
- func (c *XunfeiClient) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
- func (c *XunfeiClient) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
- func (c *XunfeiClient) DeleteFeature(ctx context.Context, groupID, featureID string) (*DeleteFeatureResult, error)
- func (c *XunfeiClient) DeleteGroup(ctx context.Context, groupID string) (*DeleteGroupResult, error)
- func (c *XunfeiClient) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
- func (c *XunfeiClient) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
- func (c *XunfeiClient) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
- func (c *XunfeiClient) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, ...) (*UpdateFeatureResult, error)
- type XunfeiConfig
- type XunfeiHeader
- type XunfeiParameter
- type XunfeiPayload
- type XunfeiProviderAdapter
- func (a *XunfeiProviderAdapter) Close() error
- func (a *XunfeiProviderAdapter) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
- func (a *XunfeiProviderAdapter) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
- func (a *XunfeiProviderAdapter) DeleteFeature(ctx context.Context, groupID, featureID string) error
- func (a *XunfeiProviderAdapter) DeleteGroup(ctx context.Context, groupID string) error
- func (a *XunfeiProviderAdapter) HealthCheck(ctx context.Context) error
- func (a *XunfeiProviderAdapter) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
- func (a *XunfeiProviderAdapter) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
- func (a *XunfeiProviderAdapter) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
- func (a *XunfeiProviderAdapter) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, ...) (*UpdateFeatureResult, error)
- type XunfeiRequest
- type XunfeiResponse
- type XunfeiResponseHeader
- type XunfeiResponsePayload
- type XunfeiServiceParam
Constants ¶
This section is empty.
Variables ¶
var ( ErrServiceDisabled = fmt.Errorf("voiceprint service is disabled") ErrInvalidAudioFormat = fmt.Errorf("invalid audio format, only WAV is supported") ErrAudioTooShort = fmt.Errorf("audio duration is too short") ErrAudioTooLong = fmt.Errorf("audio duration is too long") ErrSpeakerNotFound = fmt.Errorf("speaker not found") ErrSpeakerExists = fmt.Errorf("speaker already exists") ErrLowSimilarity = fmt.Errorf("similarity score too low") ErrInvalidResponse = fmt.Errorf("invalid response from voiceprint service") ErrTimeout = fmt.Errorf("voiceprint service timeout") ErrTooManyCandidates = fmt.Errorf("too many candidate speakers") )
声纹识别相关错误定义
Functions ¶
func CalculateAudioHash ¶
CalculateAudioHash 计算音频数据的哈希值(用于去重)
func ErrAPIRequest ¶
func ErrDeletionFailed ¶
func ErrIdentificationFailed ¶
func ErrRegistrationFailed ¶
func ValidateAudioDuration ¶
ValidateAudioDuration 验证音频时长
func ValidateAudioQuality ¶
ValidateAudioQuality 验证音频质量
Types ¶
type AudioInfo ¶
type AudioInfo struct {
Format string `json:"format"`
SampleRate int `json:"sample_rate"`
Channels int `json:"channels"`
BitsPerSample int `json:"bits_per_sample"`
Duration time.Duration `json:"duration"`
FileSize int64 `json:"file_size"`
}
AudioInfo 音频文件信息
type AudioResource ¶
type AudioResource struct {
Encoding string `json:"encoding"` // lame
SampleRate int `json:"sample_rate"` // 16000
Channels int `json:"channels"` // 1
BitDepth int `json:"bit_depth"` // 16
Status int `json:"status"` // 3
Audio string `json:"audio"` // base64编码的音频数据
}
AudioResource 音频资源
type BatchIdentifyRequest ¶
type BatchIdentifyRequest struct {
Requests []IdentifyRequest `json:"requests" validate:"required,min=1"`
}
BatchIdentifyRequest 批量识别请求
type BatchIdentifyResponse ¶
type BatchIdentifyResponse struct {
Success int `json:"success"`
Failed int `json:"failed"`
Total int `json:"total"`
Results []IdentifyResponse `json:"results"`
Timestamp time.Time `json:"timestamp"`
}
BatchIdentifyResponse 批量识别响应
type BatchRegisterRequest ¶
type BatchRegisterRequest struct {
Speakers []RegisterRequest `json:"speakers" validate:"required,min=1"`
}
BatchRegisterRequest 批量注册请求
type BatchRegisterResponse ¶
type BatchRegisterResponse struct {
Success int `json:"success"`
Failed int `json:"failed"`
Total int `json:"total"`
Results []RegisterResponse `json:"results"`
Timestamp time.Time `json:"timestamp"`
}
BatchRegisterResponse 批量注册响应
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) (interface{}, bool)
Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
Exists(ctx context.Context, key string) bool
Delete(ctx context.Context, key string) error
}
Cache 缓存接口
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 声纹识别客户端
func (*Client) DeleteVoiceprint ¶
func (c *Client) DeleteVoiceprint(ctx context.Context, speakerID string, assistantID ...string) (*DeleteResponse, error)
DeleteVoiceprint 删除声纹
func (*Client) HealthCheck ¶
func (c *Client) HealthCheck(ctx context.Context) (*HealthResponse, error)
HealthCheck 健康检查
func (*Client) IdentifyVoiceprint ¶
func (c *Client) IdentifyVoiceprint(ctx context.Context, req *IdentifyRequest) (*IdentifyResponse, error)
IdentifyVoiceprint 识别声纹
func (*Client) RegisterVoiceprint ¶
func (c *Client) RegisterVoiceprint(ctx context.Context, req *RegisterRequest) (*RegisterResponse, error)
RegisterVoiceprint 注册声纹
type Config ¶
type Config struct {
Enabled bool `env:"VOICEPRINT_ENABLED" mapstructure:"enabled"`
BaseURL string `env:"VOICEPRINT_BASE_URL" mapstructure:"base_url"`
APIKey string `env:"VOICEPRINT_API_KEY" mapstructure:"api_key"`
Timeout time.Duration `env:"VOICEPRINT_TIMEOUT" mapstructure:"timeout"`
ConnectTimeout time.Duration `env:"VOICEPRINT_CONNECT_TIMEOUT" mapstructure:"connect_timeout"`
MaxRetries int `env:"VOICEPRINT_MAX_RETRIES" mapstructure:"max_retries"`
RetryInterval time.Duration `env:"VOICEPRINT_RETRY_INTERVAL" mapstructure:"retry_interval"`
SimilarityThreshold float64 `env:"VOICEPRINT_SIMILARITY_THRESHOLD" mapstructure:"similarity_threshold"`
MaxCandidates int `env:"VOICEPRINT_MAX_CANDIDATES" mapstructure:"max_candidates"`
CacheEnabled bool `env:"VOICEPRINT_CACHE_ENABLED" mapstructure:"cache_enabled"`
CacheTTL time.Duration `env:"VOICEPRINT_CACHE_TTL" mapstructure:"cache_ttl"`
LogEnabled bool `env:"VOICEPRINT_LOG_ENABLED" mapstructure:"log_enabled"`
LogLevel string `env:"VOICEPRINT_LOG_LEVEL" mapstructure:"log_level"`
}
Config 声纹识别服务配置
func NewConfigFromEnv ¶
NewConfigFromEnv 从环境变量创建配置,支持自定义环境变量获取函数
type CreateFeatureResult ¶
type CreateFeatureResult struct {
FeatureID string `json:"featureId"`
}
CreateFeatureResult 创建特征结果
type CreateGroupResult ¶
type CreateGroupResult struct {
GroupID string `json:"groupId"`
GroupName string `json:"groupName"`
GroupInfo string `json:"groupInfo"`
}
CreateGroupResult 创建特征库结果
type DeleteFeatureResult ¶
type DeleteFeatureResult struct {
Message string `json:"msg"`
}
DeleteFeatureResult 删除特征结果
type DeleteGroupResult ¶
type DeleteGroupResult struct {
Message string `json:"msg"`
}
DeleteGroupResult 删除特征库结果
type DeleteRequest ¶
type DeleteRequest struct {
SpeakerID string `json:"speaker_id" validate:"required"`
AgentID string `json:"agent_id,omitempty"`
}
DeleteRequest 声纹删除请求
type DeleteResponse ¶
type DeleteResponse struct {
Success bool `json:"success"`
Message string `json:"msg"`
SpeakerID string `json:"speaker_id,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
DeleteResponse 声纹删除响应
type Factory ¶
type Factory struct{}
Factory 声纹识别工厂
func (*Factory) CreateProvider ¶
func (f *Factory) CreateProvider(config *ProviderConfig) (VoiceprintProvider, error)
CreateProvider 创建提供商
type FeatureItem ¶
type FeatureItem struct {
FeatureID string `json:"featureId"`
FeatureInfo string `json:"featureInfo"`
}
FeatureItem 特征项
type HTTPProviderAdapter ¶
type HTTPProviderAdapter struct {
// contains filtered or unexported fields
}
HTTPProviderAdapter HTTP 提供商适配器
func (*HTTPProviderAdapter) CreateFeature ¶
func (a *HTTPProviderAdapter) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
CreateFeature 创建特征
func (*HTTPProviderAdapter) CreateGroup ¶
func (a *HTTPProviderAdapter) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
CreateGroup 创建特征库
func (*HTTPProviderAdapter) DeleteFeature ¶
func (a *HTTPProviderAdapter) DeleteFeature(ctx context.Context, groupID, featureID string) error
DeleteFeature 删除特征
func (*HTTPProviderAdapter) DeleteGroup ¶
func (a *HTTPProviderAdapter) DeleteGroup(ctx context.Context, groupID string) error
DeleteGroup 删除特征库
func (*HTTPProviderAdapter) HealthCheck ¶
func (a *HTTPProviderAdapter) HealthCheck(ctx context.Context) error
HealthCheck 健康检查
func (*HTTPProviderAdapter) QueryFeatureList ¶
func (a *HTTPProviderAdapter) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
QueryFeatureList 查询特征列表
func (*HTTPProviderAdapter) SearchFea ¶
func (a *HTTPProviderAdapter) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
SearchFea 1:N比对
func (*HTTPProviderAdapter) SearchScoreFea ¶
func (a *HTTPProviderAdapter) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
SearchScoreFea 1:1比对
func (*HTTPProviderAdapter) UpdateFeature ¶
func (a *HTTPProviderAdapter) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, cover bool) (*UpdateFeatureResult, error)
UpdateFeature 更新特征
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
TotalVoiceprints int `json:"total_voiceprints"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
HealthResponse 健康检查响应
type IdentifyRequest ¶
type IdentifyRequest struct {
CandidateIDs []string `json:"candidate_ids" validate:"required,min=1"`
AgentID string `json:"agent_id" validate:"required"`
AudioData []byte `json:"-"`
AudioFormat string `json:"audio_format,omitempty"`
Threshold float64 `json:"threshold,omitempty"`
MaxResults int `json:"max_results,omitempty"`
}
IdentifyRequest 声纹识别请求
type IdentifyResponse ¶
type IdentifyResponse struct {
SpeakerID string `json:"speaker_id"`
Score float64 `json:"score"`
Timestamp time.Time `json:"timestamp,omitempty"`
Confidence string `json:"confidence,omitempty"`
}
IdentifyResponse 声纹识别响应
type IdentifyResult ¶
type IdentifyResult struct {
SpeakerID string `json:"speaker_id"`
Score float64 `json:"score"`
Confidence string `json:"confidence"`
Threshold float64 `json:"threshold"`
IsMatch bool `json:"is_match"`
ProcessTime time.Duration `json:"process_time"`
Timestamp time.Time `json:"timestamp"`
}
IdentifyResult 识别结果(扩展版本)
func (*IdentifyResult) GetConfidenceLevel ¶
func (r *IdentifyResult) GetConfidenceLevel() string
GetConfidenceLevel 根据相似度分数获取置信度等级
func (*IdentifyResult) IsHighConfidence ¶
func (r *IdentifyResult) IsHighConfidence() bool
IsHighConfidence 判断是否为高置信度
func (*IdentifyResult) IsValidMatch ¶
func (r *IdentifyResult) IsValidMatch() bool
IsValidMatch 判断是否为有效匹配
type ProviderConfig ¶
type ProviderConfig struct {
Provider Provider `json:"provider"`
Options map[string]interface{} `json:"options"`
}
ProviderConfig 提供商配置
type QueryFeatureListResult ¶
type QueryFeatureListResult struct {
Features []FeatureItem `json:"features"`
}
QueryFeatureListResult 查询特征列表结果
func (*QueryFeatureListResult) UnmarshalJSON ¶
func (q *QueryFeatureListResult) UnmarshalJSON(data []byte) error
UnmarshalJSON 自定义JSON解析,处理数组响应
type RegisterRequest ¶
type RegisterRequest struct {
SpeakerID string `json:"speaker_id" validate:"required"`
AgentID string `json:"agent_id" validate:"required"`
AudioData []byte `json:"-"`
AudioFormat string `json:"audio_format,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
RegisterRequest 声纹注册请求
type RegisterResponse ¶
type RegisterResponse struct {
Success bool `json:"success"`
Message string `json:"msg"`
SpeakerID string `json:"speaker_id,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
RegisterResponse 声纹注册响应
type ResponseFormat ¶
type ResponseFormat struct {
Encoding string `json:"encoding"` // utf8
Compress string `json:"compress"` // raw
Format string `json:"format"` // json
}
ResponseFormat 响应格式配置
type SearchFeaResult ¶
type SearchFeaResult struct {
ScoreList []SearchScoreFeaResult `json:"scoreList"`
}
SearchFeaResult 1:N比对结果
func (*SearchFeaResult) UnmarshalJSON ¶
func (s *SearchFeaResult) UnmarshalJSON(data []byte) error
UnmarshalJSON 自定义JSON解析,处理数组响应
type SearchScoreFeaResult ¶
type SearchScoreFeaResult struct {
Score float64 `json:"score"`
FeatureID string `json:"featureId"`
FeatureInfo string `json:"featureInfo"`
}
SearchScoreFeaResult 1:1比对结果
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 声纹识别服务
func NewService ¶
NewService 创建新的声纹识别服务
func (*Service) BatchRegister ¶
func (s *Service) BatchRegister(ctx context.Context, requests []RegisterRequest) (*BatchRegisterResponse, error)
BatchRegister 批量注册声纹
func (*Service) DeleteVoiceprint ¶
DeleteVoiceprint 删除声纹
func (*Service) HealthCheck ¶
func (s *Service) HealthCheck(ctx context.Context) (*HealthResponse, error)
HealthCheck 健康检查
func (*Service) IdentifyVoiceprint ¶
func (s *Service) IdentifyVoiceprint(ctx context.Context, req *IdentifyRequest) (*IdentifyResult, error)
IdentifyVoiceprint 识别声纹
func (*Service) IdentifyWithConfidence ¶
func (s *Service) IdentifyWithConfidence(ctx context.Context, req *IdentifyRequest, minConfidence string) (*IdentifyResult, error)
IdentifyWithConfidence 带置信度检查的识别
func (*Service) RegisterVoiceprint ¶
func (s *Service) RegisterVoiceprint(ctx context.Context, req *RegisterRequest) (*RegisterResponse, error)
RegisterVoiceprint 注册声纹
type SpeakerInfo ¶
type SpeakerInfo struct {
SpeakerID string `json:"speaker_id"`
RegisterTime time.Time `json:"register_time"`
UpdateTime time.Time `json:"update_time"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
SpeakerInfo 说话人信息
type Statistics ¶
type Statistics struct {
TotalSpeakers int `json:"total_speakers"`
TotalIdentifications int `json:"total_identifications"`
SuccessRate float64 `json:"success_rate"`
AverageScore float64 `json:"average_score"`
LastActivity time.Time `json:"last_activity"`
}
Statistics 统计信息
type TextResponse ¶
TextResponse 文本响应
type UpdateFeatureResult ¶
type UpdateFeatureResult struct {
Message string `json:"msg"`
}
UpdateFeatureResult 更新特征结果
type VoiceprintError ¶
type VoiceprintError struct {
Code string `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
}
VoiceprintError 声纹识别错误类型
func (*VoiceprintError) Error ¶
func (e *VoiceprintError) Error() string
type VoiceprintProvider ¶
type VoiceprintProvider interface {
// 特征库管理
CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
DeleteGroup(ctx context.Context, groupID string) error
// 特征管理
CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, cover bool) (*UpdateFeatureResult, error)
DeleteFeature(ctx context.Context, groupID, featureID string) error
QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
// 特征比对
SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
// 健康检查
HealthCheck(ctx context.Context) error
// 关闭
Close() error
}
VoiceprintProvider 声纹识别提供商接口
type VolcengineClient ¶
type VolcengineClient struct {
// contains filtered or unexported fields
}
VolcengineClient 火山引擎声纹识别客户端
func NewVolcengineClient ¶
func NewVolcengineClient(config *VolcengineConfig, logger *zap.Logger) (*VolcengineClient, error)
NewVolcengineClient 创建火山引擎客户端
func (*VolcengineClient) Delete ¶
func (c *VolcengineClient) Delete(ctx context.Context, uuid string) error
Delete 删除声纹
func (*VolcengineClient) HealthCheck ¶
func (c *VolcengineClient) HealthCheck(ctx context.Context) error
HealthCheck 健康检查
func (*VolcengineClient) Query ¶
func (c *VolcengineClient) Query(ctx context.Context, uuids []string, limit int, iterator string) (*VolcengineQueryResult, error)
Query 查询声纹
func (*VolcengineClient) Register ¶
func (c *VolcengineClient) Register(ctx context.Context, audio, audioName, metaInfo string) (*VolcengineRegisterResult, error)
Register 注册声纹
type VolcengineConfig ¶
type VolcengineConfig struct {
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
Region string `json:"region"`
BaseURL string `json:"base_url"`
Timeout time.Duration `json:"timeout"`
}
VolcengineConfig 火山引擎配置
type VolcengineDeleteRequest ¶
type VolcengineDeleteRequest struct {
UUID string `json:"UUID"` // 要删除的声纹唯一标识符
}
VolcengineDeleteRequest 火山引擎删除请求
type VolcengineDeleteResponse ¶
type VolcengineDeleteResponse struct {
ResponseMetadata VolcengineResponseMetadata `json:"ResponseMetadata"`
Result interface{} `json:"Result"`
}
VolcengineDeleteResponse 火山引擎删除响应
type VolcengineError ¶
type VolcengineError struct {
ResponseMetadata VolcengineResponseMetadata `json:"ResponseMetadata"`
Error VolcengineErrorDetail `json:"Error"`
}
VolcengineError 火山引擎错误响应
type VolcengineErrorDetail ¶
type VolcengineErrorDetail struct {
Code string `json:"Code"` // 错误码
Message string `json:"Message"` // 错误信息
}
VolcengineErrorDetail 错误详情
type VolcengineProviderAdapter ¶
type VolcengineProviderAdapter struct {
// contains filtered or unexported fields
}
VolcengineProviderAdapter 火山引擎提供商适配器
func (*VolcengineProviderAdapter) Close ¶
func (a *VolcengineProviderAdapter) Close() error
Close 关闭
func (*VolcengineProviderAdapter) CreateFeature ¶
func (a *VolcengineProviderAdapter) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
CreateFeature 创建特征 - 映射到Register
func (*VolcengineProviderAdapter) CreateGroup ¶
func (a *VolcengineProviderAdapter) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
CreateGroup 创建特征库 - 火山引擎不支持
func (*VolcengineProviderAdapter) DeleteFeature ¶
func (a *VolcengineProviderAdapter) DeleteFeature(ctx context.Context, groupID, featureID string) error
DeleteFeature 删除特征 - 映射到Delete
func (*VolcengineProviderAdapter) DeleteGroup ¶
func (a *VolcengineProviderAdapter) DeleteGroup(ctx context.Context, groupID string) error
DeleteGroup 删除特征库 - 火山引擎不支持
func (*VolcengineProviderAdapter) HealthCheck ¶
func (a *VolcengineProviderAdapter) HealthCheck(ctx context.Context) error
HealthCheck 健康检查
func (*VolcengineProviderAdapter) QueryFeatureList ¶
func (a *VolcengineProviderAdapter) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
QueryFeatureList 查询特征列表 - 映射到Query
func (*VolcengineProviderAdapter) SearchFea ¶
func (a *VolcengineProviderAdapter) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
SearchFea 1:N比对 - 火山引擎不支持
func (*VolcengineProviderAdapter) SearchScoreFea ¶
func (a *VolcengineProviderAdapter) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
SearchScoreFea 1:1比对 - 火山引擎不支持
func (*VolcengineProviderAdapter) UpdateFeature ¶
func (a *VolcengineProviderAdapter) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, cover bool) (*UpdateFeatureResult, error)
UpdateFeature 更新特征 - 映射到Update
type VolcengineQueryRequest ¶
type VolcengineQueryRequest struct {
UUIDs []string `json:"UUIDs,omitempty"` // 声纹ID列表,可选
Limit int `json:"Limit,omitempty"` // 每页返回的最大结果数量,默认50
Iterator string `json:"Iterator,omitempty"` // 分页标识
}
VolcengineQueryRequest 火山引擎查询请求
type VolcengineQueryResponse ¶
type VolcengineQueryResponse struct {
ResponseMetadata VolcengineResponseMetadata `json:"ResponseMetadata"`
Result VolcengineQueryResult `json:"Result"`
}
VolcengineQueryResponse 火山引擎查询响应
type VolcengineQueryResult ¶
type VolcengineQueryResult struct {
VoicePrints []VolcengineVoicePrint `json:"VoicePrints,omitempty"` // 声纹对象数组
NextIterator string `json:"NextIterator,omitempty"` // 下一页的分页标识
}
VolcengineQueryResult 查询结果
type VolcengineRegisterRequest ¶
type VolcengineRegisterRequest struct {
Audio string `json:"Audio"` // Base64编码的WAV音频数据
MetaInfo string `json:"MetaInfo"` // 声纹元信息,可选
AudioName string `json:"AudioName"` // 音频样本名称
}
VolcengineRegisterRequest 火山引擎注册请求
type VolcengineRegisterResponse ¶
type VolcengineRegisterResponse struct {
ResponseMetadata VolcengineResponseMetadata `json:"ResponseMetadata"`
Result VolcengineRegisterResult `json:"Result"`
}
VolcengineRegisterResponse 火山引擎注册响应
type VolcengineRegisterResult ¶
type VolcengineRegisterResult struct {
UUID string `json:"UUID"` // 注册成功的声纹唯一标识符
}
VolcengineRegisterResult 注册结果
type VolcengineResponseMetadata ¶
type VolcengineResponseMetadata struct {
Action string `json:"Action"` // 接口名称
Region string `json:"Region"` // 区域
Service string `json:"Service"` // 服务名称
Version string `json:"Version"` // 接口版本
RequestID string `json:"RequestId"` // 请求ID
}
VolcengineResponseMetadata 响应元数据
type VolcengineUpdateRequest ¶
type VolcengineUpdateRequest struct {
UUID string `json:"UUID"` // 要更新的声纹唯一标识符
Audio string `json:"Audio,omitempty"` // Base64编码的WAV音频数据,可选
MetaInfo string `json:"MetaInfo,omitempty"` // 声纹元信息,可选
AudioName string `json:"AudioName,omitempty"` // 音频样本名称,可选
}
VolcengineUpdateRequest 火山引擎更新请求
type VolcengineUpdateResponse ¶
type VolcengineUpdateResponse struct {
ResponseMetadata VolcengineResponseMetadata `json:"ResponseMetadata"`
Result interface{} `json:"Result"`
}
VolcengineUpdateResponse 火山引擎更新响应
type VolcengineVoicePrint ¶
type VolcengineVoicePrint struct {
UUID string `json:"UUID,omitempty"` // 声纹唯一标识符
MetaInfo string `json:"MetaInfo,omitempty"` // 声纹元信息
AccountID string `json:"AccountID,omitempty"` // 火山引擎账户ID
AudioName string `json:"AudioName,omitempty"` // 音频样本名称
CreatedAt int64 `json:"CreatedAt,omitempty"` // 创建时间,Unix时间戳(毫秒)
UpdatedAt int64 `json:"UpdatedAt,omitempty"` // 最后更新时间,Unix时间戳(毫秒)
VoicePrint string `json:"VoicePrint,omitempty"` // 声纹特征数据
}
VolcengineVoicePrint 声纹对象
type VolcengineVoicePrintInfo ¶
type VolcengineVoicePrintInfo struct {
UUID string // 声纹唯一标识符
MetaInfo string // 声纹元信息
AudioName string // 音频样本名称
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 最后更新时间
VoicePrint string // 声纹特征数据
}
VolcengineVoicePrintInfo 声纹信息(用于统一接口)
type XunfeiAuth ¶
XunfeiAuth 讯飞认证
func NewXunfeiAuth ¶
func NewXunfeiAuth(apiKey, apiSecret, host string) *XunfeiAuth
NewXunfeiAuth 创建讯飞认证
func (*XunfeiAuth) BuildAuthURL ¶
func (a *XunfeiAuth) BuildAuthURL(baseURL, path string) (string, error)
BuildAuthURL 构建带认证参数的URL
func (*XunfeiAuth) GenerateAuthHeader ¶
func (a *XunfeiAuth) GenerateAuthHeader(method, path string) (string, string, error)
GenerateAuthHeader 生成认证头
func (*XunfeiAuth) VerifyResponse ¶
func (a *XunfeiAuth) VerifyResponse(responseDate string) error
VerifyResponse 验证响应(可选,用于验证服务器响应的完整性)
type XunfeiClient ¶
type XunfeiClient struct {
// contains filtered or unexported fields
}
XunfeiClient 讯飞声纹识别客户端
func NewXunfeiClient ¶
func NewXunfeiClient(config *XunfeiConfig, logger *zap.Logger) (*XunfeiClient, error)
NewXunfeiClient 创建讯飞客户端
func (*XunfeiClient) CreateFeature ¶
func (c *XunfeiClient) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
CreateFeature 添加音频特征
func (*XunfeiClient) CreateGroup ¶
func (c *XunfeiClient) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
CreateGroup 创建声纹特征库
func (*XunfeiClient) DeleteFeature ¶
func (c *XunfeiClient) DeleteFeature(ctx context.Context, groupID, featureID string) (*DeleteFeatureResult, error)
DeleteFeature 删除指定特征
func (*XunfeiClient) DeleteGroup ¶
func (c *XunfeiClient) DeleteGroup(ctx context.Context, groupID string) (*DeleteGroupResult, error)
DeleteGroup 删除声纹特征库
func (*XunfeiClient) QueryFeatureList ¶
func (c *XunfeiClient) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
QueryFeatureList 查询特征列表
func (*XunfeiClient) SearchFea ¶
func (c *XunfeiClient) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
SearchFea 特征比对1:N
func (*XunfeiClient) SearchScoreFea ¶
func (c *XunfeiClient) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
SearchScoreFea 特征比对1:1
func (*XunfeiClient) UpdateFeature ¶
func (c *XunfeiClient) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, cover bool) (*UpdateFeatureResult, error)
UpdateFeature 更新音频特征
type XunfeiConfig ¶
type XunfeiConfig struct {
APIKey string `json:"api_key"`
APISecret string `json:"api_secret"`
AppID string `json:"app_id"`
BaseURL string `json:"base_url"`
Timeout time.Duration `json:"timeout"`
}
XunfeiConfig 讯飞配置
type XunfeiHeader ¶
XunfeiHeader 讯飞请求头
type XunfeiParameter ¶
type XunfeiParameter struct {
S782b4996 XunfeiServiceParam `json:"s782b4996"`
}
XunfeiParameter 讯飞参数
type XunfeiPayload ¶
type XunfeiPayload struct {
Resource *AudioResource `json:"resource,omitempty"`
}
XunfeiPayload 讯飞请求负载
type XunfeiProviderAdapter ¶
type XunfeiProviderAdapter struct {
// contains filtered or unexported fields
}
XunfeiProviderAdapter 讯飞提供商适配器
func (*XunfeiProviderAdapter) CreateFeature ¶
func (a *XunfeiProviderAdapter) CreateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte) (*CreateFeatureResult, error)
CreateFeature 创建特征
func (*XunfeiProviderAdapter) CreateGroup ¶
func (a *XunfeiProviderAdapter) CreateGroup(ctx context.Context, groupID, groupName, groupInfo string) (*CreateGroupResult, error)
CreateGroup 创建特征库
func (*XunfeiProviderAdapter) DeleteFeature ¶
func (a *XunfeiProviderAdapter) DeleteFeature(ctx context.Context, groupID, featureID string) error
DeleteFeature 删除特征
func (*XunfeiProviderAdapter) DeleteGroup ¶
func (a *XunfeiProviderAdapter) DeleteGroup(ctx context.Context, groupID string) error
DeleteGroup 删除特征库
func (*XunfeiProviderAdapter) HealthCheck ¶
func (a *XunfeiProviderAdapter) HealthCheck(ctx context.Context) error
HealthCheck 健康检查
func (*XunfeiProviderAdapter) QueryFeatureList ¶
func (a *XunfeiProviderAdapter) QueryFeatureList(ctx context.Context, groupID string) (*QueryFeatureListResult, error)
QueryFeatureList 查询特征列表
func (*XunfeiProviderAdapter) SearchFea ¶
func (a *XunfeiProviderAdapter) SearchFea(ctx context.Context, groupID string, topK int, audioData []byte) (*SearchFeaResult, error)
SearchFea 1:N比对
func (*XunfeiProviderAdapter) SearchScoreFea ¶
func (a *XunfeiProviderAdapter) SearchScoreFea(ctx context.Context, groupID, dstFeatureID string, audioData []byte) (*SearchScoreFeaResult, error)
SearchScoreFea 1:1比对
func (*XunfeiProviderAdapter) UpdateFeature ¶
func (a *XunfeiProviderAdapter) UpdateFeature(ctx context.Context, groupID, featureID, featureInfo string, audioData []byte, cover bool) (*UpdateFeatureResult, error)
UpdateFeature 更新特征
type XunfeiRequest ¶
type XunfeiRequest struct {
Header XunfeiHeader `json:"header"`
Parameter XunfeiParameter `json:"parameter"`
Payload *XunfeiPayload `json:"payload,omitempty"`
}
XunfeiRequest 讯飞请求基础结构
type XunfeiResponse ¶
type XunfeiResponse struct {
Header XunfeiResponseHeader `json:"header"`
Payload XunfeiResponsePayload `json:"payload"`
}
XunfeiResponse 讯飞响应基础结构
type XunfeiResponseHeader ¶
type XunfeiResponseHeader struct {
Code int `json:"code"`
Message string `json:"message"`
SID string `json:"sid"`
}
XunfeiResponseHeader 讯飞响应头
type XunfeiResponsePayload ¶
type XunfeiResponsePayload struct {
CreateGroupRes *TextResponse `json:"createGroupRes,omitempty"`
CreateFeatureRes *TextResponse `json:"createFeatureRes,omitempty"`
UpdateFeatureRes *TextResponse `json:"updateFeatureRes,omitempty"`
QueryFeatureListRes *TextResponse `json:"queryFeatureListRes,omitempty"`
SearchScoreFeaRes *TextResponse `json:"searchScoreFeaRes,omitempty"`
SearchFeaRes *TextResponse `json:"searchFeaRes,omitempty"`
DeleteFeatureRes *TextResponse `json:"deleteFeatureRes,omitempty"`
DeleteGroupRes *TextResponse `json:"deleteGroupRes,omitempty"`
}
XunfeiResponsePayload 讯飞响应负载
type XunfeiServiceParam ¶
type XunfeiServiceParam struct {
Func string `json:"func"`
// 创建特征库参数
GroupID string `json:"groupId,omitempty"`
GroupName string `json:"groupName,omitempty"`
GroupInfo string `json:"groupInfo,omitempty"`
// 特征相关参数
FeatureID string `json:"featureId,omitempty"`
FeatureInfo string `json:"featureInfo,omitempty"`
DstFeatureID string `json:"dstFeatureId,omitempty"`
// 查询参数
TopK int `json:"topK,omitempty"`
// 更新参数
Cover bool `json:"cover,omitempty"`
// 响应格式配置
CreateGroupRes *ResponseFormat `json:"createGroupRes,omitempty"`
CreateFeatureRes *ResponseFormat `json:"createFeatureRes,omitempty"`
UpdateFeatureRes *ResponseFormat `json:"updateFeatureRes,omitempty"`
QueryFeatureListRes *ResponseFormat `json:"queryFeatureListRes,omitempty"`
SearchScoreFeaRes *ResponseFormat `json:"searchScoreFeaRes,omitempty"`
SearchFeaRes *ResponseFormat `json:"searchFeaRes,omitempty"`
DeleteFeatureRes *ResponseFormat `json:"deleteFeatureRes,omitempty"`
DeleteGroupRes *ResponseFormat `json:"deleteGroupRes,omitempty"`
}
XunfeiServiceParam 讯飞服务参数