Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,49 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
/// </remarks>
public async global::System.Threading.Tasks.Task<global::MagicHour.AiVoiceClonerCreateAudioResponse> AiVoiceClonerCreateAudioAsync(

global::MagicHour.AiVoiceClonerCreateAudioRequest request,
global::MagicHour.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await AiVoiceClonerCreateAudioAsResponseAsync(

request: request,
requestOptions: requestOptions,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// AI Voice Cloner<br/>
/// Clone a voice from an audio sample and generate speech. <br/>
/// * Each character costs 0.05 credits. <br/>
/// * The cost is rounded up to the nearest whole number
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::MagicHour.ApiException"></exception>
/// <remarks>
/// curl --request POST \<br/>
/// --url https://api.magichour.ai/v1/ai-voice-cloner \<br/>
/// --header 'accept: application/json' \<br/>
/// --header 'authorization: Bearer &lt;token&gt;' \<br/>
/// --header 'content-type: application/json' \<br/>
/// --data '<br/>
/// {<br/>
/// "name": "My Voice Cloner audio",<br/>
/// "assets": {<br/>
/// "audio_file_path": "api-assets/id/1234.mp3"<br/>
/// },<br/>
/// "style": {<br/>
/// "prompt": "Hello, this is my cloned voice."<br/>
/// }<br/>
/// }<br/>
/// '
/// </remarks>
public async global::System.Threading.Tasks.Task<global::MagicHour.AutoSDKHttpResponse<global::MagicHour.AiVoiceClonerCreateAudioResponse>> AiVoiceClonerCreateAudioAsResponseAsync(

global::MagicHour.AiVoiceClonerCreateAudioRequest request,
global::MagicHour.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -105,6 +148,7 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(

global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{

var __pathBuilder = new global::MagicHour.PathBuilder(
path: "/v1/ai-voice-cloner",
baseUri: HttpClient.BaseAddress);
Expand Down Expand Up @@ -184,6 +228,8 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
Expand All @@ -194,6 +240,11 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
var __retryDelay = global::MagicHour.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: null,
attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::MagicHour.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
Expand All @@ -211,6 +262,8 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
Expand All @@ -220,8 +273,7 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::MagicHour.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand All @@ -230,6 +282,11 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
__attempt < __maxAttempts &&
global::MagicHour.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
var __retryDelay = global::MagicHour.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: __response,
attempt: __attempt);
await global::MagicHour.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::MagicHour.AutoSDKRequestOptionsSupport.CreateHookContext(
Expand All @@ -246,14 +303,15 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
retryDelay: __retryDelay,
retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::MagicHour.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand Down Expand Up @@ -293,6 +351,8 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
Expand All @@ -313,6 +373,8 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
// Invalid Request
Expand Down Expand Up @@ -527,9 +589,13 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
{
__response.EnsureSuccessStatusCode();

return
global::MagicHour.AiVoiceClonerCreateAudioResponse.FromJson(__content, JsonSerializerContext) ??
var __value = global::MagicHour.AiVoiceClonerCreateAudioResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
return new global::MagicHour.AutoSDKHttpResponse<global::MagicHour.AiVoiceClonerCreateAudioResponse>(
statusCode: __response.StatusCode,
headers: global::MagicHour.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down Expand Up @@ -557,9 +623,13 @@ partial void ProcessAiVoiceClonerCreateAudioResponseContent(
#endif
).ConfigureAwait(false);

return
await global::MagicHour.AiVoiceClonerCreateAudioResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
var __value = await global::MagicHour.AiVoiceClonerCreateAudioResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::MagicHour.AutoSDKHttpResponse<global::MagicHour.AiVoiceClonerCreateAudioResponse>(
statusCode: __response.StatusCode,
headers: global::MagicHour.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
Loading