@@ -0,0 +1,2181 @@
+package com.ibm.watson.developer_cloud.text_to_speech.v1.util;%0A%0Aimport java.io.ByteArrayInputStream;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Aimport com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;%0A%0A%0A/**%0A * Utility class to write the data size header in wave(.wav) files synthesized with the%0A * %7B@link TextToSpeech%7D service%0A */%0Apublic class WaveUtils %7B%0A%0A  /** The WAVE header byte size. (value is 44) */%0A  private static final int WAVE_HEADER_BYTE_SIZE = 44;%0A%0A  /**%0A   * Adds the data size to the header(bytes 4-8) of the WAVE(.wav) input stream.%3Cbr%3E%0A   * It needs to be read in order to calculate the size.%0A   * %0A   * @param is the input stream%0A   * @return A new input stream that includes the data header in the header%0A   * @throws IOException Signals that an I/O exception has occurred.%0A   */%0A  public static InputStream addDataSizeToInputStream(InputStream is) throws IOException %7B%0A    byte%5B%5D audioBytes = toByteArray(is);%0A    int filesize = audioBytes.length - 8;%0A    audioBytes%5B4%5D = (byte) (filesize);%0A    audioBytes%5B5%5D = (byte) (filesize %3E%3E%3E 8);%0A    audioBytes%5B6%5D = (byte) (filesize %3E%3E%3E 16);%0A    audioBytes%5B7%5D = (byte) (filesize %3E%3E%3E 24);%0A%0A    int datasize = filesize + 8 - WAVE_HEADER_BYTE_SIZE;%0A    audioBytes%5B40%5D = (byte) (datasize);%0A    audioBytes%5B41%5D = (byte) (datasize %3E%3E%3E 8);%0A    audioBytes%5B42%5D = (byte) (datasize %3E%3E%3E 16);%0A    audioBytes%5B43%5D = (byte) (datasize %3E%3E%3E 24);%0A%0A%0A    return new ByteArrayInputStream(audioBytes);%0A  %7D%0A%0A  /**%0A   * Converts an %7B@link InputStream%7D to byte array%0A   * %0A   * @param is the input stream%0A   * @return the byte array%0A   * @throws IOException If the first byte cannot be read for any reason other than end of file, or%0A   *         if the input stream has been closed, or if some other I/O error occurs.%0A   */%0A  public static byte%5B%5D toByteArray(InputStream is) throws IOException %7B%0A    ByteArrayOutputStream buffer = new ByteArrayOutputStream();%0A%0A    int nRead;%0A    byte%5B%5D data = new byte%5B16384%5D; // 4 kb%0A%0A    while ((nRead = is.read(data, 0, data.length)) != -1) %7B%0A      buffer.write(data, 0, nRead);%0A    %7D%0A%0A    buffer.flush();%0A    return buffer.toByteArray();%0A  %7D%0A%0A%7D%0A

Add a WaveUtils class to fix the .wav header #81