0
에 대한 오디오이 내 자바 코드입니다 점점하지 오전 :나는 왓슨 TTS
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AudioFormat;
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice;
public static void main(String[] args) {
TextToSpeech textService = new TextToSpeech(IBM_WATSON_USERNAME, IBM_WATSON_PASSWORD);
String text = "Show me the meaning of being lonely";
try {
InputStream in = textService.synthesize(text, Voice.EN_ALLISON, AudioFormat.WAV)
.execute();
System.out.println(in.available());
byte[] buffer = new byte[in.available()];
in.read(buffer);
File targetFile = new File("local_path/Aud.wav");
OutputStream outStream = new FileOutputStream(targetFile);
outStream.write(buffer);
outStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
나는 같은 이클립스 콘솔에서 응답을 얻고 코드를 실행하면 :
Dec 13, 2017 5:38:35 PM okhttp3.internal.platform.Platform log
INFO: --> POST https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_AllisonVoice&accept=audio/wav http/1.1 (71-byte body)
Dec 13, 2017 5:38:35 PM okhttp3.internal.platform.Platform log
INFO: <-- 200 OK https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_AllisonVoice&accept=audio/wav (501ms, unknown-length body)
값 of.available()은 0입니다.
오디오가 생성되지 않습니다. 따라서 코드 흐름 당 0kB의 .wav 파일이 생성됩니다. 어떤 오디오가 들리지 않습니까?
감사 레오나르도 시도 – Rohit