audio

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Provider kinds
	KindQiniu  = "qiniu"
	KindQCloud = "qcloud"
	KindAliyun = "aliyun"
)
View Source
const (
	// AudioCensorEndpoint is the audio moderation API endpoint
	AudioCensorEndpoint = "/v3/audio/censor"
	// AudioJobEndpoint is the audio job query API endpoint template
	AudioJobEndpoint = "/v3/jobs/audio"
	// AudioCensorHost is the audio moderation API host
	AudioCensorHost = "ai.qiniuapi.com"
)
View Source
const (
	// Aliyun default endpoint for Green
	AliyunGreenDefaultEndpoint = "green-cip.cn-shanghai.aliyuncs.com"
)
View Source
const (
	// QCloud default region for ASR
	QCloudASRDefaultRegion = "ap-guangzhou"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AliyunAudioCensor

type AliyunAudioCensor struct {
	AccessKeyID     string
	AccessKeySecret string
	Endpoint        string
	Client          *green.Client
}

AliyunAudioCensor is the client for Alibaba Cloud audio content moderation

func NewAliyunAudioCensor

func NewAliyunAudioCensor(accessKeyID, accessKeySecret, endpoint string) (*AliyunAudioCensor, error)

NewAliyunAudioCensor creates a new Alibaba Cloud audio moderation client

func (*AliyunAudioCensor) GetCensorResult

func (c *AliyunAudioCensor) GetCensorResult(taskID string) (interface{}, error)

GetCensorResult retrieves the audio moderation result

func (*AliyunAudioCensor) SubmitCensorAudio

func (c *AliyunAudioCensor) SubmitCensorAudio(audioURL string) (string, error)

SubmitCensorAudio submits an audio moderation task

type AudioCensor

type AudioCensor interface {
	SubmitCensorAudio(audioURL string) (string, error)
	GetCensorResult(taskID string) (interface{}, error)
}

AudioCensor interface for audio content moderation

func GetAudioCensor

func GetAudioCensor(kind string, credentials ...interface{}) (AudioCensor, error)

GetAudioCensor returns an audio censor client based on the provider kind

type AudioCensorData

type AudioCensorData struct {
	URI string `json:"uri"` // Audio URL address
	ID  string `json:"id"`  // Unique identifier set by the caller, optional
}

AudioCensorData represents the audio data to be moderated

type AudioCensorJobResponse

type AudioCensorJobResponse struct {
	ID        string             `json:"id"`         // Task ID
	Status    string             `json:"status"`     // Task status: WAITING/DOING/FINISHED/FAILED
	Request   json.RawMessage    `json:"request"`    // Request body from audio moderation request
	Response  *AudioCensorResult `json:"response"`   // Audio content moderation result
	Error     string             `json:"error"`      // Task error information
	CreatedAt string             `json:"created_at"` // Task creation time
	UpdatedAt string             `json:"updated_at"` // Task update time
}

AudioCensorJobResponse represents the audio moderation task status response

type AudioCensorParams

type AudioCensorParams struct {
	Scenes   []string `json:"scenes"`              // Moderation type, required field, currently only option: antispam
	HookURL  string   `json:"hook_url,omitempty"`  // Callback address after audio detection completes, optional
	HookAuth bool     `json:"hook_auth,omitempty"` // true/false, default is false, adds authorization header to callback request
}

AudioCensorParams represents moderation parameters

type AudioCensorRequest

type AudioCensorRequest struct {
	Data   AudioCensorData   `json:"data"`
	Params AudioCensorParams `json:"params"`
}

AudioCensorRequest represents the request parameters for audio moderation

type AudioCensorResult

type AudioCensorResult struct {
	Code      int                      `json:"code"`       // Processing status: 200 means success
	Message   string                   `json:"message"`    // Status description
	AudioText string                   `json:"audio_text"` // Audio text
	Result    *AudioCensorResultDetail `json:"result"`     // Moderation result details
}

AudioCensorResult represents the audio moderation result

type AudioCensorResultDetail

type AudioCensorResultDetail struct {
	Suggestion string                      `json:"suggestion"` // pass (approved), review (needs manual review), block (violation)
	Scenes     map[string]AudioSceneResult `json:"scenes"`     // Moderation results for each scene
}

AudioCensorResultDetail represents detailed moderation result

type AudioCensorSubmitResponse

type AudioCensorSubmitResponse struct {
	ID string `json:"id"` // Server-returned unique identifier for the audio moderation task
}

AudioCensorSubmitResponse represents the response for submitting an audio moderation task

type AudioCutDetail

type AudioCutDetail struct {
	Suggestion string  `json:"suggestion"` // Detailed suggestion: pass/review/block
	Label      string  `json:"label"`      // Moderation label: normal, politics, porn, abuse, contraband
	Score      float64 `json:"score"`      // Confidence score
}

AudioCutDetail represents detailed moderation information for an audio segment

type AudioCutResult

type AudioCutResult struct {
	Suggestion string           `json:"suggestion"` // Suggestion for this audio segment: pass/review/block
	StartTime  int              `json:"start_time"` // Start offset of this audio segment in the original audio, unit: seconds
	EndTime    int              `json:"end_time"`   // End offset of this audio segment in the original audio, unit: seconds
	AudioText  string           `json:"audio_text"` // Text of this audio segment
	Details    []AudioCutDetail `json:"details"`    // Detailed information array
}

AudioCutResult represents the moderation result for an audio segment

type AudioSceneResult

type AudioSceneResult struct {
	Suggestion string           `json:"suggestion"` // Overall suggestion for this scene: pass/review/block
	Cuts       []AudioCutResult `json:"cuts"`       // Audio segment moderation result array
}

AudioSceneResult represents the moderation result for a scene

type QCloudAudioCensor

type QCloudAudioCensor struct {
	SecretID  string
	SecretKey string
	Region    string
	Client    *asr.Client
}

QCloudAudioCensor is the client for Tencent Cloud audio content moderation

func NewQCloudAudioCensor

func NewQCloudAudioCensor(secretID, secretKey, region string) (*QCloudAudioCensor, error)

NewQCloudAudioCensor creates a new Tencent Cloud audio moderation client

func (*QCloudAudioCensor) GetCensorResult

func (c *QCloudAudioCensor) GetCensorResult(taskID string) (interface{}, error)

GetCensorResult retrieves the audio moderation result

func (*QCloudAudioCensor) SubmitCensorAudio

func (c *QCloudAudioCensor) SubmitCensorAudio(audioURL string) (string, error)

SubmitCensorAudio submits an audio moderation task

type QiniuAudioCensor

type QiniuAudioCensor struct {
	AccessKey string
	SecretKey string
	Host      string
	Client    *http.Client
}

QiniuAudioCensor is the client for audio content moderation

func NewQiniuAudioCensor

func NewQiniuAudioCensor(accessKey, secretKey string) *QiniuAudioCensor

NewQiniuAudioCensor creates a new audio moderation client

func (*QiniuAudioCensor) GetCensorResult

func (c *QiniuAudioCensor) GetCensorResult(taskID string) (interface{}, error)

GetCensorResult retrieves the audio moderation result This method implements the AudioCensor interface

func (*QiniuAudioCensor) GetCensorResultFull

func (c *QiniuAudioCensor) GetCensorResultFull(taskID string) (*AudioCensorJobResponse, error)

GetCensorResultFull retrieves the audio moderation result with full details

func (*QiniuAudioCensor) SubmitCensor

SubmitCensor submits an audio moderation task

func (*QiniuAudioCensor) SubmitCensorAudio

func (c *QiniuAudioCensor) SubmitCensorAudio(audioURL string) (string, error)

SubmitCensorAudio submits an audio moderation task with just the audio URL This method implements the AudioCensor interface

func (*QiniuAudioCensor) SubmitCensorAudioFull

func (c *QiniuAudioCensor) SubmitCensorAudioFull(uri, audioID string, scenes []string, hookURL string) (*AudioCensorSubmitResponse, error)

SubmitCensorAudioFull is a full-featured method to submit an audio moderation task uri: audio URI audioID: unique identifier for the audio (optional) scenes: moderation scene list, e.g., []string{"antispam"} hookURL: callback address (optional)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL