본문 바로가기
C.W.K.
Stream
Lesson 04 of 05 · published

Audio APIs — TTS, 전사, Realtime

~22 min · audio, tts, transcription

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

OpenAI audio API 는 세 갈래로 나뉘어. TTS 는 gpt-4o-mini-tts 로 text 를 audio 로 바꾸고, 전사는 gpt-4o-transcribe 로 audio 를 text 로 바꾸며, Realtime은 websocket 에서 양방향 저지연 voice agent 를 만들어.

TTS — text-to-speech

client.audio.speech.create(model='gpt-4o-mini-tts', voice='nova', input='...') 로 MP3, Opus, WAV 를 만들 수 있어. 여러 voice 중 제품 character 와 어울리는 tone 을 골라.

전사 — speech-to-text

client.audio.transcriptions.create(model='gpt-4o-transcribe', file=...) 로 WAV, MP3, M4A 등을 text 로 바꿔. 단어별 timestamp 는 caption 과 음성 검색에 활용할 수 있어.

Realtime — 실시간 voice agent

말을 들으면서 바로 답하는 경험에는 Realtime websocket 을 써. connection 하나에서 audio input 과 output 이 함께 흐르므로 TTS 와 STT 를 따로 이어붙이는 방식보다 지연을 줄일 수 있어.

cwkPippa 의 TTS 선택

cwkPippa 는 더 풍부한 prosody 를 위해 ElevenLabs 의 Joanne voice 를 기본으로 쓰고, MD5 cache 로 같은 문장을 다시 생성하지 않아. 높은 음성 표현력이 필요하지 않은 작업에는 OpenAI TTS 가 단순한 선택이 될 수 있어.

Code

TTS with gpt-4o-mini-tts·python
# Classic Whisper
with open("recording.mp3", "rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        model="whisper-1",
        file=audio_file,
        language="en",
        response_format="text",  # "text", "json", "srt", "vtt"
    )
print(transcript.text)

# GPT-4o powered (more accurate)
with open("recording.mp3", "rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        model="gpt-4o-transcribe",
        file=audio_file,
    )
전사 with gpt-4o-transcribe·python
response = client.audio.speech.create(
    model="tts-1",             # "tts-1", "tts-1-hd", "gpt-4o-mini-tts"
    voice="alloy",             # "alloy", "echo", "fable", "onyx", "nova", "shimmer"
    input="Hello! Welcome to our service.",
    response_format="mp3",     # "mp3", "opus", "aac", "flac", "wav", "pcm"
    speed=1.0,                 # 0.25 – 4.0
)

with open("speech.mp3", "wb") as f:
    f.write(response.content)

External links

Exercise

'Speak this answer' 흐름을 만들어 text 를 gpt-4o-mini-tts MP3 로 저장해. 이어서 그 MP3 를 gpt-4o-transcribe 로 다시 text 로 바꾸고 원문 paragraph 가 얼마나 보존됐는지 확인해.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.