Skip to content

Commit

Permalink
updated text to speech example with streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHodgson committed Nov 7, 2023
1 parent afe8554 commit 93043b2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,15 @@ Generates audio from the input text.

```csharp
var api = new OpenAIClient();
var request = new SpeechRequest("Hello world!");
var audioData = await api.AudioEndpoint.CreateSpeechAsync(request);
// play audio data
var request = new SpeechRequest("Hello World!");
async Task ChunkCallback(ReadOnlyMemory<byte> chunkCallback)
{
// TODO Implement audio playback as chunks arrive
await Task.CompletedTask;
}

var result = await api.AudioEndpoint.CreateSpeechAsync(request, ChunkCallback);
await File.WriteAllBytesAsync(@"..\..\..\Assets\HelloWorld.mp3", result.ToArray());
```

#### [Create Transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
Expand Down

0 comments on commit 93043b2

Please sign in to comment.