@crvouga/ mockingbird-service-aws-speech (中文(简体) )
本地模拟器。 真正的API合同. 部分 嘲笑鸟。 。 。 .
状态模拟器 亚马逊波利 财务报告和审定财务报表 亚马逊语转写 测试套房: Polly
SynthesizeSpeech 财务报告和审定财务报表 StartSpeechSynthesisStream (HTTP/2 二进制事件流),转写
流线 StartStreamTranscription (HTTP/2 二相)和转录批次
StartTranscriptionJob 编号 : GetTranscriptionJob。聊天声音将运行到没有音频结束
离开机器:转录“听力” 测试脚本,波利用决定论回答
其长度跟随文本的合成音频.
- 行动范围: 支助
- 与官方客户 证明我们的消费者针:
@aws-sdk/client-polly, (中文(简体) ),@aws-sdk/client-transcribe-streaming, (中文(简体) ),@aws-sdk/client-transcribe(3.1132.0)和《蒙特利尔议定书》3 解码我们的后端用途( e)[email protected]) (中文(简体) ).
安装
npm install -D @crvouga/mockingbird-service-aws-speech
仅限无害环境管理。 节点 22或 Bun 1.2. 无土生属地. 给它服务
npx mockingbird-aws-speech serve (h2c + 一个端口的HTTP/1.1), createServer 从
./server,或 createRuntime 与任何获取服务器(仅HTTP/1.1).
使用量
npx mockingbird-aws-speech serve --port 8797
export AWS_ENDPOINT_URL_POLLY=http://127.0.0.1:8797
export AWS_ENDPOINT_URL_TRANSCRIBE_STREAMING=http://127.0.0.1:8797
export AWS_ENDPOINT_URL_TRANSCRIBE=http://127.0.0.1:8797
import { PollyClient, SynthesizeSpeechCommand } from "@aws-sdk/client-polly"
import {
StartStreamTranscriptionCommand,
TranscribeStreamingClient,
} from "@aws-sdk/client-transcribe-streaming"
import { createServer } from "@crvouga/mockingbird-service-aws-speech/server"
// Test setup: start the emulator and script what the next voice session "hears":
// partials while audio streams in, then the final.
const emulator = await createServer()
await fetch(`${emulator.url}/__admin/transcripts`, {
method: "PUT",
headers: { "content-type": "application/json" },
body: JSON.stringify({ match: { any: true }, partials: ["I have", "I have a headache"], final: "I have a headache." }),
})
// The AWS SDK clients your application uses; only the endpoint changes.
const config = {
endpoint: emulator.url,
region: "us-east-1",
credentials: { accessKeyId: "fixture", secretAccessKey: "fixture" },
}
const transcribe = new TranscribeStreamingClient(config)
const polly = new PollyClient(config)
// Application code: a voice turn transcribes the member's audio, then speaks the reply.
const { TranscriptResultStream } = await transcribe.send(
new StartStreamTranscriptionCommand({
LanguageCode: "en-US",
MediaEncoding: "pcm",
MediaSampleRateHertz: 16_000,
AudioStream: (async function* () {
yield { AudioEvent: { AudioChunk: new Uint8Array(3_200) } }
})(),
}),
)
const heard: string[] = []
for await (const event of TranscriptResultStream ?? []) {
for (const result of event.TranscriptEvent?.Transcript?.Results ?? [])
heard.push(result.Alternatives?.[0]?.Transcript ?? "")
}
// heard: ["I have", "I have a headache", "I have a headache."]
const { AudioStream } = await polly.send(
new SynthesizeSpeechCommand({ VoiceId: "Matthew", OutputFormat: "mp3", Text: "Rest and drink water." }),
)
const audio = await AudioStream?.transformToByteArray() // deterministic MP3 frames
await emulator.close() // after the test
议定书
Polly 和 Translatising 客户端默认为 NodeHttp2Handler: 反对 http://
他们说话的终点 (单位:千美元) 及其双向
操作需要 HTTP/2 二进制。 转录批次使用HTTP/1.1. mockingbird-aws-speech serve
财务报告和审定财务报表 createServer 嗅出每个连接并在一个端口上服务(serve --config 从
另一家服务的CLI,和 createRuntime 在 Plain Facker 服务器后,只说 HTTP/1.1 ).
路线
| 路线 | 行为 |
|---|---|
POST /v1/speech | 宝丽 SynthesizeSpeech。 。 。 . OutputFormat: pcm − 生PCM s16le单音节440 Hz音(audio/pcm即使字节数, SampleRate 8000/16000,默认为16000; mp3 • 有效的 MPEG-2 第三级框架(audio/mpeg,8000/16000/22050/24000) (中文(简体) ). 每个字符60毫秒的音频,每跑一次的字节相同; x-amzn-RequestCharacters。错误: ValidationException (未知的声音或引擎), InvalidSampleRateException, (中文(简体) ), TextLengthExceededException ( > 3000个字符). |
POST /v1/synthesisStream | 宝丽 StartSpeechSynthesisStream (HTTP/2 二进制,参数: x-amzn-Engine 编号 : x-amzn-VoiceId 编号 : x-amzn-OutputFormat 编号 : x-amzn-SampleRate; 仅基因引擎). 每个 TextEvent 答题 AudioEvents (24 kHz MP3 帧 mpg123 解码); CloseStreamEvent (或输入结束)答案 StreamClosedEvent {RequestCharacters}。 。 。 . |
POST /stream-transcription | 转写 StartStreamTranscription (HTTP/2 二联). 验证 x-amzn-transcribe-* 参数 (400) BadRequestException),在响应标题中回放它们 x-amzn-transcribe-session-id。发送一个脚本部分(IsPartial: true(单位) AudioEvent 收到,其余的当音频结束, 然后最后的结果,然后关闭。 音频字节被计算,从未保留. |
POST / | 转录批次(AWS JSON 1.1, X-Amz-Target) (中文(简体) ). StartTranscriptionJob → IN_PROGRESS (单位:千美元)ConflictException 重复名称; GetTranscriptionJob → COMPLETED 一次 jobDurationMs (2 s) 已经传递到模拟时钟上 Transcript.TranscriptFileUri =: https://s3.<region>.amazonaws.com/<OutputBucketName>/<OutputKey>· ; BadRequestException 一个未知的工作. |
语录 (PUT /__admin/transcripts(中文(简体) )
{match?, partials?, final, times?} (或 {"transcripts": [...]}) (中文(简体) ). match 实值
{sessionIndex} (基于名称空间中流线会话的0基数), {jobName} (批次数)
任务),或 {any: true}; 准确的对决胜出 any。无文字记录的会议和工作听到
defaultTranscript (单位:千美元)"Hello.", (中文(简体) ), PUT /__admin/settings并计为 unscripted
(单位:千美元)GET /__admin/transcripts → stats) (中文(简体) ).
管理员(超过标准合同)
| 路线 | 效果 |
|---|---|
PUT 编号 : POST 编号 : GET 编号 : DELETE /__admin/transcripts | 替换、添加、列表(由 stats),删除(?id=) (中文(简体) ). |
GET /__admin/jobs | 批量工作(在模拟器时钟上得到先进). |
POST /__admin/jobs/:name/complete | 现在完成,可选择使用 {transcript}。 。 。 . |
POST /__admin/jobs/:name/fail | 失败 {reason} (单位:千美元)FailureReason) (中文(简体) ). |
GET /__admin/jobs/:name/transcript | JSON Transis的笔录会写给S3. |
GET /__admin/speech | 每份合成/抄本的元数据(语音、引擎、格式、字符、字节、脚本 id——从不文本). |
GET/PUT /__admin/settings | defaultTranscript, (中文(简体) ), jobDurationMs。 。 。 . |
与 --s3-endpoint <url> (单位:千美元)transcriptStore jSON的笔录也是
写到 S3( 堆栈的 s3rver) OutputBucketName/OutputKey所以这个应用是自己的
GetObject 打开 TranscriptFileUri 发现它.
错误预设( E)POST /__admin/faults {"preset": "<name>", "count"?: n}:
polly_throttling (429个) ThrottlingException, (中文(简体) ), polly_service_failure (500个),
polly_stream_throttling 编号 : polly_stream_validation 编号 : polly_stream_quota (一个例外)
任何音频前的事件: 我们的适配器返回到 SynthesizeSpeech, (中文(简体) ), polly_stream_failure
(单位:千美元)ServiceFailureException 音频之后, polly_stream_no_close (无) StreamClosedEvent, (中文(简体) ),
transcribe_bad_request (400个), transcribe_limit_exceeded (429个), transcribe_service_unavailable
(503个), transcribe_mid_stream_failure (单位:千美元)InternalFailureException 在第一部分之后,
transcribe_job_limit (单位:千美元)LimitExceededException, (中文(简体) ), transcribe_job_failed (下一个任务) FAILED) (中文(简体) ).
命名空间
x-mockingbird-namespace页:1 /__admin/ns/<name> 前缀在端点 URL上,或 SigV4 访问密钥 id:
PUT /__admin/credentials {"credentials": {"<AWS_ACCESS_KEY_ID>": "<namespace>"}}。日记
记录语音,引擎,格式,字符计数和脚本代号——永远不要文本.
故意不模拟
- 真实的语音: Polly 音频是一个音调( PCM) 或无声但有效的 MP3 帧( 一个音调需要真实的) MP3编码器; Transis从不听——单词只出自脚本.
ogg_vorbis, (中文(简体) ),ogg_opus, (中文(简体) ),mulaw, (中文(简体) ),alaw和语音标记json)输出,SSML语义(tags) 按长度、词典、每台语音引擎的可用性计算.- 转写语言识别,扬声器标签,自定义词汇(接受并呼应, ),Call Analytics and Medical 变体,批量工作读取自S3的介质.
- SigV4 签名和事件签名未验证;访问密钥 id 只选择一个 名称空间.
API 密码
| 导出 | 仁爱 | 说明 |
|---|---|---|
SpeechAPI | 类 | 进程模拟器 : fetch, (中文(简体) ), reset, (中文(简体) ), jobs(), (中文(简体) ), complete(name, transcript?), (中文(简体) ), fail(name, reason), (中文(简体) ), transcriptDocument(job), (中文(简体) ), speechLog(), (中文(简体) ), stats()选项: sqlite, (中文(简体) ), now, (中文(简体) ), namespace, (中文(简体) ), settings, (中文(简体) ), transcripts, (中文(简体) ), transcriptStore。 。 。 . |
createRuntime | 函数 | 服务合同的模拟者。 选项 : settings, (中文(简体) ), transcripts, (中文(简体) ), transcriptStore, (中文(简体) ), clock, (中文(简体) ), seed, (中文(简体) ), adminKey, (中文(简体) ), onLog, (中文(简体) ), sqlite。 。 。 . |
SPEECH_PRESETS | 对象 | 每个命名的断层预设. |
SPEECH_NAMESPACE | 字符串 | 服务名称, "aws-speech"。 。 。 . |
POLLY_VOICES | 数组 | 每个波利的声音id模拟器接受. |
speechError | 函数 | 剩余 Json1 错误响应( S)x-amzn-ErrorType + 键 {message}) (中文(简体) ). |
accessKeyCredential | 函数 | SigV4 访问请求的密钥 ID( 如何将证书映射到命名空间) . |
pcmTone, (中文(简体) ), mp3Audio, (中文(简体) ), mp3Frame, (中文(简体) ), durationFor, (中文(简体) ), MS_PER_CHARACTER, (中文(简体) ), MP3_SAMPLE_RATES, (中文(简体) ), MP3_SAMPLES_PER_FRAME | 音频 | 决定性的合成音频. |
DEFAULT_SETTINGS | 价值 | 默认设置 . |
encodeMessage, (中文(简体) ), decodeMessage, (中文(简体) ), FrameReader, (中文(简体) ), readFrames, (中文(简体) ), eventFrame, (中文(简体) ), exceptionFrame, (中文(简体) ), unwrapSigned, (中文(简体) ), crc32, (中文(简体) ), EventStreamError | 代码c | 事件流编码器(精确的前奏,头和CRC32),双向. |
document, (中文(简体) ), operationIds, (中文(简体) ), supportedOperationIds | 数值 | 销售商为OpenAPI合同及其业务代号. |
createServer, (中文(简体) ), serveTarget, (中文(简体) ), DEFAULT_PORT, (中文(简体) ), listenH2c (单位:千美元)./server(中文(简体) ) | 节点 | 在一个端口上服务 h2c + HTTP/1.1 serve CLI目标; 第8797端口; 二相正听器. |
部分 嘲笑鸟。 。 。 .