12
12
13
13
14
14
class VoiceEnrollmentException (Exception ):
15
- def __init__ (self , status_code : int , code : str ,
15
+ def __init__ (self , request_id : str , status_code : int , code : str ,
16
16
error_message : str ) -> None :
17
+ self ._request_id = request_id
17
18
self ._status_code = status_code
18
19
self ._code = code
19
20
self ._error_message = error_message
20
21
21
22
def __str__ (self ):
22
- return f'Status Code: { self ._status_code } , Code: { self ._code } , Error Message: { self ._error_message } '
23
+ return f'Request: { self . _request_id } , Status Code: { self ._status_code } , Code: { self ._code } , Error Message: { self ._error_message } '
23
24
24
25
25
26
class VoiceEnrollmentService (BaseApi ):
@@ -81,11 +82,11 @@ def create_voice(self, target_model: str, prefix: str, url: str) -> str:
81
82
'prefix' : prefix ,
82
83
'url' : url ,
83
84
}, )
85
+ self ._last_request_id = response .request_id
84
86
if response .status_code == 200 :
85
- self ._last_request_id = response .request_id
86
87
return response .output ['voice_id' ]
87
88
else :
88
- raise VoiceEnrollmentException (response .status_code , response .code ,
89
+ raise VoiceEnrollmentException (response .request_id , response . status_code , response .code ,
89
90
response .message )
90
91
91
92
def list_voices (self ,
@@ -111,11 +112,11 @@ def list_voices(self,
111
112
'page_index' : page_index ,
112
113
'page_size' : page_size ,
113
114
}, )
115
+ self ._last_request_id = response .request_id
114
116
if response .status_code == 200 :
115
- self ._last_request_id = response .request_id
116
117
return response .output ['voice_list' ]
117
118
else :
118
- raise VoiceEnrollmentException (response .status_code , response .code ,
119
+ raise VoiceEnrollmentException (response .request_id , response . status_code , response .code ,
119
120
response .message )
120
121
121
122
def query_voice (self , voice_id : str ) -> List [str ]:
@@ -128,11 +129,11 @@ def query_voice(self, voice_id: str) -> List[str]:
128
129
'action' : 'query_voice' ,
129
130
'voice_id' : voice_id ,
130
131
}, )
132
+ self ._last_request_id = response .request_id
131
133
if response .status_code == 200 :
132
- self ._last_request_id = response .request_id
133
134
return response .output
134
135
else :
135
- raise VoiceEnrollmentException (response .status_code , response .code ,
136
+ raise VoiceEnrollmentException (response .request_id , response . status_code , response .code ,
136
137
response .message )
137
138
138
139
def update_voice (self , voice_id : str , url : str ) -> None :
@@ -146,11 +147,11 @@ def update_voice(self, voice_id: str, url: str) -> None:
146
147
'voice_id' : voice_id ,
147
148
'url' : url ,
148
149
}, )
150
+ self ._last_request_id = response .request_id
149
151
if response .status_code == 200 :
150
- self ._last_request_id = response .request_id
151
152
return
152
153
else :
153
- raise VoiceEnrollmentException (response .status_code , response .code ,
154
+ raise VoiceEnrollmentException (response .request_id , response . status_code , response .code ,
154
155
response .message )
155
156
156
157
def delete_voice (self , voice_id : str ) -> None :
@@ -162,11 +163,11 @@ def delete_voice(self, voice_id: str) -> None:
162
163
'action' : 'delete_voice' ,
163
164
'voice_id' : voice_id ,
164
165
}, )
166
+ self ._last_request_id = response .request_id
165
167
if response .status_code == 200 :
166
- self ._last_request_id = response .request_id
167
168
return
168
169
else :
169
- raise VoiceEnrollmentException (response .status_code , response .code ,
170
+ raise VoiceEnrollmentException (response .request_id , response . status_code , response .code ,
170
171
response .message )
171
172
172
173
def get_last_request_id (self ):
0 commit comments