库依赖
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
代码
URL url= null;
try {
url = new URL("http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=欢迎");
} catch (MalformedURLException e) {
e.printStackTrace();
}
URLConnection urlConnection = null;
try {
urlConnection = url.openConnection();
} catch (IOException e) {
e.printStackTrace();
}
Player player= null;
try {
InputStream inputStream = urlConnection.getInputStream();
player = new Player(inputStream);
player.play();
} catch (Exception e) {
e.printStackTrace();
}
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END