Message |
[+]
Avaya Orchestration Designer
» How to play non wav sound, 12/02/2018 12:51:38
» Go to message
|
|
Ross, thank you for your help!
After quite a bit trial and error, found what I was doing wrong.
While trying to convert synthesized audio format Riff8Khz8BitMonoMULaw to 8Khz 8Bit WAV, I specified audio format like this:
AudioFormat frmt = new AudioFormat(8000, 16, 1, true, false);
It looks like encoding must be specified (if not PCM), so this fixed it:
AudioFormat frmt = new AudioFormat(new AudioFormat.Encoding("ULAW"), 8000, 8, 1, 2, 8000, false);
|
|
[+]
Avaya Orchestration Designer
» How to play non wav sound, 12/02/2018 10:57:22
» Go to message
|
|
Yes, file created by the code I posted plays in Eclipse AOD and outside (i.e. windows media player). Both players have way too much background noise - this is why I think code that converts Mono MU Law to wav is probably culprit in this case.
When I request riff-16khz-16bit-mono-pcm - it remains silent in Eclipse AOD but plays crystal clear outside.
|
|
[+]
Avaya Orchestration Designer
» How to play non wav sound, 12/02/2018 10:13:51
» Go to message
|
|
I do pretty much the same, except I cannot request .withSampleRate("8000") for PCM.
But, as per your link, Raw8Khz8BitMonoMULaw should be supported. Below is the code which makes the file. File is played by AOD in eclipse, but sound has a lot of background noise. Maybe I am just not converting it properly to wav?
String textToSynthesize = "This is test only, please disregard.";
String outputFormat = AudioOutputFormat.Raw8Khz8BitMonoMULaw;
String deviceLanguage = "en-US";
String genderName = Gender.Female;
String voiceName = "Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)";
try{
//byte[] pcm_data = TTSService.Synthesize(textToSynthesize, outputFormat, deviceLanguage, genderName, voiceName);
InputStream inSt = TTSService.Synthesize_IS(textToSynthesize, outputFormat, deviceLanguage, genderName, voiceName);
String outputFileName = mySession.getSessionId().replace(":/","") + ".wav";
// stuff file name into text variable used by prompt to play it - just hardcode URL for now
mySession.getVariableField(IProjectVariables.TTSFILE_NAME).setValue("http://localhost:8080/TestCallInfo/data/temp/" + outputFileName);
// convert to WAV
String outputWave = mySession.getAbsoluteProjectFilePath().replace("C:\\", "/").replace("\\", "/")+ "/data/temp/" + outputFileName;
AudioFormat frmt = new AudioFormat(8000, 8, 1, true, false);
//AudioInputStream ais = new AudioInputStream( new ByteArrayInputStream(pcm_data), frmt, pcm_data.length / frmt.getFrameSize() );
BufferedInputStream bInSt = new BufferedInputStream(inSt);
bInSt.mark(Integer.MAX_VALUE);
byte[] bytes = new byte[10 * 1024];
int lengthBytesRead;
int totalBytesLength = 0;
while ((lengthBytesRead = bInSt.read(bytes)) > 0) {
totalBytesLength += lengthBytesRead;
}
bInSt.reset();
AudioInputStream ais = new AudioInputStream((InputStream) bInSt, frmt, totalBytesLength / frmt.getFrameSize());
try {
AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File(outputWave) );
}
catch(Exception e) {
e.printStackTrace();
} finally {
if (ais != null)
ais.close();
}
}
catch(Exception e){
e.printStackTrace();
}
|
|
[+]
Avaya Orchestration Designer
» How to play non wav sound, 12/02/2018 08:31:16
» Go to message
|
|
Microsoft cognitive services.
|
|
[+]
Avaya Orchestration Designer
» How to play non wav sound, 09/02/2018 15:41:17
» Go to message
|
|
I have dynamically synthesized speech and I am trying to play it in AOD and AAEP.
Text can be synthesized in several different audio formats like:
riff-16khz-16bit-mono-pcm, raw-16khz-16bit-mono-pcm or riff-8khz-8bit-mono-mulaw, raw-8khz-8bit-mono-mulaw etc., then saved in temp folder.
How can I play these files – say 16khz 16bit PCM? I tried via dynamic prompts but it fails due to file format. I tried converting to wav, but it looks like only 8khz 16bit wav files are accepted so I would have to do dynamic down sampling etc.
There must better way…
Thanks!
|
|