2
2
3
3
from cozepy .model import CozeModel
4
4
from cozepy .request import Requester
5
- from cozepy .util import remove_url_trailing_slash
5
+ from cozepy .util import remove_none_values , remove_url_trailing_slash
6
+
7
+
8
+ class RoomAudioConfig (CozeModel ):
9
+ # 房间音频编码格式,支持设置为:
10
+ # AACLC: AAC-LC 编码格式。
11
+ # G711A: G711A 编码格式。
12
+ # OPUS: (默认)Opus 编码格式。
13
+ # G722: G.722 编码格式。
14
+ codec : Optional [str ]
15
+
16
+
17
+ class RoomVideoConfig (CozeModel ):
18
+ # 房间视频编码格式,支持设置为:
19
+ # H264:(默认)H264 编码格式。
20
+ # BYTEVC1: 火山引擎自研的视频编码格式。
21
+ codec : Optional [str ]
22
+ # 房间视频流类型, 支持 main 和 screen。
23
+ # main: 主流,包括通过摄像头/麦克风的内部采集机制获取的流,以及通过自定义采集方式获取的流。
24
+ # screen: 屏幕流,用于屏幕共享或屏幕录制的视频流。
25
+ stream_video_type : Optional [str ]
26
+
27
+
28
+ class RoomConfig (CozeModel ):
29
+ # The audio config of the room.
30
+ audio_config : Optional [RoomAudioConfig ]
31
+ # The video config of the room.
32
+ video_config : Optional [RoomVideoConfig ]
33
+ # 自定义开场白
34
+ prologue_content : Optional [str ]
6
35
7
36
8
37
class CreateRoomResp (CozeModel ):
@@ -32,6 +61,8 @@ def create(
32
61
voice_id : Optional [str ] = None ,
33
62
conversation_id : Optional [str ] = None ,
34
63
uid : Optional [str ] = None ,
64
+ workflow_id : Optional [str ] = None ,
65
+ config : Optional [RoomConfig ] = None ,
35
66
) -> CreateRoomResp :
36
67
"""
37
68
create rtc room
@@ -40,15 +71,21 @@ def create(
40
71
:param voice_id: The voice id of the voice.
41
72
:param conversation_id: The id of the conversation.
42
73
:param uid: The id of the user. if not provided, it will be generated by the server.
74
+ :param workflow_id: The id of the workflow.
75
+ :param config: The config of the room.
43
76
:return: create room result
44
77
"""
45
78
url = f"{ self ._base_url } /v1/audio/rooms"
46
- body = {
47
- "bot_id" : bot_id ,
48
- "voice_id" : voice_id ,
49
- "conversation_id" : conversation_id ,
50
- "uid" : uid ,
51
- }
79
+ body = remove_none_values (
80
+ {
81
+ "bot_id" : bot_id ,
82
+ "voice_id" : voice_id ,
83
+ "conversation_id" : conversation_id ,
84
+ "uid" : uid ,
85
+ "workflow_id" : workflow_id ,
86
+ "config" : config .model_dump () if config else None ,
87
+ }
88
+ )
52
89
return self ._requester .request ("post" , url , stream = False , cast = CreateRoomResp , body = body )
53
90
54
91
@@ -68,6 +105,8 @@ async def create(
68
105
voice_id : Optional [str ] = None ,
69
106
conversation_id : Optional [str ] = None ,
70
107
uid : Optional [str ] = None ,
108
+ workflow_id : Optional [str ] = None ,
109
+ config : Optional [RoomConfig ] = None ,
71
110
) -> CreateRoomResp :
72
111
"""
73
112
create rtc room
@@ -76,13 +115,19 @@ async def create(
76
115
:param voice_id: The voice id of the voice.
77
116
:param conversation_id: The id of the conversation.
78
117
:param uid: The id of the user. if not provided, it will be generated by the server.
118
+ :param workflow_id: The id of the workflow.
119
+ :param config: The config of the room.
79
120
:return: create room result
80
121
"""
81
122
url = f"{ self ._base_url } /v1/audio/rooms"
82
- body = {
83
- "bot_id" : bot_id ,
84
- "voice_id" : voice_id ,
85
- "conversation_id" : conversation_id ,
86
- "uid" : uid ,
87
- }
123
+ body = remove_none_values (
124
+ {
125
+ "bot_id" : bot_id ,
126
+ "voice_id" : voice_id ,
127
+ "conversation_id" : conversation_id ,
128
+ "uid" : uid ,
129
+ "workflow_id" : workflow_id ,
130
+ "config" : config .model_dump () if config else None ,
131
+ }
132
+ )
88
133
return await self ._requester .arequest ("post" , url , stream = False , cast = CreateRoomResp , body = body )
0 commit comments