凌晨 1 点的时候,OpenAI 突然做了三项发布:
语音转文本(STT)模型
文本转语音(TTS)模型
一个体验网站:OpenAI.fm
结论前置:
不大的发布,实用的东西,不错的 PlayGround
剩下的,容我逐个道来。
语音转文本(STT)模型
两款模型:gpt-4o-transcribe 和 gpt-4o-mini-transcribe,比之前的 Whisper 价格更优,性能更好,尤其在处理口音、噪音和不同语速方面表现更佳。
先是价格对比
Whisper: ~ $0.006/min
gpt-4o-transcribe: ~ $0.006/min
gpt-4o-mini-transcribe: ~ $0.003/min
再是错误率对比(越低越好)
对比自家的 Whisper
对比竞品模型
这俩 endpoint,一个是 transcriptions,另一个是translations,同样可以用于新模型。前者是纯转文字,简单调用起来是这样:
from openai import OpenAI
client = OpenAI()
audio_file = open("/path/to/file/audio.mp3", "rb")
transcription = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file
)
print(transcription.text)
后者是转文字+翻译(仅限翻译成英文),调用大概这样。
from openai import OpenAI
client = OpenAI()
audio_file = open("/path/to/file/speech.mp3", "rb")
transcription = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
response_format="text"
)
print(transcription.text)
剩下的,是一些接口参数更新:
时间戳 (Timestamps):通过设置 timestamp_granularities 参数,可以获取带有时间戳的 JSON 输出,精确到句子片段或单词级别。
流式转录 (Streaming transcriptions):通过设置 stream=True,可以在模型完成音频片段的转录后立即接收到 transcript.text.delta 事件,最终会收到包含完整转录的 transcript.text.done 事件。
实时 API (Realtime API):对于正在进行的音频流(例如实时会议或语音输入),可以通过 WebSocket 连接实时发送音频数据并接收转录事件。
详细文档:
https://platform.openai.com/docs/guides/speech-to-text
语音转文本(TTS)模型
模型名称是 gpt-4o-mini-tts 可控性很强的 TTS:
可以指定要说的内容,如:“我是练习时长两年半的个人练习生”
可以指定说话的风格,如:“用娇滴滴的语气”
中文示例
英文示例
我个人感觉效果不是很好(但可以 roll 点音色);
长度方面,最大支持 2000 token 的内容;
价格方面,是 $0.015/min,示例代码如下:
import asyncio
from openai import AsyncOpenAI
from openai.helpers import LocalAudioPlayer
openai = AsyncOpenAI()
input = """大家好,我是练习时长两年半的个人练习生,你坤坤,喜欢唱、跳、Rap和篮球,music~\n\n在今后的节目中,有我很多作词,作曲,编舞的原创作品,期待的话多多投票吧!"""
instructions = """用娇滴滴的语气,萝莉音"""
asyncdefmain() -> None:
asyncwith openai.audio.speech.with_streaming_response.create(
model="gpt-4o-mini-tts",
voice="alloy",
input=input,
instructions=instructions,
response_format="pcm",
) as response:
await LocalAudioPlayer().play(response)
if __name__ == "__main__":
asyncio.run(main())
详细文档:
https://platform.openai.com/docs/guides/text-to-speech
新网站:OpenAI.fm
这是一个调试语音的 PlayGround,挺好玩的
还可以在右上角,一键导出代码
结论
不大的发布,实用的东西:
STT 很实用,Whisper 可以退役了
TTS 效果一般,不推荐用
PlayGround 的设计很不错,代码导出很方便
领取专属 10元无门槛券
私享最新 技术干货