Skip to content

Commit e88906e

Browse files
authored
Merge pull request #13 from umjammer/0.0.12
0.0.12
2 parents b3c6eb3 + 023b33e commit e88906e

20 files changed

+174
-158
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Release](https://jitpack.io/v/umjammer/vavi-speech2.svg)](https://jitpack.io/#umjammer/vavi-speech2)
2-
[![Java CI](https://github.com/umjammer/vavi-speech2/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/vavi-speech2/actions)
2+
[![Java CI](https://github.com/umjammer/vavi-speech2/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/vavi-speech2/actions/workflows/maven.yml)
33
[![CodeQL](https://github.com/umjammer/vavi-speech2/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/vavi-speech2/actions/workflows/codeql-analysis.yml)
44
![Java](https://img.shields.io/badge/Java-17-b07219)
55

@@ -81,4 +81,4 @@ Text to Speech and Speech to Text (JSAPI2) engines for Java
8181
* [SHAREVOX](https://www.sharevox.app)
8282
* [http://itvoice.starfree.jp/](http://itvoice.starfree.jp/)
8383
* AVSpeechSynthesizer needs block
84-
* rcp client/server (wip)
84+
* ~~rcp client/server (wip)~~ -> [vavi-speech-rpc](https://github.com/umjammer/vavi-speech-rpc)

pom.xml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>vavi</groupId>
1010
<artifactId>vavi-speech2</artifactId>
11-
<version>0.0.11</version>
11+
<version>0.0.12</version>
1212

1313
<name>vavi-speech2</name>
1414
<description/>
@@ -22,16 +22,10 @@
2222

2323
<properties>
2424
<jsapi2.groupId>com.github.umjammer.jsapi</jsapi2.groupId> <!-- org.jvoicexml / com.github.umjammer.jsapi -->
25-
<jsapi2.version>0.6.5</jsapi2.version>
26-
<jersey.version>3.1.1</jersey.version>
27-
</properties>
25+
<jsapi2.version>0.6.6</jsapi2.version>
2826

29-
<distributionManagement>
30-
<repository>
31-
<id>github</id>
32-
<url>https://maven.pkg.github.com/umjammer/vavi-speech2</url>
33-
</repository>
34-
</distributionManagement>
27+
<jersey.version>3.1.5</jersey.version>
28+
</properties>
3529

3630
<profiles>
3731
<profile>
@@ -86,6 +80,7 @@
8680
</environmentVariables>
8781
<argLine>
8882
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
83+
-Dvavi.util.logging.VaviFormatter.extraClassMethod=sun\\.util\\.logging\\.internal\\.LoggingProviderImpl.*r#log
8984
</argLine>
9085
<includes>
9186
<include>**/*Test_*.java</include>
@@ -176,10 +171,6 @@
176171
</build>
177172

178173
<repositories>
179-
<repository>
180-
<id>github</id>
181-
<url>https://maven.pkg.github.com/umjammer/*</url>
182-
</repository>
183174
<repository>
184175
<id>jitpack.io</id>
185176
<url>https://jitpack.io</url>
@@ -199,7 +190,7 @@
199190
<dependency>
200191
<groupId>org.junit</groupId>
201192
<artifactId>junit-bom</artifactId>
202-
<version>5.10.1</version>
193+
<version>5.10.2</version>
203194
<type>pom</type>
204195
<scope>import</scope>
205196
</dependency>
@@ -228,7 +219,7 @@
228219
<dependency>
229220
<groupId>com.github.umjammer</groupId> <!-- vavi / com.github.umjammer -->
230221
<artifactId>vavi-speech</artifactId>
231-
<version>0.1.8</version>
222+
<version>0.1.9</version>
232223
<exclusions>
233224
<exclusion>
234225
<groupId>javax.speech</groupId>
@@ -274,7 +265,7 @@
274265
<dependency>
275266
<groupId>jakarta.activation</groupId>
276267
<artifactId>jakarta.activation-api</artifactId>
277-
<version>2.1.2</version>
268+
<version>2.1.3</version>
278269
</dependency>
279270

280271
<dependency>
@@ -302,7 +293,7 @@
302293
<dependency>
303294
<groupId>org.slf4j</groupId>
304295
<artifactId>slf4j-jdk14</artifactId>
305-
<version>2.0.5</version>
296+
<version>2.0.11</version>
306297
<scope>test</scope>
307298
</dependency>
308299
</dependencies>

src/main/java/vavi/speech/aquestalk10/jsapi2/AquesTalk10EngineListFactory.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public class AquesTalk10EngineListFactory implements EngineListFactory {
3333

3434
@Override
3535
public EngineList createEngineList(EngineMode require) {
36-
if (require instanceof SynthesizerMode) {
37-
SynthesizerMode mode = (SynthesizerMode) require;
36+
if (require instanceof SynthesizerMode mode) {
3837
List<Voice> allVoices = getVoices();
3938
List<Voice> voices = new ArrayList<>();
4039
if (mode.getVoices() == null) {
@@ -54,7 +53,7 @@ public EngineList createEngineList(EngineMode require) {
5453
mode.getRunning(),
5554
mode.getSupportsLetterToSound(),
5655
mode.getMarkupSupport(),
57-
voices.toArray(new Voice[0]))
56+
voices.toArray(Voice[]::new))
5857
};
5958
return new EngineList(features);
6059
}
@@ -67,7 +66,7 @@ public EngineList createEngineList(EngineMode require) {
6766
*
6867
* @return all voices
6968
*/
70-
private List<Voice> getVoices() {
69+
private static List<Voice> getVoices() {
7170
List<Voice> voiceList = new LinkedList<>();
7271
for (Map.Entry<String, AQTK_VOICE> aquesTalkVoice : AquesTalk10Wrapper.voices.entrySet()) {
7372
Voice voice = new Voice(new SpeechLocale(Locale.JAPAN.toString()),
@@ -82,11 +81,10 @@ private List<Voice> getVoices() {
8281

8382
/** */
8483
private static int toGender(AQTK_VOICE voice) {
85-
switch (voice.bas) {
86-
case 0: return Voice.GENDER_FEMALE;
87-
case 1: return Voice.GENDER_FEMALE;
88-
case 2: return Voice.GENDER_MALE;
89-
default: return Voice.GENDER_DONT_CARE;
90-
}
84+
return switch (voice.bas) {
85+
case 0, 1 -> Voice.GENDER_FEMALE;
86+
case 2 -> Voice.GENDER_MALE;
87+
default -> Voice.GENDER_DONT_CARE;
88+
};
9189
}
9290
}

src/main/java/vavi/speech/aquestalk10/jsapi2/AquesTalk10Synthesizer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public final class AquesTalk10Synthesizer extends BaseSynthesizer {
4545

4646
/** Logger for this class. */
47-
private static final Logger LOGGER = Logger.getLogger(AquesTalk10Synthesizer.class.getName());
47+
private static final Logger logger = Logger.getLogger(AquesTalk10Synthesizer.class.getName());
4848

4949
/** */
5050
@Property(binder = InstanciationBinder.class, value = "vavi.speech.phoneme.KuromojiJaPhonemer")
@@ -72,16 +72,16 @@ protected void handleAllocate() throws EngineStateException, EngineException, Au
7272
Voice voice;
7373
AquesTalk10SynthesizerMode mode = (AquesTalk10SynthesizerMode) getEngineMode();
7474
if (mode == null) {
75-
voice = null;
75+
throw new EngineException("not engine mode");
7676
} else {
7777
Voice[] voices = mode.getVoices();
78-
if (voices == null) {
79-
voice = null;
78+
if (voices == null || voices.length < 1) {
79+
throw new EngineException("no voice");
8080
} else {
8181
voice = voices[0];
8282
}
8383
}
84-
LOGGER.fine("default voice: " + voice.getName());
84+
logger.fine("default voice: " + voice.getName());
8585
getSynthesizerProperties().setVoice(voice);
8686

8787
aquesTalk10 = AquesTalk10Wrapper.getInstance();
@@ -95,7 +95,7 @@ protected void handleAllocate() throws EngineStateException, EngineException, Au
9595
/**
9696
* @param voice when null, returns default voice.
9797
*/
98-
private AQTK_VOICE toNativeVoice(Voice voice) {
98+
private static AQTK_VOICE toNativeVoice(Voice voice) {
9999
return AquesTalk10Wrapper.voices.get(voice == null ? "F1" : voice.getName());
100100
}
101101

@@ -119,7 +119,7 @@ public void handleDeallocate() {
119119
// Leave some time to let all resources detach
120120
try {
121121
Thread.sleep(500);
122-
} catch (InterruptedException e) {
122+
} catch (InterruptedException ignored) {
123123
}
124124
aquesTalk10 = null;
125125

src/main/java/vavi/speech/googlecloud/jsapi2/GoogleCloudEngineListFactory.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class GoogleCloudEngineListFactory implements EngineListFactory {
3535

3636
@Override
3737
public EngineList createEngineList(EngineMode require) {
38-
if (require instanceof SynthesizerMode) {
39-
SynthesizerMode mode = (SynthesizerMode) require;
38+
if (require instanceof SynthesizerMode mode) {
4039
List<Voice> allVoices = getVoices();
4140
List<Voice> voices = new ArrayList<>();
4241
if (mode.getVoices() == null) {
@@ -56,7 +55,7 @@ public EngineList createEngineList(EngineMode require) {
5655
mode.getRunning(),
5756
mode.getSupportsLetterToSound(),
5857
mode.getMarkupSupport(),
59-
voices.toArray(new Voice[0]))
58+
voices.toArray(Voice[]::new))
6059
};
6160
return new EngineList(features);
6261
}
@@ -69,7 +68,7 @@ public EngineList createEngineList(EngineMode require) {
6968
*
7069
* @return all voices
7170
*/
72-
private List<Voice> getVoices() {
71+
private static List<Voice> getVoices() {
7372
List<Voice> voiceList = new LinkedList<>();
7473
for (com.google.cloud.texttospeech.v1.Voice nativeVoice : listAllSupportedVoices()) {
7574
Voice voice = new Voice(new SpeechLocale(nativeVoice.getLanguageCodes(0)),

src/main/java/vavi/speech/googlecloud/jsapi2/GoogleCloudSpeechRecognizer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.jvoicexml.jsapi2.recognition.BaseRecognizer;
2929
import org.jvoicexml.jsapi2.recognition.BaseResult;
3030
import org.jvoicexml.jsapi2.recognition.GrammarDefinition;
31+
import vavi.util.Debug;
3132

3233

3334
/**
@@ -90,19 +91,18 @@ protected boolean handleResume(InputStream in) throws EngineStateException {
9091
file.deleteOnExit();
9192
FileOutputStream out = new FileOutputStream(file);
9293

93-
StringBuffer xml = new StringBuffer();
94+
StringBuilder xml = new StringBuilder();
9495
xml.append(grammar.toString());
9596
int index = xml.indexOf("06/grammar");
9697
xml.insert(index + 11, " xml:lang=\"de-DE\" ");
9798
out.write(xml.toString().getBytes());
9899
out.close();
99100
grammarSources[i] = file.getCanonicalPath();
100-
// System.out.println(xml);
101-
// System.out.println(grammarSources[i]);
101+
//Debug.println(xml);
102+
//Debug.println(grammarSources[i]);
102103

103104
} catch (IOException e) {
104-
// TODO Auto-generated catch block
105-
e.printStackTrace();
105+
Debug.printStackTrace(e);
106106
}
107107
++i;
108108
}

src/main/java/vavi/speech/googlecloud/jsapi2/GoogleCloudTextToSpeechSynthesizer.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
* @version 0.00 2019/09/20 umjammer initial version <br>
4444
*/
4545
public final class GoogleCloudTextToSpeechSynthesizer extends BaseSynthesizer {
46+
4647
/** Logger for this class. */
47-
private static final Logger LOGGER = Logger.getLogger(GoogleCloudTextToSpeechSynthesizer.class.getName());
48+
private static final Logger logger = Logger.getLogger(GoogleCloudTextToSpeechSynthesizer.class.getName());
4849

4950
/** */
5051
private TextToSpeechClient client;
@@ -63,16 +64,16 @@ protected void handleAllocate() throws EngineStateException, EngineException, Au
6364
Voice voice;
6465
GoogleCloudTextToSpeechSynthesizerMode mode = (GoogleCloudTextToSpeechSynthesizerMode) getEngineMode();
6566
if (mode == null) {
66-
voice = null;
67+
throw new EngineException("not engine mode");
6768
} else {
6869
Voice[] voices = mode.getVoices();
69-
if (voices == null) {
70-
voice = null;
70+
if (voices == null || voices.length < 1) {
71+
throw new EngineException("no voice");
7172
} else {
7273
voice = voices[0];
7374
}
7475
}
75-
LOGGER.fine("default voice: " + voice.getName());
76+
logger.fine("default voice: " + voice.getName());
7677
getSynthesizerProperties().setVoice(voice);
7778

7879
try {
@@ -88,7 +89,7 @@ protected void handleAllocate() throws EngineStateException, EngineException, Au
8889
}
8990

9091
/** */
91-
private com.google.cloud.texttospeech.v1.Voice toNativeVoice(Voice voice) {
92+
private static com.google.cloud.texttospeech.v1.Voice toNativeVoice(Voice voice) {
9293
if (voice == null) {
9394
return null;
9495
}
@@ -116,7 +117,7 @@ public void handleDeallocate() {
116117
// Leave some time to let all resources detach
117118
try {
118119
Thread.sleep(500);
119-
} catch (InterruptedException e) {
120+
} catch (InterruptedException ignored) {
120121
}
121122
client.close();
122123

@@ -138,7 +139,7 @@ public boolean handleResume() {
138139
@Override
139140
public AudioSegment handleSpeak(int id, String item) {
140141
try {
141-
byte[] bytes = synthe(item);
142+
byte[] bytes = synthesis(item);
142143
AudioManager manager = getAudioManager();
143144
String locator = manager.getMediaLocator();
144145
// you should pass bytes to BaseAudioSegment as AudioInputStream or causes crackling!
@@ -156,7 +157,7 @@ public AudioSegment handleSpeak(int id, String item) {
156157
}
157158

158159
/** */
159-
private byte[] synthe(String text) {
160+
private byte[] synthesis(String text) {
160161
SynthesisInput input = SynthesisInput.newBuilder().setText(text).build();
161162

162163
VoiceSelectionParams voice = VoiceSelectionParams.newBuilder()

0 commit comments

Comments
 (0)