gpt4 book ai didi

java - 可以从 vxml 或 ccxml (Voximal) 播放音频流(PCM 流 8000)

转载 作者:行者123 更新时间:2023-11-30 06:30:08 27 4
gpt4 key购买 nike

希望你一切顺利。我们一直在 Ubuntu(16.04.2 LTS) 上使用带有 asterisk 13 的 Voximal(最新)。

我正在尝试调用返回 PCM 8000 流的 java Web 服务,该流是我们使用 Amazon polly 生成的,然后我想严格使用 vxml 通过电话向用户播放相同的流。

首先我想知道是否可以使用VXML2.1或CCXML来播放PCM流,我搜索了很多到现在还没有成功。

这是我的 vxml 代码,只是一次疯狂的尝试:)

 <?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">
<var name="serviceVS" expr="'http://localhost:57144/polly/v1'"/>
<form>
<filled>
<data name="url" srcexpr="serviceVS" method="post" namelist="file"
enctype="multipart/form-data"/>
<assign name="urlToPlay" expr="url.url"/>

<log>
urlToPlay =>
<value expr="urlToPlay"/>
</log>
<audio expr ="urlToPlay"/>
</filled>
</form>
</vxml>

下面是我的java代码

@RequestMapping(value="/polly/v1", method = {RequestMethod.POST,RequestMethod.GET})
public ResponseEntity<InputStreamResource> pollyEndPoint(@RequestParam("voiceId") String voiceId,
@RequestParam("text")String text,@RequestParam("outputFormat") String outputFormat){
InputStream speechStream= null;
InputStreamResource inputStreamResource=null;
HttpHeaders headers=null;
try{
speechStream=quikWitService.getPollyTextToSpeech(voiceId,text,outputFormat);
inputStreamResource= new InputStreamResource(speechStream);
headers = new HttpHeaders();
headers.add("Content-Type",QuikWitUtils.getAudioFormatContentType(outputFormat));

}
catch(Exception e){
logger.error(e);
logger.debug(e.getStackTrace());
}
return new ResponseEntity<>(inputStreamResource,headers, HttpStatus.OK);

}

如果有人可以向我指出任何文章或更多信息,我将不胜感激。

谢谢

最佳答案

Polly 与 Voximal 集成(您只需在 TTS/提示部分设置正确的配置)。Voximal 使用命令行“aws”生成本地音频内容,您可以使用 Amazon TextToSpeech 的全部功能,但应使用另一种方法来减少响应时间(约 1 秒的延迟,但 Voximal 使用的缓存可以掩盖这种影响)。我们将在下一个 Voximal 版本中改进 Polly 集成。

另一种方法是创建您自己的 Polly 与我们的 TTS/HTTP API 集成: https://wiki.voximal.com/doku.php?id=installation_guide:tts_http:start

对于每个部分,如果文本内容不在缓存中,Voximal 将生成 HTTP 请求。

关于java - 可以从 vxml 或 ccxml (Voximal) 播放音频流(PCM 流 8000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46340506/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com