Documentation ¶
Index ¶
- type AcquireBuilderTokenRequest
- type AcquireBuilderTokenResponse
- type AgpraRTTResponse
- type CaptionConfig
- type ClientStartRTTRequest
- type Language
- type RTCConfig
- type RTTService
- func (s *RTTService) AddTimestamp(response Timestampable) (json.RawMessage, error)
- func (s *RTTService) Contains(list *[]string, item string) bool
- func (s *RTTService) GenerateUID() string
- func (s *RTTService) HandleAcquireBuilderTokenReq(acquireReq AcquireBuilderTokenRequest) (json.RawMessage, string, error)
- func (s *RTTService) HandleQueryReq(taskId string, builderToken string) (json.RawMessage, error)
- func (s *RTTService) HandleStartReq(startRttRequest StartRTTRequest, builderToken string) (json.RawMessage, error)
- func (s *RTTService) HandleStopReq(taskId string, builderToken string) (json.RawMessage, error)
- func (s *RTTService) QueryRTT(c *gin.Context)
- func (s *RTTService) RegisterRoutes(r *gin.Engine)
- func (s *RTTService) StartRTT(c *gin.Context)
- func (s *RTTService) StopRTT(c *gin.Context)
- func (s *RTTService) ValidateAndSetDefaults(clientStartReq *ClientStartRTTRequest)
- type StartRTTRequest
- type StopRTTResponse
- type Timestampable
- type TranslateConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcquireBuilderTokenRequest ¶
type AcquireBuilderTokenRequest struct {
InstanceId string `json:"instanceId"`
}
AcquireBuilderTokenRequest defines the structure for a request to acquire a builder token for real time transcription It includes the instance ID set by the developer. Best practice is to use the channel name.
type AcquireBuilderTokenResponse ¶
type AcquireBuilderTokenResponse struct { TokenName string `json:"tokenName"` // The value of the dynamic key builderToken CreateTs int `json:"createTs"` // The Unix timestamp (seconds) when the builderToken was generated. InstanceId string `json:"instanceId"` // The instance ID set in the request body. Timestamp *string `json:"timestamp,omitempty"` // Optional timestamp for when the recording was started. }
StartRTTResponse represents the response received from the Agora server after successfully starting a recording. It includes the identifiers of the recording session along with an optional timestamp.
func (*AcquireBuilderTokenResponse) SetTimestamp ¶
func (s *AcquireBuilderTokenResponse) SetTimestamp(timestamp string)
type AgpraRTTResponse ¶
type AgpraRTTResponse struct { CreateTs int `json:"createTs"` // The Unix timestamp (seconds) when the builderToken was generated. Status string `json:"status"` // The channel name for the recording session. TaskId string `json:"taskId"` // a UUID (Universal Unique Identifier) generated by the Agora server to identify the real-time transcription task that has been created. Timestamp *string `json:"timestamp,omitempty"` // Optional timestamp for when the recording was started. }
AgpraRTTResponse represents the response received from the Agora server after successfully starting a recording. It includes the identifiers of the recording session along with an optional timestamp.
func (*AgpraRTTResponse) SetTimestamp ¶
func (s *AgpraRTTResponse) SetTimestamp(timestamp string)
type CaptionConfig ¶
type CaptionConfig struct {
Storage cloud_recording_service.StorageConfig `json:"storage"`
}
type ClientStartRTTRequest ¶
type ClientStartRTTRequest struct { ChannelName string `json:"channelName"` // The name of the channel to transcribe Languages []string `json:"languages"` // The language(s) to transcribe SubscribeAudioUIDs []string `json:"subscribeAudioUids"` // A list of UID's to subscribe to in the channel. Max 3 CryptionMode *string `json:"cryptionMode,omitempty"` // Cryption mode (Optional, if need cryption for audio and caption text) Secret *string `json:"secret,omitempty"` // Cryption secret (Optional, if need decryption for audio and caption text) Salt *string `json:"salt,omitempty"` // Cryption salt (Optional, if need decryption for audio and caption text)forceTranslateInterval.languages MaxIdleTime *int `json:"maxIdleTime,omitempty"` // The default is 30 seconds. The unit is seconds, Range 5 seconds - 2592000 seconds (30 days) TranslateConfig *TranslateConfig `json:"translateConfig,omitempty"` EnableStorage *bool `json:"enableStorage,omitempty"` // Use to enable storage of captions EnableNTPtimestamp *bool `json:"enableNTPtimestamp,omitempty"` // Use to enable subtitle sync }
ClientStartRTTRequest represents the JSON payload structure sent by the client to start real time transcription. It includes the instance ID ,
type RTCConfig ¶
type RTCConfig struct { ChannelName string `json:"channelName"` // The name of the channel to transcribe SubBotUID string `json:"subBotUid"` // The Uid used by the audio streaming bot to join the channel. SubBotToken *string `json:"subBotToken"` // RTC token for the audio streaming bot PubBotUID string `json:"pubBotUid"` // The uid used for Data streaming bot, used to stream text content after conversion. PubBotToken *string `json:"pubBotToken"` // RTC token for the audio streaming bot SubscribeAudioUIDs []string `json:"subscribeAudioUids"` // A list of UID's to subscribe to in the channel. Max 3 CryptionMode *string `json:"cryptionMode,omitempty"` // Cryption mode (Optional, if need cryption for audio and caption text) Secret *string `json:"secret,omitempty"` // Cryption secret (Optional, if need decryption for audio and caption text) Salt *string `json:"salt,omitempty"` // Cryption salt (Optional, if need decryption for audio and caption text)forceTranslateInterval.languages }
type RTTService ¶
type RTTService struct {
// contains filtered or unexported fields
}
RTTService struct holds all the necessary configurations and dependencies required for managing real-time transcription services.
func NewRTTService ¶
func NewRTTService(appID string, baseURL string, basicAuth string, tokenService *token_service.TokenService, storageConfig cloud_recording_service.StorageConfig) *RTTService
NewRTTService initializes a new instance of RTTService with the provided configurations. It seeds the random number generator to ensure varied operational behavior.
Parameters:
- appID: The Agora application ID.
- baseURL: Base URL for the API interactions.
- basicAuth: Basic authentication credentials for the API.
- tokenService: Token service instance for generating tokens.
- storageConfig: Storage configuration detailing file and directory naming conventions.
Returns:
- A pointer to the newly created RTTService.
func (*RTTService) AddTimestamp ¶
func (s *RTTService) AddTimestamp(response Timestampable) (json.RawMessage, error)
AddTimestamp adds a current timestamp to any response object that supports the Timestampable interface. It then marshals the updated object back into JSON format for further use or storage.
func (*RTTService) Contains ¶
func (s *RTTService) Contains(list *[]string, item string) bool
Contains checks if a specific string is present within a slice of strings. This is useful for determining if a particular item exists within a list.
func (*RTTService) GenerateUID ¶
func (s *RTTService) GenerateUID() string
generateUID generates a unique user identifier for use within cloud recording sessions. This function ensures the UID is never zero, which is reserved, by generating a random number between 1 and the maximum possible 32-bit integer value.
func (*RTTService) HandleAcquireBuilderTokenReq ¶
func (s *RTTService) HandleAcquireBuilderTokenReq(acquireReq AcquireBuilderTokenRequest) (json.RawMessage, string, error)
HandleAcquireBuilderTokenReq constructs a URL, marshals the request payload, sends it to the Agora cloud recording API, and processes the response to acquire a resource for cloud recording.
Parameters:
- acquireReq: AcquireResourceRequest - The structured data containing the details necessary for acquiring a resource.
Returns:
- string: A unique identifier (resource ID) for the acquired resource from the Agora cloud recording API.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Converts the acquireReq object into JSON format for the API request.
- Constructs the URL for sending the acquisition request to the Agora cloud recording API.
- Utilizes makeRequest to perform the POST operation with the constructed URL and marshaled data.
- Interprets the API's JSON response to extract the resource ID if the operation succeeds.
Notes:
- Assumes the availability of s.baseURL for constructing the request URL.
func (*RTTService) HandleQueryReq ¶
func (s *RTTService) HandleQueryReq(taskId string, builderToken string) (json.RawMessage, error)
HandleAcquireResourceReq constructs a URL, marshals the request payload, sends it to the Agora cloud recording API, and processes the response to acquire a resource for cloud recording.
Parameters:
- acquireReq: AcquireResourceRequest - The structured data containing the details necessary for acquiring a resource.
Returns:
- string: A unique identifier (resource ID) for the acquired resource from the Agora cloud recording API.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Converts the acquireReq object into JSON format for the API request.
- Constructs the URL for sending the acquisition request to the Agora cloud recording API.
- Utilizes makeRequest to perform the POST operation with the constructed URL and marshaled data.
- Interprets the API's JSON response to extract the resource ID if the operation succeeds.
Notes:
- Assumes the availability of s.baseURL for constructing the request URL.
func (*RTTService) HandleStartReq ¶
func (s *RTTService) HandleStartReq(startRttRequest StartRTTRequest, builderToken string) (json.RawMessage, error)
HandleAcquireResourceReq constructs a URL, marshals the request payload, sends it to the Agora cloud recording API, and processes the response to acquire a resource for cloud recording.
Parameters:
- acquireReq: AcquireResourceRequest - The structured data containing the details necessary for acquiring a resource.
Returns:
- string: A unique identifier (resource ID) for the acquired resource from the Agora cloud recording API.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Converts the acquireReq object into JSON format for the API request.
- Constructs the URL for sending the acquisition request to the Agora cloud recording API.
- Utilizes makeRequest to perform the POST operation with the constructed URL and marshaled data.
- Interprets the API's JSON response to extract the resource ID if the operation succeeds.
Notes:
- Assumes the availability of s.baseURL for constructing the request URL.
func (*RTTService) HandleStopReq ¶
func (s *RTTService) HandleStopReq(taskId string, builderToken string) (json.RawMessage, error)
HandleAcquireResourceReq constructs a URL, marshals the request payload, sends it to the Agora cloud recording API, and processes the response to acquire a resource for cloud recording.
Parameters:
- acquireReq: AcquireResourceRequest - The structured data containing the details necessary for acquiring a resource.
Returns:
- string: A unique identifier (resource ID) for the acquired resource from the Agora cloud recording API.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Converts the acquireReq object into JSON format for the API request.
- Constructs the URL for sending the acquisition request to the Agora cloud recording API.
- Utilizes makeRequest to perform the POST operation with the constructed URL and marshaled data.
- Interprets the API's JSON response to extract the resource ID if the operation succeeds.
Notes:
- Assumes the availability of s.baseURL for constructing the request URL.
func (*RTTService) QueryRTT ¶
func (s *RTTService) QueryRTT(c *gin.Context)
func (*RTTService) RegisterRoutes ¶
func (s *RTTService) RegisterRoutes(r *gin.Engine)
RegisterRoutes sets up the API endpoints related to the real-time transcription service. It creates a route group and registers individual routes for starting, stopping, and querying the transcription status.
Parameters:
- r: *gin.Engine - Gin engine instance to register routes.
func (*RTTService) StartRTT ¶
func (s *RTTService) StartRTT(c *gin.Context)
StartRTT handles the starting of the real-time transcription by binding JSON data from client requests, validating and setting default values, acquiring necessary tokens, and making the start request.
Parameters:
- c: *gin.Context - Context instance containing HTTP request and response objects.
func (*RTTService) StopRTT ¶
func (s *RTTService) StopRTT(c *gin.Context)
func (*RTTService) ValidateAndSetDefaults ¶
func (s *RTTService) ValidateAndSetDefaults(clientStartReq *ClientStartRTTRequest)
type StartRTTRequest ¶
type StartRTTRequest struct { Languages []string `json:"languages"` // The language(s) to transcribe MaxIdleTime int `json:"maxIdleTime"` // If there is no audio stream in the channel for more than this time, the RTT Task will stop automatically. RTCConfig RTCConfig `json:"rtcConfig"` // The RTC settings for the audio and data bots CaptionConfig *CaptionConfig `json:"captionConfig,omitempty"` // The cloud recording configuration TranslateConfig *TranslateConfig `json:"translateConfig,omitempty"` // The settings for real-time translation }
type StopRTTResponse ¶
type StopRTTResponse struct { Status string `json:"status"` Timestamp *string `json:"timestamp,omitempty"` // Optional timestamp for when the recording was started. }
StopRTTResponse represents the response received from the Agora server after successfully starting a recording. It includes the identifiers of the recording session along with an optional timestamp.
func (*StopRTTResponse) SetTimestamp ¶
func (s *StopRTTResponse) SetTimestamp(timestamp string)
type Timestampable ¶
type Timestampable interface {
SetTimestamp(timestamp string)
}
Timestampable is an interface that allows struct types to receive a timestamp. Implementing this interface ensures that a timestamp can be set on the object, primarily for auditing or tracking purposes.