| | |
| | | fileDto.setName(name); |
| | | dto.setPsdk_index(psdk_index); |
| | | dto.setFile(fileDto); |
| | | double time = getAudioDuration(file); |
| | | // double time = getAudioDuration(file); |
| | | voiceEntity.setMd5(md5); |
| | | voiceEntity.setSecond(time); |
| | | // voiceEntity.setSecond(time); |
| | | voiceEntity.setUrl(url); |
| | | voiceEntity.setName(name); |
| | | voiceMapper.insert(voiceEntity); |
| | |
| | | public int awayRiver(String sn) { |
| | | SpeakVoiceStartDto dto = new SpeakVoiceStartDto(); |
| | | SpeakVoiceFileDto fileDto = new SpeakVoiceFileDto(); |
| | | fileDto.setUrl("https://dev.jxpskj.com:8026/cloud-bucket/00015672-5d68-4985-9340-b23919d7f77e/DJI_202403060918_008_00015672-5d68-4985-9340-b23919d7f77e/qq.wav"); |
| | | fileDto.setUrl("http://dev.jxpskj.com:9000/cloud-bucket/请远离河道07151604"); |
| | | fileDto.setMd5("d2b448dcba09071834d02f082dc5386f"); |
| | | fileDto.setFormat(FormatEnum.PCM); |
| | | fileDto.setName("河道危险"); |
| | |
| | | String accessKey = pojo.getAccessKey(); |
| | | String secretKey = pojo.getSecretKey(); |
| | | String bucketName = pojo.getBucket(); |
| | | String objectName = "/" + fileName + getNowTimeName(); |
| | | String objectName = "/" + fileName + getNowTimeName()+"pcm"; |
| | | FileServiceImpl.uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, file, "audio/mpeg"); |
| | | return endpoint + "/" + bucketName + objectName; |
| | | } |
| | |
| | | return currentTime.format(DateTimeFormatter.ofPattern("MMddHHmm")); |
| | | } |
| | | |
| | | public static double getAudioDuration(File file) throws UnsupportedAudioFileException, IOException { |
| | | AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); |
| | | AudioFormat format = audioInputStream.getFormat(); |
| | | long audioFileLength = file.length(); |
| | | int frameSize = format.getFrameSize(); |
| | | float frameRate = format.getFrameRate(); |
| | | return Math.round(audioFileLength / (frameSize * frameRate)); |
| | | } |
| | | // public static double getAudioDuration(File file) throws UnsupportedAudioFileException, IOException { |
| | | // AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); |
| | | // AudioFormat format = audioInputStream.getFormat(); |
| | | // long audioFileLength = file.length(); |
| | | // int frameSize = format.getFrameSize(); |
| | | // float frameRate = format.getFrameRate(); |
| | | // return Math.round(audioFileLength / (frameSize * frameRate)); |
| | | // } |
| | | } |