百度语音识别 有MP3转pcm的方法吗
有iOS wav转pcm的库吗?w(゚Д゚)w
1、引入jar包
com.googlecode.soundlibs mp3spi 1.9.5.4
2、代码
/** * MP3转换PCM * @param inputStream MP3输入流 * @throws Exception */ public static byte[] mp3Convert2pcm(InputStream inputStream) throws Exception { //转换PCM audioInputStream 数据 AudioInputStream audioInputStream = getPcmAudioInputStream(inputStream); byte[] pcmBytes = IOUtils.toByteArray(audioInputStream); return pcmBytes; } /** * 获取PCM AudioInputStream 数据 * @param inputStream MP3输入流 * @return AudioInputStream PCM输入流 */ private static AudioInputStream getPcmAudioInputStream(InputStream inputStream) { AudioInputStream audioInputStream = null; AudioFormat targetFormat = null; try { AudioInputStream in = null; MpegAudioFileReader mp = new MpegAudioFileReader(); in = mp.getAudioInputStream(inputStream); AudioFormat baseFormat = in.getFormat(); targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false); audioInputStream = AudioSystem.getAudioInputStream(targetFormat, in); } catch (Exception e) { e.printStackTrace(); } return audioInputStream; }
我也需要啊,楼主找到了么
有iOS wav转pcm的库吗?w(゚Д゚)w
1、引入jar包
2、代码
我也需要啊,楼主找到了么