🗣️Text to speech
Sample Code for Speech Requests:
var request = new SpeechRequest.Builder()
.SetModel(TTSModel.TTS1)
.SetVoice(VoiceActor.Alloy)
.SetInput("The quick brown fox jumped over the lazy dog.")
.Build();
var result = await request.ExecuteAsync();
AudioClip audioClip = result.AudioOutput;
// Now you can use the audio clip in your project.
// For example:
var audioSource = gameObject.AddComponent<AudioSource>();
audioSource.clip = audioClip;from pathlib import Path
import openai
speech_file_path = Path(__file__).parent / "speech.mp3"
response = openai.audio.speech.create(
model="tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file(speech_file_path)Last updated