MRCPv2
来源:互联网 发布:smtp.126.com端口 编辑:程序博客网 时间:2024/05/19 23:28
Speech Synthesizer 语音合成服务
状态机
方法
客户端用于控制服务端提供语音合成服务的方法。
synthesizer-method = "SPEAK" / "STOP" / "PAUSE" / "RESUME" / "BARGE-IN-OCCURRED" / "CONTROL" / "DEFINE-LEXICON"
- SPEAK
客户端发送SPEAK请求向服务端语音合成服务提供需要进行语音合成的文本,启动服务端语音合成和流媒体。一个SPEAK请求,通常包含SPEAK**请求行,设置语音、语速的请求头,格式化描述的需要完成语音合成的文本的请求体**。
语音服务状态:当SPEAK请求到达服务端时的状态。switch (语音服务状态){ case idle: 服务端立即处理SPEAK请求,立即向客户端响应包含成功的状态码和IN-PROGRESS的请求状态。 break; case 处理之前的SPEAK请求: 服务端向客户端响应成功状态吗和PENDING请求状态,并将SPEAK请求放入队列。队列严格按照FIFO处理,如果其中一个请求执行失败,则其后所有的请求都将被取消。服务端会生成一个SPEAK-COMPLETE事件,事件描述为cancelled。 break;}语音处理完成,服务端发起一个包含该SPEAK请求id的SPEAK-COMPLETE事件,请求状态为COMPLETE。
例如:
C->S: MRCP/2.0 ... SPEAK 543257 Channel-Identifier:32AECB23433802@speechsynth Voice-gender:neutral Voice-Age:25 Prosody-volume:medium Content-Type:application/ssml+xml Content-Length:... <?xml version="1.0"?> <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd" xml:lang="en-US"> <p> <s>You have 4 new messages.</s> <s>The first is from Stephanie Williams and arrived at <break/> <say-as interpret-as="vxml:time">0342p</say-as>. </s> <s>The subject is <prosody rate="-20%">ski trip</prosody> </s> </p> </speak> S->C: MRCP/2.0 ... 543257 200 IN-PROGRESS Channel-Identifier:32AECB23433802@speechsynth Speech-Marker:timestamp=857206027059 S->C: MRCP/2.0 ... SPEAK-COMPLETE 543257 COMPLETE Channel-Identifier:32AECB23433802@speechsynth Completion-Cause:000 normal Speech-Marker:timestamp=857206027059
上例中,客户端发送SPEAK请求,服务度响应IN-PROGRESS。处理完成后,服务端向客户端发送SPEAK-COMPLETE事件。
- STOP
客户端向服务端发送STOP请求,告知服务端停止处理一些语音合成的服务。
if request中含有Active-Request-Id-List 服务端停止Active-Request-Id-List指定的SPEAK请求;else 服务端终止所有未完成的SPEAK请求向客户端响应200响应码,并包含Active-Request-Id-List,指定被服务端种植的SPEAK请求。if request处于IN-PROGRESS if speaking被stop 队列中被PENDING的下一个请求变为IN-PROGRESS,并进入speaking状态 if pause被stop 队列中被PENDING的下一个请求变为IN-PROGRESS,并进入pause状态
例如:
C->S: MRCP/2.0 ... SPEAK 543258 Channel-Identifier:32AECB23433802@speechsynth Content-Type:application/ssml+xml Content-Length:... <?xml version="1.0"?> <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd" xml:lang="en-US"> <p> <s>You have 4 new messages.</s> <s>The first is from Stephanie Williams and arrived at <break/> <say-as interpret-as="vxml:time">0342p</say-as>.</s> <s>The subject is <prosody rate="-20%">ski trip</prosody></s> </p> </speak> S->C: MRCP/2.0 ... 543258 200 IN-PROGRESS Channel-Identifier:32AECB23433802@speechsynth Speech-Marker:timestamp=857206027059 C->S: MRCP/2.0 ... STOP 543259 Channel-Identifier:32AECB23433802@speechsynth S->C: MRCP/2.0 ... 543259 200 COMPLETE Channel-Identifier:32AECB23433802@speechsynth Active-Request-Id-List:543258 Speech-Marker:timestamp=857206039059
上例中,客户端发送543258请求,服务端响应IN-PROGRESS。客户端发出STOP请求,服务端终止了543258请求。
- PAUSE
客户端发送PAUSE请求到服务端,暂停语音合成服务。
if SPEAK请求正在处理 返回客户端包含Active-Request-Id-List的响应,告诉客户端哪个SPEAK请求被PAUSEelse if SPEAK请求已经处于pause状态 响应200else if SPEAK请求未进行处理 响应402 "Method not valid in this state"
例如
C->S: MRCP/2.0 ... SPEAK 543258 Channel-Identifier:32AECB23433802@speechsynth Voice-gender:neutral Voice-Age:25 Prosody-volume:medium Content-Type:application/ssml+xml Content-Length:... <?xml version="1.0"?> <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd" xml:lang="en-US"> <p> <s>You have 4 new messages.</s> <s>The first is from Stephanie Williams and arrived at <break/> <say-as interpret-as="vxml:time">0342p</say-as>.</s> <s>The subject is <prosody rate="-20%">ski trip</prosody></s> </p> </speak> S->C: MRCP/2.0 ... 543258 200 IN-PROGRESS Channel-Identifier:32AECB23433802@speechsynth Speech-Marker:timestamp=857206027059 C->S: MRCP/2.0 ... PAUSE 543259 Channel-Identifier:32AECB23433802@speechsynth S->C: MRCP/2.0 ... 543259 200 COMPLETE Channel-Identifier:32AECB23433802@speechsynth Active-Request-Id-List:543258
上例中,客户端发送SPEAK请求543258,服务端响应200 IN-PROGRESS。客户端发送PAUSE,服务端发送200,并暂停543258。
- RESUME
客户端控制服务端从pause状态继续提供语音合成服务speaking。
if 会话中request请求处于被pause 服务端向客户端响应带有Active-Request-Id-List的消息,指定恢复语音合成服务的请求idelse if 会话中request请求处于speaking 服务端向客户端响应200else if 会话中没有active的SPEAK请求 服务端向客户端返回402 "Method not valid in this state"
例如
C->S: MRCP/2.0 ... SPEAK 543258 Channel-Identifier:32AECB23433802@speechsynth Voice-gender:neutral Voice-age:25 Prosody-volume:medium Content-Type:application/ssml+xml Content-Length:... <?xml version="1.0"?> <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd" xml:lang="en-US"> <p> <s>You have 4 new messages.</s> <s>The first is from Stephanie Williams and arrived at <break/> <say-as interpret-as="vxml:time">0342p</say-as>.</s> <s>The subject is <prosody rate="-20%">ski trip</prosody></s> </p> </speak> S->C: MRCP/2.0 ... 543258 200 IN-PROGRESS@speechsynth Channel-Identifier:32AECB23433802 Speech-Marker:timestamp=857206027059 C->S: MRCP/2.0 ... PAUSE 543259 Channel-Identifier:32AECB23433802@speechsynth S->C: MRCP/2.0 ... 543259 200 COMPLETE Channel-Identifier:32AECB23433802@speechsynth Active-Request-Id-List:543258 C->S: MRCP/2.0 ... RESUME 543260 Channel-Identifier:32AECB23433802@speechsynth S->C: MRCP/2.0 ... 543260 200 COMPLETE Channel-Identifier:32AECB23433802@speechsynth Active-Request-Id-List:543258
客户端向服务端发送SPEAK请求,服务端返回200 IN-PROGRESS。客户端发送PAUSE请求,服务端返回200,COMPLETE并将543258请求暂停。客户端发送RESUME请求,服务端返回200,并告诉客户端543258请求已经被激活。
- BARGE-IN-OCCURRED
CONTROL
客户端向服务端发送CONTROL请求,用于修改直接修改语音合成的一些参数。比如,韵律、快进、快退、速度等。DEFINE-LEXICON
事件
synthesizer-event = "SPEECH-MARKER" / "SPEAK-COMPLETE"
消息头
synthesizer-header = jump-size / kill-on-barge-in / speaker-profile / completion-cause / completion-reason / voice-parameter / prosody-parameter / speech-marker / speech-language / fetch-hint / audio-fetch-hint / failed-uri / failed-uri-cause / speak-restart / speak-length / load-lexicon / lexicon-search-order