这是indexloc提供的服务,不要输入任何密码
Skip to content

Feature/add support for instructions for speech api #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ OpenAi4J是一个非官方的Java库,旨在帮助java开发者与OpenAI的GPT
## 导入依赖
### Gradle

`implementation 'io.github.lambdua:<api|client|service>:0.22.92'`
`implementation 'io.github.lambdua:<api|client|service>:0.22.93'`
### Maven
```xml

<dependency>
<groupId>io.github.lambdua</groupId>
<artifactId>service</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</dependency>
```

Expand Down Expand Up @@ -61,7 +61,7 @@ static void simpleChat() {
<dependency>
<groupId>io.github.lambdua</groupId>
<artifactId>api</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ applications effortlessly.
## Import
### Gradle

`implementation 'io.github.lambdua:<api|client|service>:0.22.92'`
`implementation 'io.github.lambdua:<api|client|service>:0.22.93'`
### Maven
```xml

<dependency>
<groupId>io.github.lambdua</groupId>
<artifactId>service</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</dependency>
```

Expand Down Expand Up @@ -67,7 +67,7 @@ To utilize pojos, import the api module:
<dependency>
<groupId>io.github.lambdua</groupId>
<artifactId>api</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.lambdua</groupId>
<artifactId>openai-java</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</parent>
<packaging>jar</packaging>
<artifactId>api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public class CreateSpeechRequest {
* The speed of the generated audio. Select a value from 0.25 to 4.0. Defaults to 1.0.
*/
Double speed;

String instructions;
}
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.lambdua</groupId>
<artifactId>openai-java</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</parent>
<packaging>jar</packaging>

Expand Down
4 changes: 2 additions & 2 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.lambdua</groupId>
<artifactId>example</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
<name>example</name>

<properties>
Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>io.github.lambdua</groupId>
<artifactId>service</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</dependency>

</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.lambdua</groupId>
<artifactId>openai-java</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
<packaging>pom</packaging>
<description>openai java 版本</description>
<url>https://github.com/Lambdua/openai-java</url>
Expand Down
2 changes: 1 addition & 1 deletion service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.lambdua</groupId>
<artifactId>openai-java</artifactId>
<version>0.22.92</version>
<version>0.22.93</version>
</parent>
<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,19 @@ void createSpeech() throws IOException {
assertEquals(MediaType.get("audio/mpeg"), speech.contentType());
assertTrue(speech.bytes().length > 0);
}

@Test
void createSpeechWithInstructions() throws IOException {
CreateSpeechRequest createSpeechRequest = CreateSpeechRequest.builder()
.model("tts-1")
.input("Hello World.")
.voice("alloy")
.instructions("Please read the text in a normal voice.")
.build();

final ResponseBody speech = service.createSpeech(createSpeechRequest);
assertNotNull(speech);
assertEquals(MediaType.get("audio/mpeg"), speech.contentType());
assertTrue(speech.bytes().length > 0);
}
}