tts-1, tts-1-hd, gpt-4o-mini-tts 모델은 사용 중단 예정(deprecated)이며 2027년 1월 6일에 서비스가 종료됩니다.
gpt-realtime-2.1-mini로 마이그레이션하려면 Realtime API를 사용하세요.
이때 API 워크플로우도 변경해야 합니다. gpt-realtime-2.1-mini는 /v1/audio/speech에서 지원되지 않습니다.
기존 연동에서는 서비스 종료 전까지 아래의 Speech API 워크플로우를 사용할 수 있습니다.
자세한 내용은 사용 중단 안내를 참고하세요.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16import fs from "fs";import path from "path";import OpenAI from "openai";const openai = new OpenAI();const speechFile = path.resolve("./speech.mp3");const mp3 = await openai.audio.speech.create({ model: "gpt-4o-mini-tts", voice: "coral", input: "Today is a wonderful day to build something people love!", instructions: "Speak in a cheerful and positive tone.",});const buffer = Buffer.from(await mp3.arrayBuffer());await fs.promises.writeFile(speechFile, buffer);
1
2
3
4
5
6
7
8
9
10
11
12
13from pathlib import Pathfrom openai import OpenAIclient = OpenAI()speech_file_path = Path(__file__).parent /"speech.mp3"with client.audio.speech.with_streaming_response.create(model="gpt-4o-mini-tts",voice="coral",input="Today is a wonderful day to build something people love!",instructions="Speak in a cheerful and positive tone.",) as response: response.stream_to_file(speech_file_path)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34package mainimport ( "context" "io" "os" "github.com/openai/openai-go/v3")func main() { client := openai.NewClient() response, err := client.Audio.Speech.New(context.Background(), openai.AudioSpeechNewParams{ Model: openai.SpeechModelGPT4oMiniTTS, Voice: openai.AudioSpeechNewParamsVoiceUnion{OfAudioSpeechNewsVoiceString2: openai.String("coral")}, Input: "Today is a wonderful day to build something people love!", Instructions: openai.String("Speak in a cheerful and positive tone."), }) if err != nil { panic(err) } defer response.Body.Close() file, err := os.Create("speech.mp3") if err != nil { panic(err) } if _, err := io.Copy(file, response.Body); err != nil { panic(err) } if err := file.Close(); err != nil { panic(err) }}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22import com.openai.client.OpenAIClient;import com.openai.client.okhttp.OpenAIOkHttpClient;import com.openai.core.http.HttpResponse;import com.openai.models.audio.speech.SpeechCreateParams;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.StandardCopyOption;try (HttpResponse audio = client .audio() .speech() .create( SpeechCreateParams.builder() .model("gpt-4o-mini-tts") .voice("coral") .input("Today is a wonderful day to build something people love!") .instructions("Speak in a cheerful and positive tone.") .build())) { Files.copy(audio.body(), Path.of("speech.mp3"), StandardCopyOption.REPLACE_EXISTING);}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17using OpenAI.Audio;#pragma warning disable OPENAI001string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;string model = "gpt-4o-mini-tts";AudioClient client = new(model, key);BinaryData audio = await client.GenerateSpeechAsync( "Today is a wonderful day to build something people love!", GeneratedSpeechVoice.Coral, new SpeechGenerationOptions { Instructions = "Speak in a cheerful and positive tone.", });await File.WriteAllBytesAsync("speech.mp3", audio.ToArray());
1
2
3
4
5
6
7
8
9
10require "openai"client = OpenAI::Client.newaudio = client.audio.speech.create( model: "gpt-4o-mini-tts", voice: "coral", input: "Today is a wonderful day to build something people love!", instructions: "Speak in a cheerful and positive tone.")File.binwrite("speech.mp3", audio.read)
1
2
3
4
5
6
7
8
9
10curl https://api.openai.com/v1/audio/speech \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini-tts", "input": "Today is a wonderful day to build something people love!", "voice": "coral", "instructions": "Speak in a cheerful and positive tone." }' \ --output speech.mp3
1
2
3
4
5
6openai audio:speech create \ --model gpt-4o-mini-tts \ --voice coral \ --instructions "Speak in a cheerful and positive tone." \ --input "Today is a wonderful day to build something people love!" \ --output speech.mp3
엔드포인트는 기본적으로 생성한 음성을 MP3로 반환합니다. 지원되는 출력 형식 중 원하는 형식을 지정할 수도 있습니다.
텍스트 음성 변환 모델
기존 Speech API 연동에서 gpt-4o-mini-tts를 사용하면 프롬프트로 다음과 같은 음성 특성을 조절할 수 있습니다.
악센트
감정 표현의 폭
억양
성대모사
말하는 속도
어조
속삭임
다른 텍스트 음성 변환 모델로는 tts-1과 tts-1-hd가 있습니다. tts-1은 tts-1-hd보다 지연 시간이 짧지만 음성 품질은 낮습니다.
음성 옵션
TTS 엔드포인트에서는 텍스트를 읽어 줄 목소리를 13가지 기본 제공 음성 중에서 선택할 수 있습니다. OpenAI.fm에서 각 음성을 듣고 직접 사용해 보세요. OpenAI API의 최신 텍스트 음성 변환 모델을 체험할 수 있는 대화형 데모입니다. 현재 음성은 영어에 최적화되어 있습니다.
alloy
ash
ballad
coral
echo
fable
nova
onyx
sage
shimmer
verse
marin
cedar
최상의 음성 품질을 원한다면 marin 또는 cedar를 권장합니다.
사용할 수 있는 음성은 모델에 따라 다릅니다. tts-1과 tts-1-hd에서 지원하는 음성은 alloy, ash, coral, echo, fable, onyx, nova, sage, shimmer로 한정됩니다.