Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCM support for text-to-speech #183

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public struct AudioSpeechQuery: Codable, Equatable {
**Response:**

```swift
/// Audio data for one of the following formats :`mp3`, `opus`, `aac`, `flac`
/// Audio data for one of the following formats :`mp3`, `opus`, `aac`, `flac`, `pcm`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly the documentation also mentions wav, so I'm wondering if we should add that as well to this PR or a separate PR.

image

public let audioData: Data?
```

Expand Down
4 changes: 3 additions & 1 deletion Sources/OpenAI/Public/Models/AudioSpeechQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public struct AudioSpeechQuery: Codable {
/// - opus
/// - aac
/// - flac
/// - pcm
public enum AudioSpeechResponseFormat: String, Codable, CaseIterable {
case mp3
case opus
case aac
case flac
case pcm
}

/// The text to generate audio for. The maximum length is 4096 characters.
Expand All @@ -45,7 +47,7 @@ public struct AudioSpeechQuery: Codable {
/// The voice to use when generating the audio. Supported voices are alloy, echo, fable, onyx, nova, and shimmer. Previews of the voices are available in the Text to speech guide.
/// https://platform.openai.com/docs/guides/text-to-speech/voice-options
public let voice: AudioSpeechVoice
/// The format to audio in. Supported formats are mp3, opus, aac, and flac.
/// The format to audio in. Supported formats are mp3, opus, aac, flac, and pcm.
/// Defaults to mp3
public let responseFormat: AudioSpeechResponseFormat?
/// The speed of the generated audio. Select a value from **0.25** to **4.0**. **1.0** is the default.
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAI/Public/Models/AudioSpeechResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import Foundation
/// Learn more: [OpenAI Speech – Documentation](https://platform.openai.com/docs/api-reference/audio/createSpeech)
public struct AudioSpeechResult: Codable, Equatable {

/// Audio data for one of the following formats :`mp3`, `opus`, `aac`, `flac`
/// Audio data for one of the following formats :`mp3`, `opus`, `aac`, `flac`, `pcm`
public let audio: Data
}