Skip to content

Commit bc06364

Browse files
committed
add SpeechRequest
1 parent d1cc1b1 commit bc06364

File tree

4 files changed

+97
-23
lines changed

4 files changed

+97
-23
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.plexpt</groupId>
77
<artifactId>chatgpt</artifactId>
8-
<version>5.0.1</version>
8+
<version>5.1.0</version>
99
<name>chatgpt</name>
1010
<description>Openai ChatGPT Java SDK.</description>
1111
<url>https://chat.plexpt.com</url>
Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.plexpt.chatgpt.api;
22

33
import com.plexpt.chatgpt.entity.audio.AudioResponse;
4+
import com.plexpt.chatgpt.entity.audio.SpeechRequest;
45
import com.plexpt.chatgpt.entity.audio.Transcriptions;
56
import com.plexpt.chatgpt.entity.billing.CreditGrantsResponse;
67
import com.plexpt.chatgpt.entity.billing.SubscriptionData;
@@ -17,86 +18,99 @@
1718
import okhttp3.MultipartBody;
1819
import retrofit2.http.*;
1920

20-
2121
/**
22-
*
22+
* API接口
23+
* API interface
2324
*/
2425
public interface Api {
2526

2627
String DEFAULT_API_HOST = "https://api.openai.com/";
2728

28-
2929
/**
30-
* chat
30+
* 聊天
31+
* Chat
3132
*/
3233
@POST("v1/chat/completions")
3334
Single<ChatCompletionResponse> chatCompletion(@Body ChatCompletion chatCompletion);
3435

3536
/**
36-
* image_generations
37+
* 图像生成
38+
* Image generations
3739
*/
3840
@POST("v1/images/generations")
3941
Single<ImagesRensponse> imageGenerations(@Body Generations generations);
4042

4143
/**
42-
* image_edits
44+
* 图像编辑
45+
* Image edits
4346
*/
4447
@Multipart
4548
@POST("v1/images/edits")
4649
Single<ImagesRensponse> imageEdits(@Part() MultipartBody.Part image,
4750
@Part() MultipartBody.Part mask,
4851
@PartMap Edits edits);
4952

50-
5153
/**
52-
* image_variations
54+
* 图像变体
55+
* Image variations
5356
*/
5457
@Multipart
5558
@POST("v1/images/variations")
5659
Single<ImagesRensponse> imageVariations(@Part() MultipartBody.Part image,
5760
@PartMap Variations variations);
5861

5962
/**
60-
* audio_transcriptions
63+
* 生成语音
64+
* Create speech
65+
*/
66+
@POST("v1/audio/speech")
67+
Single<AudioResponse> audioSpeech(@Body SpeechRequest speechRequest);
68+
69+
/**
70+
* 音频转录
71+
* Audio transcriptions
6172
*/
6273
@Multipart
6374
@POST("v1/audio/transcriptions")
6475
Single<AudioResponse> audioTranscriptions(@Part() MultipartBody.Part audio,
6576
@PartMap Transcriptions transcriptions);
6677

6778
/**
68-
* audio_translations
79+
* 音频翻译
80+
* Audio translations
6981
*/
7082
@Multipart
7183
@POST("v1/audio/translations")
7284
Single<AudioResponse> audioTranslations(@Part() MultipartBody.Part audio,
7385
@PartMap Transcriptions transcriptions);
7486

75-
7687
/**
7788
* 余额查询
89+
* Credit grants query
7890
*/
7991
@GET("dashboard/billing/credit_grants")
8092
Single<CreditGrantsResponse> creditGrants();
8193

8294
/**
83-
* 余额查询
95+
* 订阅查询
96+
* Subscription query
8497
*/
8598
@GET("v1/dashboard/billing/subscription")
8699
Single<SubscriptionData> subscription();
87100

88101
/**
89-
* 余额查询
102+
* 使用情况查询
103+
* Usage query
90104
*/
91105
@GET("v1/dashboard/billing/usage")
92106
Single<UseageResponse> usage(@Query("start_date") String startDate,
93107
@Query("end_date") String endDate);
94108

95-
96109
/**
97110
* 生成向量
111+
* Create embeddings
98112
*/
99113
@POST("v1/embeddings")
100114
Single<EmbeddingResult> createEmbeddings(@Body EmbeddingRequest request);
101-
115+
102116
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.plexpt.chatgpt.entity.audio;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
9+
import lombok.extern.slf4j.Slf4j;
10+
11+
/**
12+
* 语音请求对象
13+
* Speech request object
14+
*/
15+
@Data
16+
@Builder
17+
@Slf4j
18+
@AllArgsConstructor
19+
@NoArgsConstructor(force = true)
20+
@JsonInclude(JsonInclude.Include.NON_NULL)
21+
@JsonIgnoreProperties(ignoreUnknown = true)
22+
public class SpeechRequest {
23+
24+
/**
25+
* 模型
26+
* Model https://platform.openai.com/docs/models/tts
27+
*
28+
* One of the available TTS models: tts-1 or tts-1-hd
29+
*/
30+
@Builder.Default
31+
private String model = "tts-1";
32+
33+
/**
34+
* 输入文本
35+
* Input text
36+
* The text to generate audio for. The maximum length is 4096 characters.
37+
*/
38+
private String input;
39+
40+
/**
41+
* 声音
42+
* Voice
43+
* The voice to use when generating the audio. Supported voices are alloy, echo, fable, onyx, nova, and shimmer.
44+
* Previews of the voices are available in the Text to speech guide.
45+
*
46+
* https://platform.openai.com/docs/guides/text-to-speech/voice-options
47+
*/
48+
@Builder.Default
49+
private String voice ="alloy";
50+
51+
/**
52+
* 响应格式
53+
* Response format
54+
* The format to audio in. Supported formats are mp3, opus, aac, flac, wav, and pcm.
55+
*/
56+
private String response_format;
57+
58+
/**
59+
* 速度
60+
* Speed
61+
*
62+
* The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.
63+
*/
64+
private Double speed;
65+
66+
}

src/main/java/com/plexpt/chatgpt/entity/chat/ChatCompletion.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,12 @@ public interface Model {
169169
* gpt-3.5-turbo
170170
*/
171171
String GPT_3_5_TURBO = "gpt-3.5-turbo";
172-
String GPT_3_5_TURBO_16K = "gpt-3.5-turbo-16k";
173-
String GPT_3_5_TURBO_INSTRUCT = "gpt-3.5-turbo-instruct";
174172
/**
175173
* GPT4.0
176174
*/
177175
String GPT4 = "gpt-4";
178-
String GPT4V = "gpt-4-vision-preview";
179176
String GPT4o = "gpt-4o";
180-
/**
181-
* GPT4.0 超长上下文
182-
*/
183-
String GPT_4_32K = "gpt-4-32k";
177+
String GPT4oMini = "gpt-4o-mini";
184178

185179
}
186180

0 commit comments

Comments
 (0)