package com.example.demo.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; /** * @Author: YafengLiang * @Description: * @Date: Created in 11:03 2018/12/21 */ public class AudioUtil { protected static final Logger logger = LoggerFactory.getLogger(AudioUtil.class); /** * @param exePath exe文件路径 * @param spePath spe文件所在路径 */ public static void spe2wav(String exePath, String spePath) { try { File file = new File(exePath); if (!file.exists()) { logger.error(exePath + " do not exist"); return; } String[] cmd = {exePath, "-f", spePath, "-callinfo"}; Process process = Runtime.getRuntime().exec(cmd); StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR"); errorGobbler.start(); StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT"); outGobbler.start(); process.waitFor(); } catch (IOException e) { e.getMessage(); } catch (InterruptedException e) { e.getCause(); } } }