Vercel News

Microsoft AI models are now available on AI Gateway

6.7内容质量

TL;DR · AI 摘要

Microsoft AI models are now available on AI Gateway - Vercel Vercel and Microsoft AI MAI have partnered to make MAI mode...

核心要点

  • 主题聚焦:Microsoft AI models are now available on AI Gate
  • 来源:Vercel News,建议结合原文判断细节。
  • AI 分析暂不可用,本条为保底评分与摘要。
#AI#后端#安全
打开原文

Microsoft AI 模型现已在 AI Gateway 上提供 - Vercel

Vercel 与微软 AI(MAI)达成合作,使 MAI 模型可通过 AI Gateway 访问。AI Gateway 是少数几家提供 MAI 模型访问权限的平台之一。

MAI 对安全性和零数据保留(ZDR)的关注与 Vercel 为 AI Gateway 用户提供数据控制权和训练使用透明度的目标相一致。

复制链接到标题 MAI 模型在 AI Gateway 上

MAI 最新的音频模型现已在 AI Gateway 上支持。MAI-Voice-2.1 和 MAI-Voice-2.1-Flash 用于生成语音,而 MAI-Transcribe-2 Streaming 则在音频到达时返回转录更新。

  • MAI-Voice-2.1(microsoft/mai-voice-2.1)可在 23 种语言中生成富有表现力的语音,并在较长段落中保持一致的发言人。适用于从头到尾都需要完整呈现的旁白、有声书、播客和课程。
  • MAI-Voice-2.1-Flash(microsoft/mai-voice-2.1-flash)将相同的多语言语音生成能力应用于低延迟交互。适用于需要快速响应的语音代理、助手和语音回复。
  • MAI-Transcribe-2 Streaming(microsoft/mai-transcribe-2-streaming)在音频仍在传输时返回部分转录内容。应用程序可以实时显示字幕或即时跟踪对话,无需等待完整录音。

AI Gateway 按照列出的费率计费这些模型,不收取平台费用或推理成本的附加费用。

复制链接到标题 入门

使用 AI SDK 7 中的 generateSpeech 与 MAI-Voice-2.1-Flash 创建语音响应。语音名称选择微软的 Harper 语音并搭配 Flash 模型:

code
1
import
{
experimental_generateSpeech
as
generateSpeech
}
from
'ai'
;
2
import
{
writeFile
}
from
'node:fs/promises'
;
3
4
const
result
=
await
generateSpeech
(
{
5
model
:
'microsoft/mai-voice-2.1-flash'
,
6
text
:
'Your order is ready for pickup.'
,
7
voice
:
'en-US-Harper:MAI-Voice-2.1-Flash'
,
8
outputFormat
:
'mp3'
,
9
}
)
;
10
11
await
writeFile
(
'response.mp3'
,
result
.
audio
.
uint8Array
)
;

对于较长的音频(如旁白),请使用 microsoft/mai-voice-2.1 。

复制链接到标题 转录实时音频

streamTranscribe 接收音频块流,并在音频到达时返回转录更新。此示例假设 microphoneStream 是 16 kHz、16 位 PCM 音频的 ReadableStream:

code
1
import
{
experimental_streamTranscribe
as
streamTranscribe
}
from
'ai'
;
2
3
const
stream
=
streamTranscribe
(
{
4
model
:
'microsoft/mai-transcribe-2-streaming'
,
5
audio
:
microphoneStream
,
6
inputAudioFormat
:
{
type
:
'audio/pcm'
,
rate
:
16000
}
,
7
}
)
;
8
9
for
await
(
const
part
of
stream
.
fullStream
)
{
10
if
(
part
.
type
===
'transcript-partial'
)
{
11
process
.
stdout
.
write
(
`
\r
${
part
.
text
}
`
)
;
12
}
13
}
14
15
console
.
log
(
await
stream
.
text
)
;

由于更多音频到达时部分转录内容可能会更改,因此当新部分到达时应替换显示的文本。

复制链接到标题 其他资源

探索 MAI-Voice-2.1-Flash 用于语音生成,以及 MAI-Transcribe-2 Streaming 用于实时转录。查看 MAI 模型页面了解完整模型系列,或按照语音快速入门指南开始使用。

AI Gateway 提供一个 API 用于调用模型、跟踪使用情况和成本,并查看请求追踪。它还支持跨可用提供商的路由、重试和故障转移。