Merge remote-tracking branch 'origin/dev'
commit
afcdc8a749
|
@ -0,0 +1,57 @@
|
|||
package com.jwl.driver.server.controller;
|
||||
|
||||
|
||||
import com.jwl.driver.server.dto.LoginUserDto;
|
||||
import com.jwl.driver.server.response.BaseResponse;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 支付表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Automated procedures
|
||||
* @since 2023-08-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/voice")
|
||||
@Slf4j
|
||||
public class VoiceController {
|
||||
@ApiOperation("文字转语音")
|
||||
@GetMapping("/contentToAudio")
|
||||
public void contentToAudio(@RequestParam String content) {
|
||||
log.info("文字转语音======>content:{}", content);
|
||||
final AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
|
||||
|
||||
DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, format);
|
||||
|
||||
if (!AudioSystem.isLineSupported(dataLineInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TargetDataLine targetDataLine;
|
||||
try {
|
||||
targetDataLine = (TargetDataLine) AudioSystem.getLine(dataLineInfo);
|
||||
targetDataLine.open(format);
|
||||
targetDataLine.start();
|
||||
|
||||
// Record audio
|
||||
AudioInputStream audioInputStream = new AudioInputStream(targetDataLine);
|
||||
|
||||
// Save audio to file
|
||||
File audioFile = new File("recorded_audio.wav");
|
||||
AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, audioFile);
|
||||
targetDataLine.close();
|
||||
} catch (LineUnavailableException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ spring:
|
|||
application:
|
||||
name: '@artifactId@'
|
||||
profiles:
|
||||
active: test
|
||||
active: dev
|
||||
#mybatis
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:/mapper/**Mapper.xml
|
||||
|
|
Loading…
Reference in New Issue