| | |
| | | |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.mqtt.service.IMessageSenderService; |
| | | import com.dji.sample.patches.config.pojo.PatchesConfigPojo; |
| | | import com.dji.sample.patches.utils.MultipartFileTOFileUtil; |
| | | import com.dji.sample.speak.model.dto.PsdkModelDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVoiceStartDto; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.sound.sampled.UnsupportedAudioFileException; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | import static com.dji.sample.speak.util.AudioConverter.convertAudio; |
| | | import static com.dji.sample.speak.util.AudioConverter.convertToFile; |
| | | |
| | | @RestController |
| | | @RequestMapping("${url.speak.prefix}${url.speak.version}") |
| | | public class SpeakVoiceController { |
| | | @Autowired |
| | | private SpeakVoiceService voiceServicel; |
| | | @Autowired |
| | | private PatchesConfigPojo patchesConfigPojo; |
| | | |
| | | @PostMapping("/startVoice") |
| | | public ResponseResult takeVoice(@RequestParam String sn, |
| | | @RequestParam int psdk_index, |
| | | @RequestParam String name, |
| | | @RequestParam MultipartFile file) { |
| | | File file1=MultipartFileTOFileUtil.multipartFile2File(file,"src/main/resources/tmp/20240614"); |
| | | return ResponseResult.success(voiceServicel.takeVoice(sn, psdk_index,name,file1)); |
| | | @RequestParam Integer volumn, |
| | | @RequestParam MultipartFile file) throws UnsupportedAudioFileException, IOException { |
| | | File file1 = MultipartFileTOFileUtil.multipartFile2File(file, patchesConfigPojo.getUnzip()); |
| | | File convertFile = convertAudio(file1); |
| | | return ResponseResult.success(voiceServicel.takeVoice(sn, psdk_index, name, convertFile, volumn)); |
| | | } |
| | | |
| | | @PostMapping("/stopVoice") |
| | |
| | | } |
| | | |
| | | @PostMapping("/restartVoice") |
| | | public ResponseResult restartVoice(@RequestParam int psdkIndex, @RequestParam String sn) { |
| | | return ResponseResult.success(voiceServicel.restartVoice(sn, psdkIndex)); |
| | | public ResponseResult restartVoice(@RequestParam int psdk_index, @RequestParam String sn) { |
| | | return ResponseResult.success(voiceServicel.restartVoice(sn, psdk_index)); |
| | | } |
| | | |
| | | @PostMapping("/putVoice") |
| | | public ResponseResult putVoice(@RequestParam String sn) { |
| | | return ResponseResult.success(voiceServicel.awayRiver(sn)); |
| | | } |
| | | |
| | | @GetMapping("/selectVoice") |
| | | public ResponseResult getVoices(@RequestParam Integer page, @RequestParam Integer page_size) { |
| | | return ResponseResult.success(voiceServicel.getVoices(page, page_size)); |
| | | } |
| | | |
| | | @PostMapping("/startVoices") |
| | | public ResponseResult takeVoices( |
| | | @RequestParam String sn, |
| | | @RequestParam int psdk_index, |
| | | @RequestParam String name, |
| | | @RequestParam String url) throws UnsupportedAudioFileException, IOException { |
| | | return ResponseResult.success(voiceServicel.takeVoices(sn, psdk_index, name, url)); |
| | | } |
| | | |
| | | } |