|
@@ -37,26 +37,36 @@ public class VideoTextServiceImpl implements VideoTextService {
|
|
|
String filePath = FileUtil.writeFiles(localPath.toString(), url, split[split.length - 1]);
|
|
|
|
|
|
Path path = Paths.get(filePath);
|
|
|
- Path pcmPath = Paths.get(localPath.toString());
|
|
|
+ String pcmPath = null;
|
|
|
|
|
|
// 获取 PCM path
|
|
|
- Optional<String> paths = VideoToPCMTool.convertMP4toPCM(path, pcmPath);
|
|
|
+ Optional<String> paths = VideoToPCMTool.convertMP4toPCM(path, Paths.get(localPath.toString()));
|
|
|
String videoText = null;
|
|
|
if (!Check.isNull(paths)) {
|
|
|
- videoText = VoiceTool.getVideoText(paths.get());
|
|
|
+ pcmPath = paths.get();
|
|
|
+ videoText = VoiceTool.getVideoText(pcmPath);
|
|
|
}
|
|
|
- try {
|
|
|
- File file = path.toFile();
|
|
|
- if (file.exists()) {
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- File pcmFile = pcmPath.toFile();
|
|
|
- if (pcmFile.exists()) {
|
|
|
- pcmFile.delete();
|
|
|
+ String finalPcmPath = pcmPath;
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ Thread.sleep(10000);
|
|
|
+ File file = path.toFile();
|
|
|
+ if (file.exists()) {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ File pcmFile = new File(finalPcmPath);
|
|
|
+ if (pcmFile.exists()) {
|
|
|
+ pcmFile.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
return ResultResponse.success(videoText);
|
|
|
}
|
|
|
|