Skip to content

Commit cd7bf3e

Browse files
committed
fix: Fixed ElevenLabs specific bug.
1 parent e1a3e66 commit cd7bf3e

File tree

29 files changed

+147
-365
lines changed

29 files changed

+147
-365
lines changed

src/libs/AutoSDK/Models/EndPoint.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public static EndPoint FromSchema(OperationContext operation)
100100
.Select(x => EndPointResponse.FromResponse(x, operation))
101101
.ToArray();
102102
var contentType = responses
103-
.Any(x => x.MimeType.Contains("application/octet-stream"))
103+
.Any(x =>
104+
x.MimeType.Contains("application/octet-stream") ||
105+
x.MimeType.Contains("audio/mpeg"))
104106
? ContentType.ByteArray
105107
: ContentType.String;
106108

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.AudioIsolationClient.CreateAudioIsolation.g.verified.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,12 @@ partial void ProcessCreateAudioIsolationResponse(
130130

131131
if (ReadResponseAsString)
132132
{
133-
var __content = await __response.Content.ReadAsStringAsync(
133+
var __content = await __response.Content.ReadAsByteArrayAsync(
134134
#if NET5_0_OR_GREATER
135135
cancellationToken
136136
#endif
137137
).ConfigureAwait(false);
138138

139-
ProcessResponseContent(
140-
client: HttpClient,
141-
response: __response,
142-
content: ref __content);
143139

144140
try
145141
{
@@ -149,11 +145,10 @@ partial void ProcessCreateAudioIsolationResponse(
149145
catch (global::System.Exception __ex)
150146
{
151147
throw new global::G.ApiException(
152-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
148+
message: __response.ReasonPhrase ?? string.Empty,
153149
innerException: __ex,
154150
statusCode: __response.StatusCode)
155151
{
156-
ResponseBody = __content,
157152
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
158153
__response.Headers,
159154
h => h.Key,
@@ -167,7 +162,7 @@ partial void ProcessCreateAudioIsolationResponse(
167162
{
168163
__response.EnsureSuccessStatusCode();
169164

170-
using var __content = await __response.Content.ReadAsStreamAsync(
165+
var __content = await __response.Content.ReadAsByteArrayAsync(
171166
#if NET5_0_OR_GREATER
172167
cancellationToken
173168
#endif

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.AudioIsolationClient.CreateAudioIsolationStream.g.verified.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,12 @@ partial void ProcessCreateAudioIsolationStreamResponse(
130130

131131
if (ReadResponseAsString)
132132
{
133-
var __content = await __response.Content.ReadAsStringAsync(
133+
var __content = await __response.Content.ReadAsByteArrayAsync(
134134
#if NET5_0_OR_GREATER
135135
cancellationToken
136136
#endif
137137
).ConfigureAwait(false);
138138

139-
ProcessResponseContent(
140-
client: HttpClient,
141-
response: __response,
142-
content: ref __content);
143139

144140
try
145141
{
@@ -149,11 +145,10 @@ partial void ProcessCreateAudioIsolationStreamResponse(
149145
catch (global::System.Exception __ex)
150146
{
151147
throw new global::G.ApiException(
152-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
148+
message: __response.ReasonPhrase ?? string.Empty,
153149
innerException: __ex,
154150
statusCode: __response.StatusCode)
155151
{
156-
ResponseBody = __content,
157152
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
158153
__response.Headers,
159154
h => h.Key,
@@ -167,7 +162,7 @@ partial void ProcessCreateAudioIsolationStreamResponse(
167162
{
168163
__response.EnsureSuccessStatusCode();
169164

170-
using var __content = await __response.Content.ReadAsStreamAsync(
165+
var __content = await __response.Content.ReadAsByteArrayAsync(
171166
#if NET5_0_OR_GREATER
172167
cancellationToken
173168
#endif

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.ConversationalAIClient.GetConvaiConversationsByConversationIdAudio.g.verified.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,12 @@ partial void ProcessGetConvaiConversationsByConversationIdAudioResponse(
113113

114114
if (ReadResponseAsString)
115115
{
116-
var __content = await __response.Content.ReadAsStringAsync(
116+
var __content = await __response.Content.ReadAsByteArrayAsync(
117117
#if NET5_0_OR_GREATER
118118
cancellationToken
119119
#endif
120120
).ConfigureAwait(false);
121121

122-
ProcessResponseContent(
123-
client: HttpClient,
124-
response: __response,
125-
content: ref __content);
126122

127123
try
128124
{
@@ -132,11 +128,10 @@ partial void ProcessGetConvaiConversationsByConversationIdAudioResponse(
132128
catch (global::System.Exception __ex)
133129
{
134130
throw new global::G.ApiException(
135-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
131+
message: __response.ReasonPhrase ?? string.Empty,
136132
innerException: __ex,
137133
statusCode: __response.StatusCode)
138134
{
139-
ResponseBody = __content,
140135
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
141136
__response.Headers,
142137
h => h.Key,
@@ -150,7 +145,7 @@ partial void ProcessGetConvaiConversationsByConversationIdAudioResponse(
150145
{
151146
__response.EnsureSuccessStatusCode();
152147

153-
using var __content = await __response.Content.ReadAsStreamAsync(
148+
var __content = await __response.Content.ReadAsByteArrayAsync(
154149
#if NET5_0_OR_GREATER
155150
cancellationToken
156151
#endif

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.DubbingClient.GetDubbingByDubbingIdAudioByLanguageCode.g.verified.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ partial void ProcessGetDubbingByDubbingIdAudioByLanguageCodeResponse(
2424
partial void ProcessGetDubbingByDubbingIdAudioByLanguageCodeResponseContent(
2525
global::System.Net.Http.HttpClient httpClient,
2626
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
27-
ref string content);
27+
ref byte[] content);
2828

2929
/// <summary>
3030
/// Get Dubbed File<br/>
@@ -197,16 +197,12 @@ partial void ProcessGetDubbingByDubbingIdAudioByLanguageCodeResponseContent(
197197

198198
if (ReadResponseAsString)
199199
{
200-
var __content = await __response.Content.ReadAsStringAsync(
200+
var __content = await __response.Content.ReadAsByteArrayAsync(
201201
#if NET5_0_OR_GREATER
202202
cancellationToken
203203
#endif
204204
).ConfigureAwait(false);
205205

206-
ProcessResponseContent(
207-
client: HttpClient,
208-
response: __response,
209-
content: ref __content);
210206
ProcessGetDubbingByDubbingIdAudioByLanguageCodeResponseContent(
211207
httpClient: HttpClient,
212208
httpResponseMessage: __response,
@@ -216,18 +212,15 @@ partial void ProcessGetDubbingByDubbingIdAudioByLanguageCodeResponseContent(
216212
{
217213
__response.EnsureSuccessStatusCode();
218214

219-
return
220-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]?>(__content, JsonSerializerOptions) ??
221-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
215+
return __content;
222216
}
223217
catch (global::System.Exception __ex)
224218
{
225219
throw new global::G.ApiException(
226-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
220+
message: __response.ReasonPhrase ?? string.Empty,
227221
innerException: __ex,
228222
statusCode: __response.StatusCode)
229223
{
230-
ResponseBody = __content,
231224
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
232225
__response.Headers,
233226
h => h.Key,
@@ -241,15 +234,13 @@ partial void ProcessGetDubbingByDubbingIdAudioByLanguageCodeResponseContent(
241234
{
242235
__response.EnsureSuccessStatusCode();
243236

244-
using var __content = await __response.Content.ReadAsStreamAsync(
237+
var __content = await __response.Content.ReadAsByteArrayAsync(
245238
#if NET5_0_OR_GREATER
246239
cancellationToken
247240
#endif
248241
).ConfigureAwait(false);
249242

250-
return
251-
global::Newtonsoft.Json.JsonSerializer.Create(JsonSerializerOptions).Deserialize<byte[]?>(new global::Newtonsoft.Json.JsonTextReader(new global::System.IO.StreamReader(__content))) ??
252-
throw new global::System.InvalidOperationException("Response deserialization failed.");
243+
return __content;
253244
}
254245
catch (global::System.Exception __ex)
255246
{

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.SoundGenerationClient.CreateSoundGeneration.g.verified.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ partial void ProcessCreateSoundGenerationResponse(
2424
partial void ProcessCreateSoundGenerationResponseContent(
2525
global::System.Net.Http.HttpClient httpClient,
2626
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
27-
ref string content);
27+
ref byte[] content);
2828

2929
/// <summary>
3030
/// Sound Generation<br/>
@@ -158,16 +158,12 @@ partial void ProcessCreateSoundGenerationResponseContent(
158158

159159
if (ReadResponseAsString)
160160
{
161-
var __content = await __response.Content.ReadAsStringAsync(
161+
var __content = await __response.Content.ReadAsByteArrayAsync(
162162
#if NET5_0_OR_GREATER
163163
cancellationToken
164164
#endif
165165
).ConfigureAwait(false);
166166

167-
ProcessResponseContent(
168-
client: HttpClient,
169-
response: __response,
170-
content: ref __content);
171167
ProcessCreateSoundGenerationResponseContent(
172168
httpClient: HttpClient,
173169
httpResponseMessage: __response,
@@ -177,18 +173,15 @@ partial void ProcessCreateSoundGenerationResponseContent(
177173
{
178174
__response.EnsureSuccessStatusCode();
179175

180-
return
181-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]?>(__content, JsonSerializerOptions) ??
182-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
176+
return __content;
183177
}
184178
catch (global::System.Exception __ex)
185179
{
186180
throw new global::G.ApiException(
187-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
181+
message: __response.ReasonPhrase ?? string.Empty,
188182
innerException: __ex,
189183
statusCode: __response.StatusCode)
190184
{
191-
ResponseBody = __content,
192185
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
193186
__response.Headers,
194187
h => h.Key,
@@ -202,15 +195,13 @@ partial void ProcessCreateSoundGenerationResponseContent(
202195
{
203196
__response.EnsureSuccessStatusCode();
204197

205-
using var __content = await __response.Content.ReadAsStreamAsync(
198+
var __content = await __response.Content.ReadAsByteArrayAsync(
206199
#if NET5_0_OR_GREATER
207200
cancellationToken
208201
#endif
209202
).ConfigureAwait(false);
210203

211-
return
212-
global::Newtonsoft.Json.JsonSerializer.Create(JsonSerializerOptions).Deserialize<byte[]?>(new global::Newtonsoft.Json.JsonTextReader(new global::System.IO.StreamReader(__content))) ??
213-
throw new global::System.InvalidOperationException("Response deserialization failed.");
204+
return __content;
214205
}
215206
catch (global::System.Exception __ex)
216207
{

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.SpeechHistoryClient.GetHistoryByHistoryItemIdAudio.g.verified.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ partial void ProcessGetHistoryByHistoryItemIdAudioResponse(
2222
partial void ProcessGetHistoryByHistoryItemIdAudioResponseContent(
2323
global::System.Net.Http.HttpClient httpClient,
2424
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
25-
ref string content);
25+
ref byte[] content);
2626

2727
/// <summary>
2828
/// Get Audio From History Item<br/>
@@ -118,16 +118,12 @@ partial void ProcessGetHistoryByHistoryItemIdAudioResponseContent(
118118

119119
if (ReadResponseAsString)
120120
{
121-
var __content = await __response.Content.ReadAsStringAsync(
121+
var __content = await __response.Content.ReadAsByteArrayAsync(
122122
#if NET5_0_OR_GREATER
123123
cancellationToken
124124
#endif
125125
).ConfigureAwait(false);
126126

127-
ProcessResponseContent(
128-
client: HttpClient,
129-
response: __response,
130-
content: ref __content);
131127
ProcessGetHistoryByHistoryItemIdAudioResponseContent(
132128
httpClient: HttpClient,
133129
httpResponseMessage: __response,
@@ -137,18 +133,15 @@ partial void ProcessGetHistoryByHistoryItemIdAudioResponseContent(
137133
{
138134
__response.EnsureSuccessStatusCode();
139135

140-
return
141-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]?>(__content, JsonSerializerOptions) ??
142-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
136+
return __content;
143137
}
144138
catch (global::System.Exception __ex)
145139
{
146140
throw new global::G.ApiException(
147-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
141+
message: __response.ReasonPhrase ?? string.Empty,
148142
innerException: __ex,
149143
statusCode: __response.StatusCode)
150144
{
151-
ResponseBody = __content,
152145
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
153146
__response.Headers,
154147
h => h.Key,
@@ -162,15 +155,13 @@ partial void ProcessGetHistoryByHistoryItemIdAudioResponseContent(
162155
{
163156
__response.EnsureSuccessStatusCode();
164157

165-
using var __content = await __response.Content.ReadAsStreamAsync(
158+
var __content = await __response.Content.ReadAsByteArrayAsync(
166159
#if NET5_0_OR_GREATER
167160
cancellationToken
168161
#endif
169162
).ConfigureAwait(false);
170163

171-
return
172-
global::Newtonsoft.Json.JsonSerializer.Create(JsonSerializerOptions).Deserialize<byte[]?>(new global::Newtonsoft.Json.JsonTextReader(new global::System.IO.StreamReader(__content))) ??
173-
throw new global::System.InvalidOperationException("Response deserialization failed.");
164+
return __content;
174165
}
175166
catch (global::System.Exception __ex)
176167
{

src/tests/AutoSDK.SnapshotTests/Snapshots/elevenlabs/NewtonsoftJson/_#G.SpeechToSpeechClient.CreateSpeechToSpeechByVoiceId.g.verified.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ partial void ProcessCreateSpeechToSpeechByVoiceIdResponse(
3232
partial void ProcessCreateSpeechToSpeechByVoiceIdResponseContent(
3333
global::System.Net.Http.HttpClient httpClient,
3434
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
35-
ref string content);
35+
ref byte[] content);
3636

3737
/// <summary>
3838
/// Speech To Speech<br/>
@@ -251,16 +251,12 @@ partial void ProcessCreateSpeechToSpeechByVoiceIdResponseContent(
251251

252252
if (ReadResponseAsString)
253253
{
254-
var __content = await __response.Content.ReadAsStringAsync(
254+
var __content = await __response.Content.ReadAsByteArrayAsync(
255255
#if NET5_0_OR_GREATER
256256
cancellationToken
257257
#endif
258258
).ConfigureAwait(false);
259259

260-
ProcessResponseContent(
261-
client: HttpClient,
262-
response: __response,
263-
content: ref __content);
264260
ProcessCreateSpeechToSpeechByVoiceIdResponseContent(
265261
httpClient: HttpClient,
266262
httpResponseMessage: __response,
@@ -270,18 +266,15 @@ partial void ProcessCreateSpeechToSpeechByVoiceIdResponseContent(
270266
{
271267
__response.EnsureSuccessStatusCode();
272268

273-
return
274-
global::Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]?>(__content, JsonSerializerOptions) ??
275-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
269+
return __content;
276270
}
277271
catch (global::System.Exception __ex)
278272
{
279273
throw new global::G.ApiException(
280-
message: __content ?? __response.ReasonPhrase ?? string.Empty,
274+
message: __response.ReasonPhrase ?? string.Empty,
281275
innerException: __ex,
282276
statusCode: __response.StatusCode)
283277
{
284-
ResponseBody = __content,
285278
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
286279
__response.Headers,
287280
h => h.Key,
@@ -295,15 +288,13 @@ partial void ProcessCreateSpeechToSpeechByVoiceIdResponseContent(
295288
{
296289
__response.EnsureSuccessStatusCode();
297290

298-
using var __content = await __response.Content.ReadAsStreamAsync(
291+
var __content = await __response.Content.ReadAsByteArrayAsync(
299292
#if NET5_0_OR_GREATER
300293
cancellationToken
301294
#endif
302295
).ConfigureAwait(false);
303296

304-
return
305-
global::Newtonsoft.Json.JsonSerializer.Create(JsonSerializerOptions).Deserialize<byte[]?>(new global::Newtonsoft.Json.JsonTextReader(new global::System.IO.StreamReader(__content))) ??
306-
throw new global::System.InvalidOperationException("Response deserialization failed.");
297+
return __content;
307298
}
308299
catch (global::System.Exception __ex)
309300
{

0 commit comments

Comments
 (0)