Skip to content

Commit 150949d

Browse files
feat: 20250801 tts mp3 (#88)
1 parent a5aa713 commit 150949d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main/java/com/zhipu/oapi/service/v4/audio/AudioSpeechRequest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public class AudioSpeechRequest extends CommonRequest implements ClientRequest<M
4343
*/
4444
private String responseFormat;
4545

46+
/**
47+
* 需要流式返回的音频编码格式
48+
*/
49+
private String encodeFormat;
50+
4651
/**
4752
* 敏感词检测控制
4853
*/
@@ -58,6 +63,7 @@ public Map<String, Object> getOptions() {
5863
paramsMap.put("stream", this.isStream());
5964
paramsMap.put("voice", this.getVoice());
6065
paramsMap.put("response_format", this.getResponseFormat());
66+
paramsMap.put("encode_format", this.getEncodeFormat());
6167
paramsMap.put("sensitive_word_check", this.getSensitiveWordCheck());
6268
if(this.getExtraJson() !=null){
6369
paramsMap.putAll(this.getExtraJson());

src/test/java/com/zhipu/oapi/V4Test.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class V4Test {
4949
private static final String API_BASE_URL = Constants.getBaseUrl();
5050

5151

52-
private static final ClientV4 client = new ClientV4.Builder(API_BASE_URL,API_SECRET_KEY)
52+
private static final ClientV4 client = new ClientV4.Builder(API_BASE_URL, API_SECRET_KEY)
5353
.enableTokenCache()
5454
.networkConfig(300, 100, 100, 100, TimeUnit.SECONDS)
5555
.connectionPool(new okhttp3.ConnectionPool(8, 1, TimeUnit.SECONDS))
@@ -673,8 +673,9 @@ public void testAudioSpeechStreaming() throws IOException {
673673
AudioSpeechRequest audioSpeechRequest =
674674
AudioSpeechRequest.builder()
675675
.model(Constants.ModelTTS)
676-
.input("智谱,你好呀")
677-
.voice("tongtong")
676+
.encodeFormat("base64")
677+
.input("你好,欢迎来到智谱开放平台")
678+
.voice("female")
678679
.stream(Boolean.TRUE)
679680
.responseFormat("wav")
680681
.build();

0 commit comments

Comments
 (0)