Its possible to play audio stream(PCM stream 8000) from vxml or ccxml (Voximal)

285 views Asked by At

Hope you doing fine. We been using Voximal(Latest) with asterisk 13 on Ubuntu(16.04.2 LTS).

I am trying to call my java web service which returns PCM 8000 stream, this stream we are generating using Amazon polly, then i want to playback the same stream to user over phone strictly using vxml.

First i want to know it's possible to playback the PCM stream using VXML2.1 or CCXML, i search a lot till now no success.

this is my vxml code, just a wild try :)

 <?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>

Below is my java code

@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);

}

If anyone can point me to any articles or any more info, i will feel oblige.

Thanks

1

There are 1 answers

0
Borja SIXTO On

Polly is integrated with Voximal (you only need to set the right configuration in the TTS/prompt section). Voximal uses the command line "aws" to generate local audio contents, you can have access to the full power of the Amazon TextToSpeech, but the response time should be reduced by using another method (~1s of delay, but Voximal uses a cache that can mask this effect). We will improve the Polly integration in the next Voximal releases.

Another way is to create your own Polly integration with our TTS/HTTP API : https://wiki.voximal.com/doku.php?id=installation_guide:tts_http:start

For each section, Voximal will generate HTTP requests if the text content is not in the cache.