-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaudio_rooms.go
69 lines (58 loc) · 1.75 KB
/
audio_rooms.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package coze
import (
"context"
"net/http"
)
func (r *audioRooms) Create(ctx context.Context, req *CreateAudioRoomsReq) (*CreateAudioRoomsResp, error) {
method := http.MethodPost
uri := "/v1/audio/rooms"
resp := &createAudioRoomsResp{}
if err := r.core.Request(ctx, method, uri, req, resp); err != nil {
return nil, err
}
resp.Data.setHTTPResponse(resp.HTTPResponse)
return resp.Data, nil
}
type audioRooms struct {
core *core
}
func newRooms(core *core) *audioRooms {
return &audioRooms{core: core}
}
// AudioCodec represents the audio codec
type AudioCodec string
const (
AudioCodecAACLC AudioCodec = "AACLC"
AudioCodecG711A AudioCodec = "G711A"
AudioCodecOPUS AudioCodec = "OPUS"
AudioCodecG722 AudioCodec = "G722"
)
// CreateAudioRoomsReq represents the request for creating an audio room
type CreateAudioRoomsReq struct {
BotID string `json:"bot_id"`
ConversationID string `json:"conversation_id,omitempty"`
VoiceID string `json:"voice_id,omitempty"`
UID string `json:"uid,omitempty"`
Config *RoomConfig `json:"config,omitempty"`
}
// RoomConfig represents the room configuration
type RoomConfig struct {
AudioConfig *RoomAudioConfig `json:"audio_config"`
}
// RoomAudioConfig represents the room audio configuration
type RoomAudioConfig struct {
Codec AudioCodec `json:"codec"`
}
// createAudioRoomsResp represents the response for creating an audio room
type createAudioRoomsResp struct {
baseResponse
Data *CreateAudioRoomsResp `json:"data"`
}
// CreateAudioRoomsResp represents the response for creating an audio room
type CreateAudioRoomsResp struct {
baseModel
RoomID string `json:"room_id"`
AppID string `json:"app_id"`
Token string `json:"token"`
UID string `json:"uid"`
}