我们使用AudioRecord录制的声音文件为PCM格式的,如何使用JAVA将PCM格式转化为MP3或者WAVE格式呢?非常简单,来看看下面的示例吧!package com.test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class TestDemo {
static Map map = new HashMap();
public static void main(String[] args) throws IOException {
//如果想要把pcm转wave,直接将后缀改成wave即可
convertAudioFiles("D:\\excelFile\\1606288228441.pcm", "D:\\excelFile\\tnafcs.mp3");
}
//PCM转MP3工具类
public static String convertAudioFiles(String src, String target) throws IOException {
try {
FileInputStream fis = new FileInputStream(src);
FileOutputStream fos = new FileOutputStream(target);
//Calculate the length
byte[] buf &