Skip to content

Commit 9c4cb16

Browse files
authored
Merge pull request #2 from k7t3/v0.1.2
v0.1.2
2 parents 5a4b1aa + f1cd86f commit 9c4cb16

File tree

33 files changed

+701
-205
lines changed

33 files changed

+701
-205
lines changed

.github/workflows/publish.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ jobs:
5858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
5959
with:
6060
draft: true # ドラフトリリースとし、公開は手動で行う
61-
files: release/**
61+
files: release/**
62+
generate_release_notes: true # リリースノートの自動生成

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Usage:
2727

2828
コマンドラインラッパーライブラリを使用するには、ライブラリの依存関係をプロジェクトに追加します。
2929
```groovy
30-
implementation group: 'io.github.k7t3', name: 'voicepeakcw4j', version: '0.1.0'
30+
implementation group: 'io.github.k7t3', name: 'voicepeakcw4j', version: '0.1.2'
3131
```
3232

3333
1. コマンドラインを実行するために、実行ファイルのパスを指定します。
@@ -79,7 +79,7 @@ implementation group: 'io.github.k7t3', name: 'voicepeakcw4j', version: '0.1.0'
7979

8080
音声の即時読み上げスピーチライブラリを使用するには、ライブラリの依存関係をプロジェクトに追加します。
8181
```groovy
82-
implementation group: 'io.github.k7t3', name: 'voicepeakcw4j-speech', version: '0.1.0'
82+
implementation group: 'io.github.k7t3', name: 'voicepeakcw4j-speech', version: '0.1.2'
8383
```
8484

8585
1. VOICEPEAK実行パスを指定し、スピーチクライアントを生成します。
@@ -108,7 +108,9 @@ implementation group: 'io.github.k7t3', name: 'voicepeakcw4j-speech', version: '
108108
.withVolumeRate(0.2f)
109109
.withSpeed(110)
110110
.build();
111-
speech.run();
111+
112+
// 読み上げを開始して状態を取得
113+
var state = speech.start();
112114
```
113115

114116

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
voicepeakcw4jVersion=0.1.1
1+
voicepeakcw4jVersion=0.1.2-SNAPSHOT
22

33
javaVersion=21
44
junitVersion=5.10.0

voicepeakcw4j-mock/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
## Implementation
66
* Javaアプリケーションとして作成
7+
* 想定しているナレーターは東北きりたん(Tohoku Kiritan)、ずんだもん(Zundamon)のみ
78
* コマンドライン実行のオプションの内容を標準出力にプリントする
9+
* サンプル音声をコピーすることで音声を合成したこととする
810

911
## Usage
10-
1. [VoicePeak.java](src/main/java/com/github/k7t3/voicepeakcw4j/VoicePeak.java)を作成
12+
1. [VoicePeak.java](src/main/java/io/github/k7t3/voicepeakcw4j/VoicePeak.java)を作成
1113
2. gradleタスク `buildMock`を実行してモックアプリケーションを生成
12-
3. [TestVPExecutable.java](../voicepeakcw4j/src/test/java/com/github/k7t3/voicepeakcw4j/TestVPExecutable.java)で使用
14+
3. [TestVPExecutable.java](../voicepeakcw4j/src/test/java/io/github/k7t3/voicepeakcw4j/TestVPExecutable.java)で使用

voicepeakcw4j-mock/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
application {
7-
mainClass = 'com.github.k7t3.voicepeakcw4j.VoicePeak'
7+
mainClass = 'io.github.k7t3.voicepeakcw4j.VoicePeak'
88
}
99

1010
repositories {
@@ -26,6 +26,11 @@ test {
2626
useJUnitPlatform()
2727
}
2828

29+
shadowJar {
30+
// バージョン名をアーカイブに含めないようにする
31+
archiveVersion.set('')
32+
}
33+
2934
tasks.register('buildMock', Copy) {
3035
dependsOn shadowJar
3136

voicepeakcw4j-mock/src/main/java/io/github/k7t3/voicepeakcw4j/NarratorEmotions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.List;
2020

21+
/**
22+
* VOICEPEAK v1.2.11
23+
*/
2124
class NarratorEmotions {
2225

2326
public static List<String> get(String narrator) {

voicepeakcw4j-mock/src/main/java/io/github/k7t3/voicepeakcw4j/VoicePeak.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import java.util.Arrays;
2424
import java.util.stream.Collectors;
2525

26+
/**
27+
* VOICEPEAK v1.2.11
28+
*/
2629
public class VoicePeak {
2730

2831
public static void main(String[] args) {
@@ -51,13 +54,19 @@ public static void main(String[] args) {
5154
}
5255

5356
if (cmd.hasOption("list-narrator")) {
54-
listNarrators();
57+
System.out.println("Zundamon");
58+
System.out.println("Tohoku Kiritan");
5559
return;
5660
}
5761

5862
if (cmd.hasOption("list-emotion")) {
5963
String narrator = cmd.getOptionValue("list-emotion");
60-
listEmotions(narrator);
64+
if (narrator == null || narrator.trim().isEmpty()) {
65+
System.out.println("error parsing options: Option 'list-emotion' is missing an argument");
66+
return;
67+
}
68+
69+
NarratorEmotions.get(narrator).forEach(System.out::println);
6170
return;
6271
}
6372

@@ -117,13 +126,4 @@ public static void main(String[] args) {
117126
}
118127
}
119128

120-
private static void listNarrators() {
121-
System.out.println("Zundamon");
122-
System.out.println("Tohoku Kiritan");
123-
}
124-
125-
private static void listEmotions(String narrator) {
126-
NarratorEmotions.get(narrator).forEach(System.out::println);
127-
}
128-
129129
}

voicepeakcw4j-mock/src/main/java/io/github/k7t3/voicepeakcw4j/VoicepeakRunner.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@
1919
import java.io.IOException;
2020
import java.nio.file.Files;
2121
import java.nio.file.Path;
22+
import java.nio.file.StandardCopyOption;
2223
import java.util.Map;
24+
import java.util.Objects;
25+
import java.util.concurrent.TimeUnit;
2326
import java.util.stream.Collectors;
2427

28+
/**
29+
* VOICEPEAK v1.2.11
30+
*/
2531
@SuppressWarnings("UnusedReturnValue")
26-
public class VoicepeakRunner {
32+
class VoicepeakRunner {
2733

2834
private String narrator;
2935

@@ -73,6 +79,9 @@ public VoicepeakRunner withEmotion(Map<String, Integer> emotion) {
7379
return this;
7480
}
7581

82+
/**
83+
* 対応するナレーターが存在しないとき、あるいはナレーターに対応する感情が指定されたときに出力されるエラー
84+
*/
7685
private void errorPrint() {
7786
System.err.println("Internal BUG occurred. Please report what you are doing and these details to us.");
7887
System.err.println("===== BEGIN BUG REPORT =====");
@@ -111,15 +120,27 @@ public void run() {
111120
System.out.println("Speech File: " + speechFile.toAbsolutePath());
112121
}
113122

114-
if (output != null) {
115-
if (!Files.exists(output)) {
116-
try {
117-
Files.createFile(output);
118-
} catch (IOException e) {
119-
System.getLogger("VOICEPEAK Mock").log(System.Logger.Level.WARNING, "failed to output");
123+
var o = output;
124+
if (o == null) {
125+
// 既定の出力場所はホームディレクトリのoutput.wav
126+
o = Path.of(System.getProperty("user.home"), "output.wav");
127+
}
128+
{
129+
try {
130+
// 生成完了までの遅延として遅延をエミュレート
131+
TimeUnit.SECONDS.sleep(1);
132+
} catch (InterruptedException e) {
133+
System.err.println("failed to sleep");
134+
}
135+
try {
136+
// テスト音声を出力ファイルとしてコピーする
137+
try (var input = getClass().getResourceAsStream("/test.wav")) {
138+
Files.copy(Objects.requireNonNull(input), o, StandardCopyOption.REPLACE_EXISTING);
120139
}
140+
} catch (IOException e) {
141+
System.err.println("failed to output");
121142
}
122-
System.out.println("Output: " + output.toAbsolutePath());
143+
System.out.println("Output: " + o.toAbsolutePath());
123144
}
124145

125146
if (pitch != Integer.MIN_VALUE) {
202 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)