聚美智数


语音合成-长文本合成

<p>[TOC]</p> <h3>描述</h3> <ul> <li>长文本在线合成接口可以将10万字以内文本一次性合成,异步返回音频。支持多种优质音库,将超长文本快速转换成稳定流畅、饱满真实的音频。适用于阅读听书、新闻播报等客户。</li> </ul> <h3>1 使用流程</h3> <h4>1.1 第一步 --发起任务</h4> <ul> <li>根据文本内容、音频格式、音库等参数创建语音合成任务,获取task_id,成功进行计费。</li> </ul> <h4>1.2 第二步 -- 查询结果</h4> <ul> <li>根据task_id的数组批量查询语音合成任务结果,查询不计费。</li> </ul> <hr /> <h3>2 接口调用说明</h3> <h4>2.1 请求方式</h4> <p>如接口没有单独说明,均为:<strong>POST</strong></p> <h4>2.2 请求格式</h4> <p>如接口没有单独说明,所有接口均为:application/x-www-form-urlencoded</p> <h4>2.3 请求参数</h4> <p>请求参数包括公共参数和业务参数(业务参数见具体接口说明) 如果请求格式为application/x-www-form-urlencoded的,需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交 如果请求格式为application/json的,需要把<strong>公共参数</strong>放在<strong>请求Header</strong>中提交</p> <h5>2.3.1 公共参数</h5> <table> <thead> <tr> <th>名称</th> <th>类型</th> <th>必须</th> <th>&lt;div style=&quot;width:420px;&quot;&gt;说明&lt;/div&gt;</th> </tr> </thead> <tbody> <tr> <td>appId</td> <td>String</td> <td>是</td> <td>服务商分配的唯一标识</td> </tr> <tr> <td>timestamp</td> <td>Long</td> <td>是</td> <td>当前时间戳(毫秒)</td> </tr> <tr> <td>sign</td> <td>String</td> <td>是</td> <td>签名,详见&lt;a href=&quot;#签名算法&quot;&gt;签名算法说明&lt;/a&gt;</td> </tr> </tbody> </table> <h5>2.3.2 签名算法说明</h5> <pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre> <p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间戳(毫秒) <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p> <pre><code class="language-java">String appId = &amp;quot;xyzxy2121zxyz&amp;quot;; String timestamp = &amp;quot;1555378976238&amp;quot;; String appSecret = &amp;quot;efcefcef1121cefcefc1212121&amp;quot;; String str = appId + appSecret + timestamp; String sign = sha256(str);</code></pre> <h4>2.4 返回说明</h4> <h5>2.4.1 公共返回字段说明</h5> <p>所有接口均返回以下公共字段:</p> <table> <thead> <tr> <th>字段名</th> <th>&lt;div style=&quot;width:420px&quot;&gt;说明&lt;/div&gt;</th> </tr> </thead> <tbody> <tr> <td>code</td> <td>返回码,详见:公共code返回码说明</td> </tr> <tr> <td>msg</td> <td>code对应的描述</td> </tr> <tr> <td>taskNo</td> <td>本次请求号</td> </tr> <tr> <td>data</td> <td>返回具体结果,object类型,详见各接口返回说明</td> </tr> </tbody> </table> <p>&lt;a name=&quot;code返回码说明&quot;&gt;&lt;/a&gt;</p> <h5>2.4.2 code返回码说明</h5> <table> <thead> <tr> <th>code</th> <th>&lt;div style=&quot;width:420px;&quot;&gt;说明&lt;/div&gt;</th> </tr> </thead> <tbody> <tr> <td>200</td> <td>成功</td> </tr> <tr> <td>201</td> <td>taskId不存在(查询结果接口返回)</td> </tr> <tr> <td>202</td> <td>获取文本内容失败(查询结果结果接口返回)</td> </tr> <tr> <td>400</td> <td>参数错误</td> </tr> <tr> <td>404</td> <td>接口地址不正确</td> </tr> <tr> <td>500</td> <td>系统维护,请稍候再试</td> </tr> <tr> <td>601</td> <td>接口未开通</td> </tr> <tr> <td>602</td> <td>账号停用</td> </tr> <tr> <td>604</td> <td>接口停用</td> </tr> <tr> <td>606</td> <td>调用超限,请稍候再试</td> </tr> <tr> <td>607</td> <td>ip不在白名单</td> </tr> <tr> <td>609</td> <td>请求过于频繁,请稍候再试</td> </tr> <tr> <td>610</td> <td>请求超时</td> </tr> </tbody> </table> <hr /> <h3>3 基础接口</h3> <h4>3.1 长文本合成发起任务</h4> <ul> <li>根据文本内容、音频格式、音库等参数创建语音合成任务,获取task_id,成功进行计费。</li> </ul> <h5>3.1.1 请求地址</h5> <p><code>https://api.jumdata.com/speech-synthesis/text-long/request</code></p> <h5>3.1.2 业务参数</h5> <table> <thead> <tr> <th>名称</th> <th>类型</th> <th>必须</th> <th>&lt;div style=&quot;width:420px;&quot;&gt;说明&lt;/div&gt;</th> </tr> </thead> <tbody> <tr> <td>text</td> <td>String</td> <td>是</td> <td>待合成的文本 总字数不超过10万个字符,1个中文字、英文字母、数字或符号均算作1个字符</td> </tr> <tr> <td>format</td> <td>String</td> <td>否</td> <td>音频格式 mp3-16k,mp3-48k,wav,pcm-8k,pcm-16k,默认为mp3-16k</td> </tr> <tr> <td>voice</td> <td>Integer</td> <td>否</td> <td>音库 基础音库:度小宇=1,度小美=0,度逍遥(基础)=3,度丫丫=4;精品音库:度逍遥(精品)=5003,度小鹿=5118,度博文=106,度小童=110,度小萌=111,度米朵=103,度小娇=5。默认为度小美</td> </tr> <tr> <td>speed</td> <td>Integer</td> <td>否</td> <td>语速 取值0-15,默认为5中语速</td> </tr> <tr> <td>pitch</td> <td>Integer</td> <td>否</td> <td>音调 取值0-15,默认为5中语调</td> </tr> <tr> <td>volume</td> <td>Integer</td> <td>否</td> <td>音量 基础音库取值0-9,精品音库取值0-15,默认为5中音量(取值为0时为音量最小值,并非为无声)</td> </tr> <tr> <td>enableSubtitle</td> <td>Integer</td> <td>否</td> <td>是否开启字幕时间戳 取值范围0, 1, 2,默认为0。0表示不开启字幕时间戳,1表示开启句级别字幕时间戳,2表示开启词级别字幕时间戳</td> </tr> <tr> <td>interval</td> <td>Integer</td> <td>否</td> <td>段落间隔 取值 0-5000 ,单位ms,用于合成文本分段传入时设置段落间间隔。</td> </tr> </tbody> </table> <h5>3.1.3 返回说明</h5> <h3>正确返回样例</h3> <pre><code class="language-json">{ &amp;quot;code&amp;quot;: 200,//返回码,详见返回码说明 &amp;quot;msg&amp;quot;: &amp;quot;成功&amp;quot;,//返回码对应描述 &amp;quot;taskNo&amp;quot;: &amp;quot;340419447206566228602625&amp;quot;,//本次请求号 &amp;quot;charge&amp;quot;: true,//计费标志,true 计费,false 不计费 &amp;quot;data&amp;quot;: { &amp;quot;task_status&amp;quot;: &amp;quot;Created&amp;quot;,//状态 &amp;quot;task_id&amp;quot;: &amp;quot;66642562a281fd000186ffb4&amp;quot;//返回task_id 查询用 } }</code></pre> <h3>错误返回样例</h3> <pre><code class="language-json">{ &amp;quot;code&amp;quot;: 400, &amp;quot;msg&amp;quot;: &amp;quot;文本不能为空&amp;quot; }</code></pre> <h4>3.2 长文本合成查询结果</h4> <ul> <li>根据task_id的数组批量查询语音合成任务结果,查询不计费。</li> </ul> <h5>3.2.1 请求地址</h5> <p><code>https://api.jumdata.com/speech-synthesis/text-long/result</code></p> <h5>3.2.2 业务参数</h5> <table> <thead> <tr> <th>名称</th> <th>类型</th> <th>必须</th> <th>&lt;div style=&quot;width:420px;&quot;&gt;说明&lt;/div&gt;</th> </tr> </thead> <tbody> <tr> <td>taskIds</td> <td>String</td> <td>是</td> <td>任务id 推荐一次查询多个任务id,单次最多可查询200个</td> </tr> </tbody> </table> <h5>3.2.3 返回样例</h5> <h3>正确返回样例</h3> <pre><code class="language-json">{ &amp;quot;code&amp;quot;: 200,//返回code &amp;quot;msg&amp;quot;: &amp;quot;成功&amp;quot;,//code对应的说明描述 &amp;quot;taskNo&amp;quot;: &amp;quot;340419447206566228602625&amp;quot;,//本次请求号 &amp;quot;charge&amp;quot;: false,//计费标志,true 计费,false 不计费 &amp;quot;data&amp;quot;: { &amp;quot;tasks_info&amp;quot;: [ //任务信息 { &amp;quot;task_status&amp;quot;: &amp;quot;Success&amp;quot;,//任务状态 &amp;quot;task_result&amp;quot;: {//任务结果 &amp;quot;speech_url&amp;quot;: &amp;quot;xxx&amp;quot;,//音频下载链接 &amp;quot;speech_timestamp&amp;quot;: {//字幕时间戳信息 &amp;quot;sentences&amp;quot;: [//句子列表 { &amp;quot;paragraph_index&amp;quot;: 0,//句子在传入文本中段落位置 &amp;quot;sentence_texts&amp;quot;: &amp;quot;xxx&amp;quot;,//句子文本信息 &amp;quot;begin_time&amp;quot;: 104,//句子文本在合成音频的开始时间戳 &amp;quot;end_time&amp;quot;: 5970,//句子文本在合成音频的结束时间戳 &amp;quot;characters&amp;quot;: [//句子中各个词的信息 { &amp;quot;character_text&amp;quot;: &amp;quot;今&amp;quot;,//句子中的词文本 &amp;quot;begin_time&amp;quot;: 106, //句子中的词在合成音频的开始时间戳 &amp;quot;end_time&amp;quot;: 313 //句子中的词在合成音频的结束时间戳 } ] } ] } }, &amp;quot;task_id&amp;quot;: &amp;quot;63c6550e52064d000104da0d&amp;quot;//任务Id } ] } }</code></pre> <h3>错误返回样例</h3> <pre><code class="language-json">{ &amp;quot;code&amp;quot;: 201, &amp;quot;msg&amp;quot;: &amp;quot;taskId不存在&amp;quot; }</code></pre>

页面列表

ITEM_HTML