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 @@ -35,6 +35,20 @@ public partial interface ITextToSpeechClient
/// Stream audio as it's generated. Returns chunked WAV data for progressive playback. The model associated with the voice is selected automatically.
/// </summary>
/// <param name="request"></param>
/// <returns>The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response.</returns>
/// <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::ResembleAI.ApiException"></exception>
global::System.Threading.Tasks.Task<global::ResembleAI.AutoSDKHttpResponse<global::System.IO.Stream>> StreamSynthesizeAsStreamAsResponseAsync(

global::ResembleAI.StreamSynthesizeRequest request,
global::ResembleAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Streaming text-to-speech synthesis (HTTP)<br/>
/// Stream audio as it's generated. Returns chunked WAV data for progressive playback. The model associated with the voice is selected automatically.
/// </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::ResembleAI.ApiException"></exception>
Expand Down
66 changes: 44 additions & 22 deletions src/libs/ResembleAI/Generated/ResembleAI.ResponseStream.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal sealed class ResponseStream : global::System.IO.Stream
{
private readonly global::System.Net.Http.HttpResponseMessage _response;
private readonly global::System.IO.Stream _stream;
private bool _disposed;
private int _disposed;

public ResponseStream(
global::System.Net.Http.HttpResponseMessage response,
Expand Down Expand Up @@ -47,21 +47,51 @@ public override int WriteTimeout
global::System.Threading.CancellationToken cancellationToken) =>
_stream.FlushAsync(cancellationToken);

public override int Read(byte[] buffer, int offset, int count) =>
_stream.Read(buffer, offset, count);
public override int Read(byte[] buffer, int offset, int count)
{
try
{
return _stream.Read(buffer, offset, count);
}
catch
{
Dispose();
throw;
}
}

public override global::System.Threading.Tasks.Task<int> ReadAsync(
public override async global::System.Threading.Tasks.Task<int> ReadAsync(
byte[] buffer,
int offset,
int count,
global::System.Threading.CancellationToken cancellationToken) =>
_stream.ReadAsync(buffer, offset, count, cancellationToken);
global::System.Threading.CancellationToken cancellationToken)
{
try
{
return await _stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
}
catch
{
Dispose();
throw;
}
}

#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER
public override global::System.Threading.Tasks.ValueTask<int> ReadAsync(
public override async global::System.Threading.Tasks.ValueTask<int> ReadAsync(
global::System.Memory<byte> buffer,
global::System.Threading.CancellationToken cancellationToken = default) =>
_stream.ReadAsync(buffer, cancellationToken);
global::System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await _stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false);
}
catch
{
Dispose();
throw;
}
}
#endif

public override long Seek(long offset, global::System.IO.SeekOrigin origin) =>
Expand Down Expand Up @@ -89,28 +119,20 @@ public override void Write(byte[] buffer, int offset, int count) =>

protected override void Dispose(bool disposing)
{
if (!_disposed && disposing)
if (disposing && global::System.Threading.Interlocked.Exchange(ref _disposed, 1) == 0)
{
_disposed = true;
_stream.Dispose();
// The response content owns the underlying stream; disposing both would close it twice.
_response.Dispose();
}

base.Dispose(disposing);
}

#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER
public override async global::System.Threading.Tasks.ValueTask DisposeAsync()
public override global::System.Threading.Tasks.ValueTask DisposeAsync()
{
if (_disposed)
{
return;
}

_disposed = true;
await _stream.DisposeAsync().ConfigureAwait(false);
_response.Dispose();
await base.DisposeAsync().ConfigureAwait(false);
Dispose();
return default;
}
#endif
}
Expand Down
Loading
Loading